]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Move NUMA cell formatter to numa_conf
authorPeter Krempa <pkrempa@redhat.com>
Wed, 11 Feb 2015 13:26:19 +0000 (14:26 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 20 Feb 2015 16:43:04 +0000 (17:43 +0100)
Move the code that formats the /domain/cpu/numa element to numa_conf as
it belongs there.

src/conf/cpu_conf.c
src/conf/numa_conf.c
src/conf/numa_conf.h

index 11ad5f41dcbf59dc68a1dad538fb7b051f86ebcd..28fbeade6aec14cf377ef3d444c068c676a9a855 100644 (file)
@@ -495,8 +495,11 @@ virCPUDefFormatBufFull(virBufferPtr buf,
                           virArchToString(def->arch));
     if (virCPUDefFormatBuf(buf, def, updateCPU) < 0)
         return -1;
-    virBufferAdjustIndent(buf, -2);
 
+    if (virDomainNumaDefCPUFormat(buf, def) < 0)
+        return -1;
+
+    virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</cpu>\n");
 
     return 0;
@@ -591,30 +594,6 @@ virCPUDefFormatBuf(virBufferPtr buf,
         }
     }
 
-    if (def->ncells) {
-        virBufferAddLit(buf, "<numa>\n");
-        virBufferAdjustIndent(buf, 2);
-        for (i = 0; i < def->ncells; i++) {
-            virMemAccess memAccess = def->cells[i].memAccess;
-            char *cpustr = NULL;
-
-            if (!(cpustr = virBitmapFormat(def->cells[i].cpumask)))
-                return -1;
-
-            virBufferAddLit(buf, "<cell");
-            virBufferAsprintf(buf, " id='%zu'", i);
-            virBufferAsprintf(buf, " cpus='%s'", cpustr);
-            virBufferAsprintf(buf, " memory='%llu'", def->cells[i].mem);
-            virBufferAddLit(buf, " unit='KiB'");
-            if (memAccess)
-                virBufferAsprintf(buf, " memAccess='%s'",
-                                  virMemAccessTypeToString(memAccess));
-            virBufferAddLit(buf, "/>\n");
-            VIR_FREE(cpustr);
-        }
-        virBufferAdjustIndent(buf, -2);
-        virBufferAddLit(buf, "</numa>\n");
-    }
     return 0;
 }
 
index 928496995044aba284f740770c48d817b4f3da1f..8b1b00a87e8e7d26dc30ab42cfb68ad6e3eca8ba 100644 (file)
@@ -777,3 +777,40 @@ virDomainNumaDefCPUParseXML(virCPUDefPtr def,
     VIR_FREE(tmp);
     return ret;
 }
+
+
+int
+virDomainNumaDefCPUFormat(virBufferPtr buf,
+                          virCPUDefPtr def)
+{
+    virMemAccess memAccess;
+    char *cpustr;
+    size_t i;
+
+    if (def->ncells == 0)
+        return 0;
+
+    virBufferAddLit(buf, "<numa>\n");
+    virBufferAdjustIndent(buf, 2);
+    for (i = 0; i < def->ncells; i++) {
+        memAccess = def->cells[i].memAccess;
+
+        if (!(cpustr = virBitmapFormat(def->cells[i].cpumask)))
+            return -1;
+
+        virBufferAddLit(buf, "<cell");
+        virBufferAsprintf(buf, " id='%zu'", i);
+        virBufferAsprintf(buf, " cpus='%s'", cpustr);
+        virBufferAsprintf(buf, " memory='%llu'", def->cells[i].mem);
+        virBufferAddLit(buf, " unit='KiB'");
+        if (memAccess)
+            virBufferAsprintf(buf, " memAccess='%s'",
+                              virMemAccessTypeToString(memAccess));
+        virBufferAddLit(buf, "/>\n");
+        VIR_FREE(cpustr);
+    }
+    virBufferAdjustIndent(buf, -2);
+    virBufferAddLit(buf, "</numa>\n");
+
+    return 0;
+}
index 78b24a1bc15e3e58afbbf8472f15050f0f0c4329..0482ade964f48952fd9a73fb45c091da39ab7aa9 100644 (file)
@@ -117,5 +117,6 @@ bool virDomainNumatuneNodeSpecified(virDomainNumatunePtr numatune,
                                     int cellid);
 
 int virDomainNumaDefCPUParseXML(virCPUDefPtr def, xmlXPathContextPtr ctxt);
+int virDomainNumaDefCPUFormat(virBufferPtr buf, virCPUDefPtr def);
 
 #endif /* __NUMA_CONF_H__ */