Add the helpers and refactor places where the value is accessed without them. --- src/conf/numa_conf.c | 20 +++++++++++++++++++- src/conf/numa_conf.h | 7 +++++++ src/libvirt_private.syms | 2 ++ src/qemu/qemu_command.c | 10 ++++++---- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 4906687..ee7e65d 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -777,7 +777,8 @@ virDomainNumaDefCPUFormat(virBufferPtr buf, virBufferAddLit(buf, "<cell"); virBufferAsprintf(buf, " id='%zu'", i); virBufferAsprintf(buf, " cpus='%s'", cpustr); - virBufferAsprintf(buf, " memory='%llu'", def->cells[i].mem); + virBufferAsprintf(buf, " memory='%llu'", + virDomainNumaGetNodeMemorySize(def, i)); virBufferAddLit(buf, " unit='KiB'"); if (memAccess) virBufferAsprintf(buf, " memAccess='%s'", @@ -840,3 +841,20 @@ virDomainNumaGetNodeMemoryAccessMode(virCPUDefPtr numa, { return numa->cells[node].memAccess; } + + +unsigned long long +virDomainNumaGetNodeMemorySize(virCPUDefPtr numa, + size_t node) +{ + return numa->cells[node].mem; +} + + +void +virDomainNumaSetNodeMemorySize(virCPUDefPtr numa, + size_t node, + unsigned long long size) +{ + numa->cells[node].mem = size; +} diff --git a/src/conf/numa_conf.h b/src/conf/numa_conf.h index 0ea2c93..eadab43 100644 --- a/src/conf/numa_conf.h +++ b/src/conf/numa_conf.h @@ -91,6 +91,9 @@ virBitmapPtr virDomainNumaGetNodeCpumask(virCPUDefPtr numa, size_t node); virNumaMemAccess virDomainNumaGetNodeMemoryAccessMode(virCPUDefPtr numa, size_t node); +unsigned long long virDomainNumaGetNodeMemorySize(virCPUDefPtr numa, + size_t node); + /* * Formatters @@ -114,6 +117,10 @@ int virDomainNumatuneSet(virDomainNumaPtr numa, virBitmapPtr nodeset) ATTRIBUTE_NONNULL(1); +void virDomainNumaSetNodeMemorySize(virCPUDefPtr numa, + size_t node, + unsigned long long size); + /* * Other accessors */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 1f1ce14..8988b61 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -632,7 +632,9 @@ virDomainNumaFree; virDomainNumaGetNodeCount; virDomainNumaGetNodeCpumask; virDomainNumaGetNodeMemoryAccessMode; +virDomainNumaGetNodeMemorySize; virDomainNumaNew; +virDomainNumaSetNodeMemorySize; virDomainNumatuneFormatNodeset; virDomainNumatuneFormatXML; virDomainNumatuneGetMode; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 05545ee..a69d004 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4745,7 +4745,8 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def, if (virAsprintf(&alias, "ram-node%zu", cell) < 0) goto cleanup; - if ((rc = qemuBuildMemoryBackendStr(def->cpu->cells[cell].mem, 0, cell, + if ((rc = qemuBuildMemoryBackendStr(virDomainNumaGetNodeMemorySize(def->cpu, cell), + 0, cell, NULL, auto_nodeset, def, qemuCaps, cfg, &backendType, &props, false)) < 0) @@ -7173,8 +7174,8 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg, /* using of -numa memdev= cannot be combined with -numa mem=, thus we * need to check which approach to use */ for (i = 0; i < ncells; i++) { - unsigned long long cellmem = VIR_DIV_UP(def->cpu->cells[i].mem, 1024); - def->cpu->cells[i].mem = cellmem * 1024; + unsigned long long cellmem = virDomainNumaGetNodeMemorySize(def->cpu, i); + virDomainNumaSetNodeMemorySize(def->cpu, i, VIR_ROUND_UP(cellmem, 1024)); if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM) || virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) { @@ -7224,7 +7225,8 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg, if (needBackend) virBufferAsprintf(&buf, ",memdev=ram-node%zu", i); else - virBufferAsprintf(&buf, ",mem=%llu", def->cpu->cells[i].mem / 1024); + virBufferAsprintf(&buf, ",mem=%llu", + virDomainNumaGetNodeMemorySize(def->cpu, i) / 1024); virCommandAddArgBuffer(cmd, &buf); } -- 2.2.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list