]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
conf: numa: Don't duplicate NUMA cell cpumask
authorPeter Krempa <pkrempa@redhat.com>
Wed, 11 Feb 2015 13:06:20 +0000 (14:06 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 20 Feb 2015 16:43:03 +0000 (17:43 +0100)
The mask was stored both as a bitmap and as a string. The string is used
for XML output only. Remove the string, as it can be reconstructed from
the bitmap.

The test change is necessary as the bitmap formatter doesn't "optimize"
using the '^' operator.

src/conf/cpu_conf.c
src/conf/cpu_conf.h
src/conf/numa_conf.c
tests/qemuxml2argvdata/qemuxml2argv-numatune-memnode.xml
tests/qemuxml2xmloutdata/qemuxml2xmlout-numatune-memnode.xml

index 98b309b0f94682e969cf13150326a074b4fcc01e..11ad5f41dcbf59dc68a1dad538fb7b051f86ebcd 100644 (file)
@@ -86,10 +86,8 @@ virCPUDefFree(virCPUDefPtr def)
 
     virCPUDefFreeModel(def);
 
-    for (i = 0; i < def->ncells; i++) {
+    for (i = 0; i < def->ncells; i++)
         virBitmapFree(def->cells[i].cpumask);
-        VIR_FREE(def->cells[i].cpustr);
-    }
     VIR_FREE(def->cells);
     VIR_FREE(def->vendor_id);
 
@@ -162,9 +160,6 @@ virCPUDefCopy(const virCPUDef *cpu)
 
             if (!copy->cells[i].cpumask)
                 goto error;
-
-            if (VIR_STRDUP(copy->cells[i].cpustr, cpu->cells[i].cpustr) < 0)
-                goto error;
         }
         copy->cells_cpus = cpu->cells_cpus;
     }
@@ -601,16 +596,21 @@ virCPUDefFormatBuf(virBufferPtr buf,
         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'", def->cells[i].cpustr);
+            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");
index e2016562058ec09893c78ab2b9a18c4fadccb0e9..d6efba71f7b82dd4cc9ec94bf95cf31d5ee1ead3 100644 (file)
@@ -104,7 +104,6 @@ typedef struct _virCellDef virCellDef;
 typedef virCellDef *virCellDefPtr;
 struct _virCellDef {
     virBitmapPtr cpumask; /* CPUs that are part of this node */
-    char *cpustr;         /* CPUs stored in string form for dumpxml */
     unsigned long long mem;     /* Node memory in kB */
     virMemAccess memAccess;
 };
index 8879c167111cfbbf500cc94e3e98f8702db42f76..928496995044aba284f740770c48d817b4f3da1f 100644 (file)
@@ -749,9 +749,7 @@ virDomainNumaDefCPUParseXML(virCPUDefPtr def,
         if (ncpus <= 0)
             goto cleanup;
         def->cells_cpus += ncpus;
-
-        def->cells[cur_cell].cpustr = tmp;
-        tmp = NULL;
+        VIR_FREE(tmp);
 
         ctxt->node = nodes[i];
         if (virDomainParseMemory("./@memory", "./@unit", ctxt,
index 8912017a033e2aa72b778dce2bef3c4034e84994..73dfdf587febc6174f4a399271628c02841525fe 100644 (file)
@@ -17,7 +17,7 @@
     <numa>
       <cell id='0' cpus='0' memory='20002' unit='KiB'/>
       <cell id='1' cpus='1-27,29' memory='660066' unit='KiB'/>
-      <cell id='2' cpus='28-31,^29' memory='24002400' unit='KiB'/>
+      <cell id='2' cpus='28,30-31' memory='24002400' unit='KiB'/>
     </numa>
   </cpu>
   <clock offset='utc'/>
index ffc57cf57d88746d97e024075313b8b90f8214ca..75421252a5d217408febdd33876904e326aa4d44 100644 (file)
@@ -17,7 +17,7 @@
     <numa>
       <cell id='0' cpus='0' memory='20002' unit='KiB'/>
       <cell id='1' cpus='1-27,29' memory='660066' unit='KiB'/>
-      <cell id='2' cpus='28-31,^29' memory='24002400' unit='KiB'/>
+      <cell id='2' cpus='28,30-31' memory='24002400' unit='KiB'/>
     </numa>
   </cpu>
   <clock offset='utc'/>