+Thu Mar 8 15:10:12 CET 2007 Daniel Veillard <veillard@redhat.com>
+
+ * src/internal.h src/xend_internal.c src/xm_internal.c src/xml.c:
+ add a check for minimal size of Xen Dom0, track places where we
+ had arbitrary minimal memory requirement and use a predefined
+ macro to clean this up.
+
Thu Mar 8 08:45:46 EST 2007 Daniel P., Berrange <berrange@redhat.com>
* src/virsh.c: Added an explicit --readonly option to virsh
#define VIR_IS_DOMAIN(obj) ((obj) && (obj)->magic==VIR_DOMAIN_MAGIC)
#define VIR_IS_CONNECTED_DOMAIN(obj) (VIR_IS_DOMAIN(obj) && VIR_IS_CONNECT((obj)->conn))
+/**
+ * VIR_NETWORK_MAGIC:
+ *
+ * magic value used to protect the API when pointers to network structures
+ * are passed down by the uers.
+ */
+#define VIR_NETWORK_MAGIC 0xDEAD1234
+#define VIR_IS_NETWORK(obj) ((obj) && (obj)->magic==VIR_NETWORK_MAGIC)
+#define VIR_IS_CONNECTED_NETWORK(obj) (VIR_IS_NETWORK(obj) && VIR_IS_CONNECT((obj)->conn))
+
+/*
+ * arbitrary limitations
+ */
#define MAX_DRIVERS 10
+#define MIN_XEN_GUEST_SIZE 64 /* 64 megabytes */
/*
* Flags for Xen connections
virDriverPtr drivers[MAX_DRIVERS];
int nb_drivers;
+ /* the list of available network drivers */
+ virNetworkDriverPtr networkDrivers[MAX_DRIVERS];
+ int nb_network_drivers;
+
/* extra data needed by drivers */
int handle; /* internal handle used for hypercall */
struct xs_handle *xshandle;/* handle to talk to the xenstore */
void *userData; /* the user data */
/* misc */
- xmlMutexPtr hashes_mux;/* a mutex to protect the domain hash table */
+ xmlMutexPtr hashes_mux;/* a mutex to protect the domain and networks hash tables */
virHashTablePtr domains;/* hash table for known domains */
+ virHashTablePtr networks;/* hash table for known domains */
int flags; /* a set of connection flags */
};
char *xml; /* the XML description for defined domains */
};
+/**
+* _virNetwork:
+*
+* Internal structure associated to a domain
+*/
+struct _virNetwork {
+ unsigned int magic; /* specific value to check */
+ int uses; /* reference count */
+ virConnectPtr conn; /* pointer back to the connection */
+ char *name; /* the network external name */
+ unsigned char uuid[VIR_UUID_BUFLEN]; /* the network unique identifier */
+};
+
/*
* Internal routines
*/
************************************************************************/
void __virRaiseError(virConnectPtr conn,
virDomainPtr dom,
+ virNetworkPtr net,
int domain,
int code,
virErrorLevel level,
virDomainPtr domain);
virDomainPtr virGetDomainByID(virConnectPtr conn,
int id);
+virNetworkPtr virGetNetwork (virConnectPtr conn,
+ const char *name,
+ const unsigned char *uuid);
+int virFreeNetwork (virConnectPtr conn,
+ virNetworkPtr domain);
#ifdef __cplusplus
}
if (cur_mem > max_mem)
max_mem = cur_mem;
virBufferVSprintf(&buf, " <memory>%d</memory>\n", max_mem);
- if ((cur_mem > 63) && (cur_mem != max_mem))
+ if ((cur_mem >= MIN_XEN_GUEST_SIZE) && (cur_mem != max_mem))
virBufferVSprintf(&buf, " <currentMemory>%d</currentMemory>\n",
cur_mem);
virBufferVSprintf(&buf, " <vcpu>%d</vcpu>\n",
memset(info, 0, sizeof(virDomainInfo));
if (xenXMConfigGetInt(entry->conf, "memory", &mem) < 0 ||
mem < 0)
- info->memory = 64 * 1024;
+ info->memory = MIN_XEN_GUEST_SIZE * 1024 * 2;
else
info->memory = (unsigned long)mem * 1024;
if (xenXMConfigGetInt(entry->conf, "maxmem", &mem) < 0 ||
}
if (xenXMConfigGetInt(conf, "memory", &val) < 0)
- val = 64;
- virBufferVSprintf(buf, " <currentMemory>%ld</currentMemory>\n", val * 1024);
+ val = MIN_XEN_GUEST_SIZE * 2;
+ virBufferVSprintf(buf, " <currentMemory>%ld</currentMemory>\n",
+ val * 1024);
if (xenXMConfigGetInt(conf, "maxmem", &val) < 0)
if (xenXMConfigGetInt(conf, "memory", &val) < 0)
- val = 64;
+ val = MIN_XEN_GUEST_SIZE * 2;
virBufferVSprintf(buf, " <memory>%ld</memory>\n", val * 1024);
virBufferVSprintf(buf, " <vcpu>%ld</vcpu>\n", val);
-
if (xenXMConfigGetString(conf, "on_poweroff", &str) < 0)
str = "destroy";
virBufferVSprintf(buf, " <on_poweroff>%s</on_poweroff>\n", str);
val < 0)
if (xenXMConfigGetInt(entry->conf, "memory", &val) < 0 ||
val < 0)
- val = 64;
+ val = MIN_XEN_GUEST_SIZE * 2;
return (val * 1024);
}
obj = xmlXPathEval(BAD_CAST "number(/domain/memory[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_NUMBER) ||
- (isnan(obj->floatval)) || (obj->floatval < 64000)) {
+ (isnan(obj->floatval)) || (obj->floatval < MIN_XEN_GUEST_SIZE * 1024)) {
max_mem = 128;
} else {
max_mem = (obj->floatval / 1024);
xmlXPathFreeObject(obj);
obj = xmlXPathEval(BAD_CAST "number(/domain/currentMemory[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_NUMBER) ||
- (isnan(obj->floatval)) || (obj->floatval < 64000)) {
+ (isnan(obj->floatval)) || (obj->floatval < MIN_XEN_GUEST_SIZE * 1024)) {
mem = max_mem;
} else {
mem = (obj->floatval / 1024);