提交 456268d4 编写于 作者: P Peter Krempa

conf: Move NUMA cell formatter to numa_conf

Move the code that formats the /domain/cpu/numa element to numa_conf as
it belongs there.
上级 2562141f
......@@ -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;
}
......
......@@ -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;
}
......@@ -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__ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册