Move the code that formats the /domain/cpu/numa element to numa_conf as it belongs there. --- src/conf/cpu_conf.c | 29 ++++------------------------- src/conf/numa_conf.c | 37 +++++++++++++++++++++++++++++++++++++ src/conf/numa_conf.h | 1 + 3 files changed, 42 insertions(+), 25 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 11ad5f4..28fbead 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -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; } diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 965d67b..d8f1739 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -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; +} diff --git a/src/conf/numa_conf.h b/src/conf/numa_conf.h index 276d25a..9202355 100644 --- a/src/conf/numa_conf.h +++ b/src/conf/numa_conf.h @@ -114,5 +114,6 @@ bool virDomainNumatuneNodesetIsAvailable(virDomainNumatunePtr numatune, virBitmapPtr auto_nodeset); int virDomainNumaDefCPUParseXML(virCPUDefPtr def, xmlXPathContextPtr ctxt); +int virDomainNumaDefCPUFormat(virBufferPtr buf, virCPUDefPtr def); #endif /* __NUMA_CONF_H__ */ -- 2.2.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list