conf: numa: Add setter/getter for NUMA node memory size

Add the helpers and refactor places where the value is accessed without
them.
This commit is contained in:
Peter Krempa 2015-02-16 19:14:23 +01:00
parent 7800d473f5
commit b9ddb25822
4 changed files with 35 additions and 5 deletions

View File

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

View File

@ -94,6 +94,9 @@ virBitmapPtr virDomainNumaGetNodeCpumask(virCPUDefPtr numa,
virNumaMemAccess virDomainNumaGetNodeMemoryAccessMode(virCPUDefPtr numa,
size_t node)
ATTRIBUTE_NONNULL(1);
unsigned long long virDomainNumaGetNodeMemorySize(virCPUDefPtr numa,
size_t node)
ATTRIBUTE_NONNULL(1);
/*
* Formatters
@ -117,6 +120,11 @@ int virDomainNumatuneSet(virDomainNumaPtr numa,
virBitmapPtr nodeset)
ATTRIBUTE_NONNULL(1);
void virDomainNumaSetNodeMemorySize(virCPUDefPtr numa,
size_t node,
unsigned long long size)
ATTRIBUTE_NONNULL(1);
/*
* Other accessors
*/

View File

@ -632,7 +632,9 @@ virDomainNumaFree;
virDomainNumaGetNodeCount;
virDomainNumaGetNodeCpumask;
virDomainNumaGetNodeMemoryAccessMode;
virDomainNumaGetNodeMemorySize;
virDomainNumaNew;
virDomainNumaSetNodeMemorySize;
virDomainNumatuneFormatNodeset;
virDomainNumatuneFormatXML;
virDomainNumatuneGetMode;

View File

@ -4747,7 +4747,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)
@ -7176,8 +7177,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)) {
@ -7227,7 +7228,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);
}