introduce function
xenFormatXMMem(virConfPtr conf,...........);
which parses memory config instead
signed-off-by: Kiarie Kahurani <davidkiarie4(a)gmail.com>
Signed-off-by: Kiarie Kahurani <davidkiarie4(a)gmail.com>
---
src/xenxs/xen_xm.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 08d26e5..350aeeb 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1672,6 +1672,23 @@ xenFormatXMGeneralMeta(virConfPtr conf, virDomainDefPtr def)
return 0;
}
+
+
+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);
@@ -1695,12 +1712,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)
--
1.8.4.5