提交 2562141f 编写于 作者: P Peter Krempa

conf: numa: Don't duplicate NUMA cell cpumask

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.
上级 34a1dd73
...@@ -86,10 +86,8 @@ virCPUDefFree(virCPUDefPtr def) ...@@ -86,10 +86,8 @@ virCPUDefFree(virCPUDefPtr def)
virCPUDefFreeModel(def); virCPUDefFreeModel(def);
for (i = 0; i < def->ncells; i++) { for (i = 0; i < def->ncells; i++)
virBitmapFree(def->cells[i].cpumask); virBitmapFree(def->cells[i].cpumask);
VIR_FREE(def->cells[i].cpustr);
}
VIR_FREE(def->cells); VIR_FREE(def->cells);
VIR_FREE(def->vendor_id); VIR_FREE(def->vendor_id);
...@@ -162,9 +160,6 @@ virCPUDefCopy(const virCPUDef *cpu) ...@@ -162,9 +160,6 @@ virCPUDefCopy(const virCPUDef *cpu)
if (!copy->cells[i].cpumask) if (!copy->cells[i].cpumask)
goto error; goto error;
if (VIR_STRDUP(copy->cells[i].cpustr, cpu->cells[i].cpustr) < 0)
goto error;
} }
copy->cells_cpus = cpu->cells_cpus; copy->cells_cpus = cpu->cells_cpus;
} }
...@@ -601,16 +596,21 @@ virCPUDefFormatBuf(virBufferPtr buf, ...@@ -601,16 +596,21 @@ virCPUDefFormatBuf(virBufferPtr buf,
virBufferAdjustIndent(buf, 2); virBufferAdjustIndent(buf, 2);
for (i = 0; i < def->ncells; i++) { for (i = 0; i < def->ncells; i++) {
virMemAccess memAccess = def->cells[i].memAccess; virMemAccess memAccess = def->cells[i].memAccess;
char *cpustr = NULL;
if (!(cpustr = virBitmapFormat(def->cells[i].cpumask)))
return -1;
virBufferAddLit(buf, "<cell"); virBufferAddLit(buf, "<cell");
virBufferAsprintf(buf, " id='%zu'", i); 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); virBufferAsprintf(buf, " memory='%llu'", def->cells[i].mem);
virBufferAddLit(buf, " unit='KiB'"); virBufferAddLit(buf, " unit='KiB'");
if (memAccess) if (memAccess)
virBufferAsprintf(buf, " memAccess='%s'", virBufferAsprintf(buf, " memAccess='%s'",
virMemAccessTypeToString(memAccess)); virMemAccessTypeToString(memAccess));
virBufferAddLit(buf, "/>\n"); virBufferAddLit(buf, "/>\n");
VIR_FREE(cpustr);
} }
virBufferAdjustIndent(buf, -2); virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</numa>\n"); virBufferAddLit(buf, "</numa>\n");
......
...@@ -104,7 +104,6 @@ typedef struct _virCellDef virCellDef; ...@@ -104,7 +104,6 @@ typedef struct _virCellDef virCellDef;
typedef virCellDef *virCellDefPtr; typedef virCellDef *virCellDefPtr;
struct _virCellDef { struct _virCellDef {
virBitmapPtr cpumask; /* CPUs that are part of this node */ 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 */ unsigned long long mem; /* Node memory in kB */
virMemAccess memAccess; virMemAccess memAccess;
}; };
......
...@@ -749,9 +749,7 @@ virDomainNumaDefCPUParseXML(virCPUDefPtr def, ...@@ -749,9 +749,7 @@ virDomainNumaDefCPUParseXML(virCPUDefPtr def,
if (ncpus <= 0) if (ncpus <= 0)
goto cleanup; goto cleanup;
def->cells_cpus += ncpus; def->cells_cpus += ncpus;
VIR_FREE(tmp);
def->cells[cur_cell].cpustr = tmp;
tmp = NULL;
ctxt->node = nodes[i]; ctxt->node = nodes[i];
if (virDomainParseMemory("./@memory", "./@unit", ctxt, if (virDomainParseMemory("./@memory", "./@unit", ctxt,
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<numa> <numa>
<cell id='0' cpus='0' memory='20002' unit='KiB'/> <cell id='0' cpus='0' memory='20002' unit='KiB'/>
<cell id='1' cpus='1-27,29' memory='660066' 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> </numa>
</cpu> </cpu>
<clock offset='utc'/> <clock offset='utc'/>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<numa> <numa>
<cell id='0' cpus='0' memory='20002' unit='KiB'/> <cell id='0' cpus='0' memory='20002' unit='KiB'/>
<cell id='1' cpus='1-27,29' memory='660066' 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> </numa>
</cpu> </cpu>
<clock offset='utc'/> <clock offset='utc'/>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册