From: Kiarie Kahurani <davidkiarie4@xxxxxxxxx> introduce function xenParseXMMem(virConfPtr conf,.........); which parses memory config instead signed-off-by: David Kiarie<davidkiarie4@xxxxxxxxx> --- src/xenxs/xen_xm.c | 83 +++++++++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 38 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 4461654..443e6da 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -40,11 +40,9 @@ #include "virstoragefile.h" #include "virstring.h" -/* Convenience method to grab a long int from the config file object */ -static int xenXMConfigGetBool(virConfPtr conf, - const char *name, - int *value, - int def) +/* Convenience method to grab a int from the config file object */ +static int +xenXMConfigGetBool(virConfPtr conf, const char *name, int *value, int def) { virConfValuePtr val; @@ -67,11 +65,10 @@ static int xenXMConfigGetBool(virConfPtr conf, } -/* Convenience method to grab a int from the config file object */ -static int xenXMConfigGetULong(virConfPtr conf, - const char *name, - unsigned long *value, - unsigned long def) +/* Convenience method to grab a long int from the config file object */ +static int +xenXMConfigGetULong(virConfPtr conf, const char *name, unsigned long *value, + unsigned long def) { virConfValuePtr val; @@ -99,10 +96,9 @@ static int xenXMConfigGetULong(virConfPtr conf, /* Convenience method to grab a int from the config file object */ -static int xenXMConfigGetULongLong(virConfPtr conf, - const char *name, - unsigned long long *value, - unsigned long long def) +static int +xenXMConfigGetULongLong(virConfPtr conf, const char *name, + unsigned long long *value, unsigned long long def) { virConfValuePtr val; @@ -130,10 +126,9 @@ static int xenXMConfigGetULongLong(virConfPtr conf, /* Convenience method to grab a string from the config file object */ -static int xenXMConfigGetString(virConfPtr conf, - const char *name, - const char **value, - const char *def) +static int +xenXMConfigGetString(virConfPtr conf, const char *name, const char **value, + const char *def) { virConfValuePtr val; @@ -155,10 +150,10 @@ static int xenXMConfigGetString(virConfPtr conf, return 0; } -static int xenXMConfigCopyStringInternal(virConfPtr conf, - const char *name, - char **value, - int allowMissing) + +static int +xenXMConfigCopyStringInternal(virConfPtr conf, const char *name, char **value, + int allowMissing) { virConfValuePtr val; @@ -188,15 +183,16 @@ static int xenXMConfigCopyStringInternal(virConfPtr conf, } -static int xenXMConfigCopyString(virConfPtr conf, - const char *name, - char **value) { +static int +xenXMConfigCopyString(virConfPtr conf, const char *name, char **value) +{ return xenXMConfigCopyStringInternal(conf, name, value, 0); } -static int xenXMConfigCopyStringOpt(virConfPtr conf, - const char *name, - char **value) { + +static int +xenXMConfigCopyStringOpt(virConfPtr conf, const char *name, char **value) +{ return xenXMConfigCopyStringInternal(conf, name, value, 1); } @@ -244,6 +240,25 @@ xenXMConfigGetUUID(virConfPtr conf, const char *name, unsigned char *uuid) return 0; } + +static int +xenParseXMMem(virConfPtr conf, virDomainDefPtr def) +{ + if (xenXMConfigGetULongLong(conf, "memory", &def->mem.cur_balloon, + MIN_XEN_GUEST_SIZE * 2) < 0) + return -1; + + if (xenXMConfigGetULongLong(conf, "maxmem", &def->mem.max_balloon, + def->mem.cur_balloon) < 0) + return -1; + + def->mem.cur_balloon *= 1024; + def->mem.max_balloon *= 1024; + + return 0; +} + + #define MAX_VFB 1024 /* * Turn a config record into a lump of XML describing the @@ -251,7 +266,7 @@ xenXMConfigGetUUID(virConfPtr conf, const char *name, unsigned char *uuid) */ virDomainDefPtr xenParseXM(virConfPtr conf, int xendConfigVersion, - virCapsPtr caps) + virCapsPtr caps) { const char *str; int hvm = 0; @@ -360,17 +375,9 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, } } - if (xenXMConfigGetULongLong(conf, "memory", &def->mem.cur_balloon, - MIN_XEN_GUEST_SIZE * 2) < 0) - goto cleanup; - - if (xenXMConfigGetULongLong(conf, "maxmem", &def->mem.max_balloon, - def->mem.cur_balloon) < 0) + if (xenParseXMMem(conf, def) < 0) goto cleanup; - def->mem.cur_balloon *= 1024; - def->mem.max_balloon *= 1024; - if (xenXMConfigGetULong(conf, "vcpus", &count, 1) < 0 || MAX_VIRT_CPUS < count) goto cleanup; -- 1.8.4.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list