]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
src/xenxs: Refactor code formating memory config
authorKiarie Kahurani <davidkiarie4@gmail.com>
Mon, 11 Aug 2014 21:21:26 +0000 (00:21 +0300)
committerJim Fehlig <jfehlig@suse.com>
Thu, 14 Aug 2014 17:49:52 +0000 (11:49 -0600)
introduce function
   xenFormatXMMem(virConfPtr conf,...........);
which parses memory config instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
src/xenxs/xen_xm.c

index 9254046146859f62601e5796a354797ff05d0f0d..2c7c99c95b953bf5ca0774d1133efee587843831 100644 (file)
@@ -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)