From e3c44f0d36ad8e2c1b14a2d57eaa19028a7c69af Mon Sep 17 00:00:00 2001 From: Prerna Saxena Date: Mon, 10 Nov 2014 17:22:58 +0530 Subject: [PATCH] cpu_conf: Allow specification of 'units' for @memory on numa nodes. CPU numa topology implicitly allows memory specification in 'KiB'. Enabling this to accept the 'unit' in which memory needs to be specified. This now allows users to specify memory in units of choice, and lists the same in 'KiB' -- just like other 'memory' elements in XML. Also augment test cases to correctly model NUMA memory specification. This adds the tag 'unit="KiB"' for memory attribute in NUMA cells. Signed-off-by: Prerna Saxena Signed-off-by: Michal Privoznik --- docs/formatdomain.html.in | 7 ++++-- docs/schemas/domaincommon.rng | 5 ++++ src/conf/cpu_conf.c | 24 +++++++------------ .../qemuxml2argv-cpu-numa-disjoint.xml | 4 ++-- .../qemuxml2argv-cpu-numa-memshared.xml | 4 ++-- .../qemuxml2argv-cpu-numa1.xml | 4 ++-- .../qemuxml2argv-cpu-numa2.xml | 4 ++-- .../qemuxml2argv-cpu-numa3.xml | 4 ++-- .../qemuxml2argv-hugepages-pages.xml | 8 +++---- .../qemuxml2argv-hugepages-pages2.xml | 4 ++-- .../qemuxml2argv-hugepages-pages3.xml | 4 ++-- .../qemuxml2argv-hugepages-pages4.xml | 8 +++---- .../qemuxml2argv-hugepages-shared.xml | 8 +++---- .../qemuxml2argv-numatune-auto-prefer.xml | 2 +- ...emuxml2argv-numatune-memnode-no-memory.xml | 4 ++-- .../qemuxml2argv-numatune-memnode.xml | 6 ++--- ...xml2argv-numatune-memnodes-problematic.xml | 4 ++-- .../qemuxml2xmlout-cpu-numa1.xml | 4 ++-- .../qemuxml2xmlout-cpu-numa2.xml | 4 ++-- .../qemuxml2xmlout-numatune-auto-prefer.xml | 2 +- .../qemuxml2xmlout-numatune-memnode.xml | 6 ++--- 21 files changed, 60 insertions(+), 60 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 7196e75cbd..b601278a77 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1153,8 +1153,8 @@ <cpu> ... <numa> - <cell id='0' cpus='0-3' memory='512000'/> - <cell id='1' cpus='4-7' memory='512000' memAccess='shared'/> + <cell id='0' cpus='0-3' memory='512000' unit='KiB'/> + <cell id='1' cpus='4-7' memory='512000' unit='KiB' memAccess='shared'/> </numa> ... </cpu> @@ -1165,6 +1165,9 @@ cpus specifies the CPU or range of CPUs that are part of the node. memory specifies the node memory in kibibytes (i.e. blocks of 1024 bytes). + Since 1.2.11 one can use an additional unit attribute to + define units in which memory is specified. Since 1.2.7 all cells should have id attribute in case referring to some cell is necessary in the code, otherwise the cells are diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 20d81ae2d6..44cabadaae 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4143,6 +4143,11 @@ + + + + + diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 1c74c666a1..2650208901 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -184,6 +184,7 @@ virCPUDefParseXML(xmlNodePtr node, { virCPUDefPtr def; xmlNodePtr *nodes = NULL; + xmlNodePtr oldnode = ctxt->node; int n; size_t i; char *cpuMode; @@ -440,7 +441,7 @@ virCPUDefParseXML(xmlNodePtr node, def->ncells = n; for (i = 0; i < n; i++) { - char *cpus, *memory, *memAccessStr; + char *cpus, *memAccessStr; int ret, ncpus = 0; unsigned int cur_cell; char *tmp = NULL; @@ -489,21 +490,10 @@ virCPUDefParseXML(xmlNodePtr node, goto error; def->cells_cpus += ncpus; - memory = virXMLPropString(nodes[i], "memory"); - if (!memory) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing 'memory' attribute in NUMA cell")); - goto error; - } - - ret = virStrToLong_ull(memory, NULL, 10, &def->cells[cur_cell].mem); - if (ret == -1) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Invalid 'memory' attribute in NUMA cell")); - VIR_FREE(memory); - goto error; - } - VIR_FREE(memory); + ctxt->node = nodes[i]; + if (virDomainParseMemory("./@memory", "./@unit", ctxt, + &def->cells[cur_cell].mem, true, false) < 0) + goto cleanup; memAccessStr = virXMLPropString(nodes[i], "memAccess"); if (memAccessStr) { @@ -526,6 +516,7 @@ virCPUDefParseXML(xmlNodePtr node, } cleanup: + ctxt->node = oldnode; VIR_FREE(fallback); VIR_FREE(vendor_id); VIR_FREE(nodes); @@ -704,6 +695,7 @@ virCPUDefFormatBuf(virBufferPtr buf, virBufferAsprintf(buf, " id='%zu'", i); virBufferAsprintf(buf, " cpus='%s'", def->cells[i].cpustr); virBufferAsprintf(buf, " memory='%llu'", def->cells[i].mem); + virBufferAddLit(buf, " unit='KiB'"); if (memAccess) virBufferAsprintf(buf, " memAccess='%s'", virMemAccessTypeToString(memAccess)); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-disjoint.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-disjoint.xml index 474a238810..bdffcd1ec2 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-disjoint.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-disjoint.xml @@ -11,8 +11,8 @@ - - + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.xml index cf7c040ccc..c638ffa004 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.xml @@ -11,8 +11,8 @@ - - + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa1.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa1.xml index 0543f7f791..20120e956c 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa1.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa1.xml @@ -11,8 +11,8 @@ - - + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa2.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa2.xml index 0a5f9fcd13..a90e7a209e 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa2.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa2.xml @@ -11,8 +11,8 @@ - - + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa3.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa3.xml index fa3070df2c..ea2dc8166f 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa3.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa3.xml @@ -11,8 +11,8 @@ - - + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages.xml b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages.xml index 5ad0695734..b67df2f70d 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages.xml @@ -20,10 +20,10 @@ - - - - + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages2.xml b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages2.xml index 3df870b6a9..6afa6ef5df 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages2.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages2.xml @@ -15,8 +15,8 @@ - - + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages3.xml b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages3.xml index 35aa2cf941..21f4985559 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages3.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages3.xml @@ -15,8 +15,8 @@ - - + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages4.xml b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages4.xml index a3ed29bca4..eb18f24b2b 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages4.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages4.xml @@ -20,10 +20,10 @@ - - - - + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-shared.xml b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-shared.xml index e7db69c5a5..52ca2f9e73 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-shared.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-shared.xml @@ -20,10 +20,10 @@ - - - - + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-numatune-auto-prefer.xml b/tests/qemuxml2argvdata/qemuxml2argv-numatune-auto-prefer.xml index 63f0d1fa36..8f809624ee 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-numatune-auto-prefer.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-numatune-auto-prefer.xml @@ -13,7 +13,7 @@ - + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-numatune-memnode-no-memory.xml b/tests/qemuxml2argvdata/qemuxml2argv-numatune-memnode-no-memory.xml index 4b2efa2105..886a07a5f5 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-numatune-memnode-no-memory.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-numatune-memnode-no-memory.xml @@ -13,8 +13,8 @@ - - + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-numatune-memnode.xml b/tests/qemuxml2argvdata/qemuxml2argv-numatune-memnode.xml index 440413bfc4..8912017a03 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-numatune-memnode.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-numatune-memnode.xml @@ -15,9 +15,9 @@ - - - + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-numatune-memnodes-problematic.xml b/tests/qemuxml2argvdata/qemuxml2argv-numatune-memnodes-problematic.xml index bb4e4af043..e1d115c718 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-numatune-memnodes-problematic.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-numatune-memnodes-problematic.xml @@ -14,8 +14,8 @@ - - + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-numa1.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-numa1.xml index 227bf1cd01..58f40b9902 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-numa1.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-numa1.xml @@ -11,8 +11,8 @@ - - + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-numa2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-numa2.xml index 227bf1cd01..58f40b9902 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-numa2.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-numa2.xml @@ -11,8 +11,8 @@ - - + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-numatune-auto-prefer.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-numatune-auto-prefer.xml index 19761b42d4..1000e9fa17 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-numatune-auto-prefer.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-numatune-auto-prefer.xml @@ -13,7 +13,7 @@ - + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-numatune-memnode.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-numatune-memnode.xml index 82b5f61870..ffc57cf57d 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-numatune-memnode.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-numatune-memnode.xml @@ -15,9 +15,9 @@ - - - + + +