From: Kiarie Kahurani Date: Mon, 11 Aug 2014 21:21:26 +0000 (+0300) Subject: src/xenxs: Refactor code formating memory config X-Git-Tag: v1.2.8-rc1~182 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8faab08c14b29d9c049857af3a4e80531ee632f1;p=thirdparty%2Flibvirt.git src/xenxs: Refactor code formating memory config introduce function xenFormatXMMem(virConfPtr conf,...........); which parses memory config instead Signed-off-by: Kiarie Kahurani --- diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 9254046146..2c7c99c95b 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1676,6 +1676,21 @@ xenFormatXMGeneralMeta(virConfPtr conf, virDomainDefPtr def) } +static int +xenFormatXMMem(virConfPtr conf, virDomainDefPtr def) +{ + if (xenXMConfigSetInt(conf, "maxmem", + VIR_DIV_UP(def->mem.max_balloon, 1024)) < 0) + return -1; + + if (xenXMConfigSetInt(conf, "memory", + VIR_DIV_UP(def->mem.cur_balloon, 1024)) < 0) + return -1; + + return 0; +} + + /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is either 32, or 64 on a platform where long is big enough. */ verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT); @@ -1699,12 +1714,7 @@ xenFormatXM(virConnectPtr conn, if (xenFormatXMGeneralMeta(conf, def) < 0) goto cleanup; - if (xenXMConfigSetInt(conf, "maxmem", - VIR_DIV_UP(def->mem.max_balloon, 1024)) < 0) - goto cleanup; - - if (xenXMConfigSetInt(conf, "memory", - VIR_DIV_UP(def->mem.cur_balloon, 1024)) < 0) + if (xenFormatXMMem(conf, def) < 0) goto cleanup; if (xenXMConfigSetInt(conf, "vcpus", def->maxvcpus) < 0)