提交 e3c44f0d 编写于 作者: P Prerna Saxena 提交者: Michal Privoznik

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.

    <numa>
      <cell cpus='0-3' memory='1024' unit='MiB' />
      <cell cpus='4-7' memory='1024' unit='MiB' />
    </numa>

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: NPrerna Saxena <prerna@linux.vnet.ibm.com>
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 ae5ecd76
......@@ -1153,8 +1153,8 @@
&lt;cpu&gt;
...
&lt;numa&gt;
&lt;cell id='0' cpus='0-3' memory='512000'/&gt;
&lt;cell id='1' cpus='4-7' memory='512000' memAccess='shared'/&gt;
&lt;cell id='0' cpus='0-3' memory='512000' unit='KiB'/&gt;
&lt;cell id='1' cpus='4-7' memory='512000' unit='KiB' memAccess='shared'/&gt;
&lt;/numa&gt;
...
&lt;/cpu&gt;
......@@ -1165,6 +1165,9 @@
<code>cpus</code> specifies the CPU or range of CPUs that are
part of the node. <code>memory</code> specifies the node memory
in kibibytes (i.e. blocks of 1024 bytes).
<span class="since">Since 1.2.11</span> one can use an additional <a
href="#elementsMemoryAllocation"><code>unit</code></a> attribute to
define units in which <code>memory</code> is specified.
<span class="since">Since 1.2.7</span> all cells should
have <code>id</code> attribute in case referring to some cell is
necessary in the code, otherwise the cells are
......
......@@ -4143,6 +4143,11 @@
<attribute name="memory">
<ref name="memoryKB"/>
</attribute>
<optional>
<attribute name="unit">
<ref name="unit"/>
</attribute>
</optional>
<optional>
<attribute name="memAccess">
<choice>
......
......@@ -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));
......
......@@ -11,8 +11,8 @@
<cpu>
<topology sockets='2' cores='4' threads='2'/>
<numa>
<cell id='0' cpus='0-3,8-11' memory='109550'/>
<cell id='1' cpus='4-7,12-15' memory='109550'/>
<cell id='0' cpus='0-3,8-11' memory='109550' unit='KiB'/>
<cell id='1' cpus='4-7,12-15' memory='109550' unit='KiB'/>
</numa>
</cpu>
<clock offset='utc'/>
......
......@@ -11,8 +11,8 @@
<cpu>
<topology sockets='2' cores='4' threads='2'/>
<numa>
<cell id='0' cpus='0-7' memory='109550' memAccess='shared'/>
<cell id='1' cpus='8-15' memory='109550' memAccess='private'/>
<cell id='0' cpus='0-7' memory='109550' unit='KiB' memAccess='shared'/>
<cell id='1' cpus='8-15' memory='109550' unit='KiB' memAccess='private'/>
</numa>
</cpu>
<clock offset='utc'/>
......
......@@ -11,8 +11,8 @@
<cpu>
<topology sockets='2' cores='4' threads='2'/>
<numa>
<cell cpus='0-7' memory='109550'/>
<cell cpus='8-15' memory='109550'/>
<cell cpus='0-7' memory='109550' unit='KiB'/>
<cell cpus='8-15' memory='109550' unit='KiB'/>
</numa>
</cpu>
<clock offset='utc'/>
......
......@@ -11,8 +11,8 @@
<cpu>
<topology sockets='2' cores='4' threads='2'/>
<numa>
<cell id='1' cpus='8-15' memory='109550'/>
<cell id='0' cpus='0-7' memory='109550'/>
<cell id='1' cpus='8-15' memory='109550' unit='KiB'/>
<cell id='0' cpus='0-7' memory='109550' unit='KiB'/>
</numa>
</cpu>
<clock offset='utc'/>
......
......@@ -11,8 +11,8 @@
<cpu>
<topology sockets='2' cores='4' threads='2'/>
<numa>
<cell id='1' cpus='0-7' memory='109550'/>
<cell id='2' cpus='8-15' memory='109550'/>
<cell id='1' cpus='0-7' memory='109550' unit='KiB'/>
<cell id='2' cpus='8-15' memory='109550' unit='KiB'/>
</numa>
</cpu>
<clock offset='utc'/>
......
......@@ -20,10 +20,10 @@
</os>
<cpu>
<numa>
<cell id='0' cpus='0' memory='1048576'/>
<cell id='1' cpus='1' memory='1048576'/>
<cell id='2' cpus='2' memory='1048576'/>
<cell id='3' cpus='3' memory='1048576'/>
<cell id='0' cpus='0' memory='1048576' unit='KiB'/>
<cell id='1' cpus='1' memory='1048576' unit='KiB'/>
<cell id='2' cpus='2' memory='1048576' unit='KiB'/>
<cell id='3' cpus='3' memory='1048576' unit='KiB'/>
</numa>
</cpu>
<clock offset='utc'/>
......
......@@ -15,8 +15,8 @@
</os>
<cpu>
<numa>
<cell id='0' cpus='0' memory='262144'/>
<cell id='1' cpus='1' memory='786432'/>
<cell id='0' cpus='0' memory='262144' unit='KiB'/>
<cell id='1' cpus='1' memory='786432' unit='KiB'/>
</numa>
</cpu>
<clock offset='utc'/>
......
......@@ -15,8 +15,8 @@
</os>
<cpu>
<numa>
<cell id='0' cpus='0' memory='262144'/>
<cell id='1' cpus='1' memory='786432'/>
<cell id='0' cpus='0' memory='262144' unit='KiB'/>
<cell id='1' cpus='1' memory='786432' unit='KiB'/>
</numa>
</cpu>
<clock offset='utc'/>
......
......@@ -20,10 +20,10 @@
</os>
<cpu>
<numa>
<cell id='0' cpus='0' memory='1048576'/>
<cell id='1' cpus='1' memory='1048576'/>
<cell id='2' cpus='2' memory='1048576'/>
<cell id='3' cpus='3' memory='1048576'/>
<cell id='0' cpus='0' memory='1048576' unit='KiB'/>
<cell id='1' cpus='1' memory='1048576' unit='KiB'/>
<cell id='2' cpus='2' memory='1048576' unit='KiB'/>
<cell id='3' cpus='3' memory='1048576' unit='KiB'/>
</numa>
</cpu>
<clock offset='utc'/>
......
......@@ -20,10 +20,10 @@
</os>
<cpu>
<numa>
<cell id='0' cpus='0' memory='1048576'/>
<cell id='1' cpus='1' memory='1048576' memAccess='shared'/>
<cell id='2' cpus='2' memory='1048576' memAccess='private'/>
<cell id='3' cpus='3' memory='1048576'/>
<cell id='0' cpus='0' memory='1048576' unit='KiB'/>
<cell id='1' cpus='1' memory='1048576' unit='KiB' memAccess='shared'/>
<cell id='2' cpus='2' memory='1048576' unit='KiB' memAccess='private'/>
<cell id='3' cpus='3' memory='1048576' unit='KiB'/>
</numa>
</cpu>
<clock offset='utc'/>
......
......@@ -13,7 +13,7 @@
</os>
<cpu>
<numa>
<cell id='0' cpus='0' memory='65536'/>
<cell id='0' cpus='0' memory='65536' unit='KiB'/>
</numa>
</cpu>
<clock offset='utc'/>
......
......@@ -13,8 +13,8 @@
</os>
<cpu>
<numa>
<cell id='0' cpus='0' memory='32768'/>
<cell id='1' cpus='1' memory='32768'/>
<cell id='0' cpus='0' memory='32768' unit='KiB'/>
<cell id='1' cpus='1' memory='32768' unit='KiB'/>
</numa>
</cpu>
<clock offset='utc'/>
......
......@@ -15,9 +15,9 @@
</os>
<cpu>
<numa>
<cell id='0' cpus='0' memory='20002'/>
<cell id='1' cpus='1-27,29' memory='660066'/>
<cell id='2' cpus='28-31,^29' memory='24002400'/>
<cell id='0' cpus='0' memory='20002' unit='KiB'/>
<cell id='1' cpus='1-27,29' memory='660066' unit='KiB'/>
<cell id='2' cpus='28-31,^29' memory='24002400' unit='KiB'/>
</numa>
</cpu>
<clock offset='utc'/>
......
......@@ -14,8 +14,8 @@
</os>
<cpu>
<numa>
<cell id='0' cpus='0' memory='32768'/>
<cell id='1' cpus='1' memory='32768'/>
<cell id='0' cpus='0' memory='32768' unit='KiB'/>
<cell id='1' cpus='1' memory='32768' unit='KiB'/>
</numa>
</cpu>
<clock offset='utc'/>
......
......@@ -11,8 +11,8 @@
<cpu>
<topology sockets='2' cores='4' threads='2'/>
<numa>
<cell id='0' cpus='0-7' memory='109550'/>
<cell id='1' cpus='8-15' memory='109550'/>
<cell id='0' cpus='0-7' memory='109550' unit='KiB'/>
<cell id='1' cpus='8-15' memory='109550' unit='KiB'/>
</numa>
</cpu>
<clock offset='utc'/>
......
......@@ -11,8 +11,8 @@
<cpu>
<topology sockets='2' cores='4' threads='2'/>
<numa>
<cell id='0' cpus='0-7' memory='109550'/>
<cell id='1' cpus='8-15' memory='109550'/>
<cell id='0' cpus='0-7' memory='109550' unit='KiB'/>
<cell id='1' cpus='8-15' memory='109550' unit='KiB'/>
</numa>
</cpu>
<clock offset='utc'/>
......
......@@ -13,7 +13,7 @@
</os>
<cpu>
<numa>
<cell id='0' cpus='0' memory='65536'/>
<cell id='0' cpus='0' memory='65536' unit='KiB'/>
</numa>
</cpu>
<clock offset='utc'/>
......
......@@ -15,9 +15,9 @@
</os>
<cpu>
<numa>
<cell id='0' cpus='0' memory='20002'/>
<cell id='1' cpus='1-27,29' memory='660066'/>
<cell id='2' cpus='28-31,^29' memory='24002400'/>
<cell id='0' cpus='0' memory='20002' unit='KiB'/>
<cell id='1' cpus='1-27,29' memory='660066' unit='KiB'/>
<cell id='2' cpus='28-31,^29' memory='24002400' unit='KiB'/>
</numa>
</cpu>
<clock offset='utc'/>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册