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.
This commit is contained in:
Peter Krempa 2015-02-11 14:26:19 +01:00
parent 2562141f19
commit 456268d46b
3 changed files with 42 additions and 25 deletions

View 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;
}

View 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;
}

View 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__ */