added memory as a scaled integer.
</p>
<p>
- The mandatory <code>node</code> subelement configures the guest NUMA
- node to attach the memory to.
+ The <code>node</code> subelement configures the guest NUMA node to
+ attach the memory to. The element shall be used only if the guest has
+ NUMA nodes configured.
</p>
</dd>
</dl>
int ret = -1;
xmlNodePtr save = ctxt->node;
ctxt->node = node;
+ int rv;
- if (virXPathUInt("string(./node)", ctxt, &def->targetNode) < 0) {
+ /* initialize to value which marks that the user didn't specify it */
+ def->targetNode = -1;
+
+ if ((rv = virXPathInt("string(./node)", ctxt, &def->targetNode)) == -2 ||
+ (rv == 0 && def->targetNode < 0)) {
virReportError(VIR_ERR_XML_ERROR, "%s",
- _("invalid or missing value of memory device node"));
+ _("invalid value of memory device node"));
goto cleanup;
}
if (src->targetNode != dst->targetNode) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target memory device targetNode '%u' "
- "doesn't match source targetNode '%u'"),
+ _("Target memory device targetNode '%d' "
+ "doesn't match source targetNode '%d'"),
dst->targetNode, src->targetNode);
return false;
}
virBufferAdjustIndent(buf, 2);
virBufferAsprintf(buf, "<size unit='KiB'>%llu</size>\n", def->size);
- virBufferAsprintf(buf, "<node>%u</node>\n", def->targetNode);
+ if (def->targetNode >= 0)
+ virBufferAsprintf(buf, "<node>%d</node>\n", def->targetNode);
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</target>\n");
return -1;
}
+ if (mem->targetNode == -1) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("target NUMA node needs to be specified for "
+ "memory device"));
+ return -1;
+ }
+
if (mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM) {
if (mem->info.addr.dimm.slot >= def->mem.memory_slots) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,