]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
conf: Prepare making memory device target node optional
authorPeter Krempa <pkrempa@redhat.com>
Wed, 7 Oct 2015 11:52:45 +0000 (13:52 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 18 Nov 2015 09:32:18 +0000 (10:32 +0100)
Adjust the config code so that it does not enforce that target memory
node is specified. To avoid breakage, adjust the qemu memory hotplug
config checker to disallow such config for now.

docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
src/qemu/qemu_domain.c

index c88b032c2ba8697dc5fb61c19f75b207aaadbb76..e5e01672628181a7d2032d7d317783f7d4595026 100644 (file)
@@ -6300,8 +6300,9 @@ qemu-kvm -net nic,model=? /dev/null
           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>
index f1961773c81a8d056425b6fdd67859cb83059a2b..994faceec74066c6371d95b8c5ec77bcac938af5 100644 (file)
         <element name="size">
           <ref name="scaledInteger"/>
         </element>
-        <element name="node">
-          <ref name="unsignedInt"/>
-        </element>
+        <optional>
+          <element name="node">
+            <ref name="unsignedInt"/>
+          </element>
+        </optional>
       </interleave>
     </element>
   </define>
index eb0044449ab780c690fc4ede6c33a3d977f17364..0ac7dbf249bd7e5092d47083ef91ac3cc4f4103d 100644 (file)
@@ -12544,10 +12544,15 @@ virDomainMemoryTargetDefParseXML(xmlNodePtr node,
     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;
     }
 
@@ -17711,8 +17716,8 @@ virDomainMemoryDefCheckABIStability(virDomainMemoryDefPtr src,
 
     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;
     }
@@ -20802,7 +20807,8 @@ virDomainMemoryTargetDefFormat(virBufferPtr buf,
     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");
index f10b5348b7c244d4a9685b5b20116193a45f8529..8d43ee65d8b42f68fd82381aabaa2a1b66612c2d 100644 (file)
@@ -2022,7 +2022,7 @@ struct _virDomainMemoryDef {
 
     /* target */
     int model; /* virDomainMemoryModel */
-    unsigned int targetNode;
+    int targetNode;
     unsigned long long size; /* kibibytes */
 
     virDomainDeviceInfo info;
index 507d44695ff2444cf3f67982fc2625b4d70886ae..52488ab08d6c969572f6dfef080ff8d7609980ea 100644 (file)
@@ -3597,6 +3597,13 @@ qemuDomainDefValidateMemoryHotplugDevice(const virDomainMemoryDef *mem,
             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,