mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-26 18:41:17 +00:00
* 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. Daniel
This commit is contained in:
parent
8ebe070edc
commit
6a1e3d5f36
@ -1,3 +1,10 @@
|
||||
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
|
||||
|
@ -84,7 +84,21 @@ extern "C" {
|
||||
#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
|
||||
@ -104,6 +118,10 @@ struct _virConnect {
|
||||
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 */
|
||||
@ -125,8 +143,9 @@ struct _virConnect {
|
||||
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 */
|
||||
};
|
||||
|
||||
@ -158,6 +177,19 @@ struct _virDomain {
|
||||
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
|
||||
*/
|
||||
@ -172,6 +204,7 @@ char *virDomainGetVMInfo(virDomainPtr domain,
|
||||
************************************************************************/
|
||||
void __virRaiseError(virConnectPtr conn,
|
||||
virDomainPtr dom,
|
||||
virNetworkPtr net,
|
||||
int domain,
|
||||
int code,
|
||||
virErrorLevel level,
|
||||
@ -196,6 +229,11 @@ int virFreeDomain (virConnectPtr conn,
|
||||
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
|
||||
}
|
||||
|
@ -1383,7 +1383,7 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root, int xendConfigVersi
|
||||
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",
|
||||
|
@ -540,7 +540,7 @@ int xenXMDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) {
|
||||
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 ||
|
||||
@ -649,12 +649,13 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
||||
@ -663,7 +664,6 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
|
||||
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);
|
||||
@ -1122,7 +1122,7 @@ unsigned long xenXMDomainGetMaxMemory(virDomainPtr domain) {
|
||||
val < 0)
|
||||
if (xenXMConfigGetInt(entry->conf, "memory", &val) < 0 ||
|
||||
val < 0)
|
||||
val = 64;
|
||||
val = MIN_XEN_GUEST_SIZE * 2;
|
||||
|
||||
return (val * 1024);
|
||||
}
|
||||
|
@ -1026,7 +1026,7 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int
|
||||
|
||||
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);
|
||||
@ -1034,7 +1034,7 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user