]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Keep numad hint after daemon restart
authorMartin Kletzander <mkletzan@redhat.com>
Fri, 24 Jul 2015 14:06:33 +0000 (16:06 +0200)
committerCole Robinson <crobinso@redhat.com>
Tue, 22 Sep 2015 00:18:00 +0000 (20:18 -0400)
The numad hint stored in priv->autoNodeset is information that gets lost
during daemon restart.  And because we would like to use that
information in the future, we also need to save it in the status XML.
For the sake of tests, we need to initialize nnumaCell_max to some
value, so that the restoration doesn't fail in our test suite.  There is
no need to fill in the actual numa cell data since the recalculating
function virCapabilitiesGetCpusForNodemask() will not fail, it will just
skip filling the data in the bitmap which we don't use in tests anyway.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 8ce86722d78d8b2a1e7d9cb29571beb791c9f3d7)

src/qemu/qemu_domain.c
tests/qemuxml2xmltest.c
tests/testutilsqemu.c

index 7377e8cfad6adf6cdc311269489f82d092e09e98..e7c90993f823f3fc5af92f366a014df2e566ebf7 100644 (file)
@@ -618,21 +618,33 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf,
         virBufferAddLit(buf, "</devices>\n");
     }
 
+    if (priv->autoNodeset) {
+        char *nodeset = virBitmapFormat(priv->autoNodeset);
+
+        if (!nodeset)
+            return -1;
+
+        virBufferAsprintf(buf, "<numad nodeset='%s'/>\n", nodeset);
+        VIR_FREE(nodeset);
+    }
+
     return 0;
 }
 
 static int
 qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
                              virDomainObjPtr vm,
-                             virDomainDefParserConfigPtr config ATTRIBUTE_UNUSED)
+                             virDomainDefParserConfigPtr config)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
+    virQEMUDriverPtr driver = config->priv;
     char *monitorpath;
     char *tmp = NULL;
     int n;
     size_t i;
     xmlNodePtr *nodes = NULL;
     virQEMUCapsPtr qemuCaps = NULL;
+    virCapsPtr caps = NULL;
 
     if (VIR_ALLOC(priv->monConfig) < 0)
         goto error;
@@ -805,15 +817,33 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
     }
     VIR_FREE(nodes);
 
+    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
+        goto error;
+
+    if ((tmp = virXPathString("string(./numad/@nodeset)", ctxt))) {
+        if (virBitmapParse(tmp, 0, &priv->autoNodeset,
+                           caps->host.nnumaCell_max) < 0)
+            goto error;
+
+        if (!(priv->autoCpuset = virCapabilitiesGetCpusForNodemask(caps,
+                                                                   priv->autoNodeset)))
+            goto error;
+    }
+    virObjectUnref(caps);
+    caps = NULL;
+    VIR_FREE(tmp);
+
     return 0;
 
  error:
     virDomainChrSourceDefFree(priv->monConfig);
     priv->monConfig = NULL;
     VIR_FREE(nodes);
+    VIR_FREE(tmp);
     virStringFreeList(priv->qemuDevices);
     priv->qemuDevices = NULL;
     virObjectUnref(qemuCaps);
+    virObjectUnref(caps);
     return -1;
 }
 
index 7a41a187044da11ea30616af067e3bebf3822ff8..09806b242f05fefa6995bc714e7c40cef9d2f734 100644 (file)
@@ -130,7 +130,8 @@ static const char testStatusXMLPrefix[] =
 "    <device alias='serial0'/>\n"
 "    <device alias='net0'/>\n"
 "    <device alias='usb'/>\n"
-"  </devices>\n";
+"  </devices>\n"
+"  <numad nodeset='0-2'/>\n";
 
 static const char testStatusXMLSuffix[] =
 "</domstatus>\n";
index ceaabb6a240a4254307373efdb8e07498aae8cbd..a2f429909a7527aae4f000a533fc847305cd6142 100644 (file)
@@ -336,6 +336,8 @@ virCapsPtr testQemuCapsInit(void)
 
     caps->host.cpu = cpuDefault;
 
+    caps->host.nnumaCell_max = 4;
+
     if ((machines = testQemuAllocMachines(&nmachines)) == NULL)
         goto cleanup;