From 8faab08c14b29d9c049857af3a4e80531ee632f1 Mon Sep 17 00:00:00 2001 From: Kiarie Kahurani Date: Tue, 12 Aug 2014 00:21:26 +0300 Subject: [PATCH] src/xenxs: Refactor code formating memory config introduce function xenFormatXMMem(virConfPtr conf,...........); which parses memory config instead Signed-off-by: Kiarie Kahurani --- src/xenxs/xen_xm.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) 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) -- GitLab