render / rpms / libvirt

Forked from rpms/libvirt 4 months ago
Clone
7a3408
From c2e77e9c6e246a254083ac0e30c9b0da209daac2 Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <c2e77e9c6e246a254083ac0e30c9b0da209daac2@dist-git>
7a3408
From: Martin Kletzander <mkletzan@redhat.com>
7a3408
Date: Thu, 13 Aug 2015 15:11:47 +0200
7a3408
Subject: [PATCH] qemu: Keep numad hint after daemon restart
7a3408
7a3408
https://bugzilla.redhat.com/show_bug.cgi?id=1162947
7a3408
7a3408
The numad hint stored in priv->autoNodeset is information that gets lost
7a3408
during daemon restart.  And because we would like to use that
7a3408
information in the future, we also need to save it in the status XML.
7a3408
For the sake of tests, we need to initialize nnumaCell_max to some
7a3408
value, so that the restoration doesn't fail in our test suite.  There is
7a3408
no need to fill in the actual numa cell data since the recalculating
7a3408
function virCapabilitiesGetCpusForNodemask() will not fail, it will just
7a3408
skip filling the data in the bitmap which we don't use in tests anyway.
7a3408
7a3408
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7a3408
(cherry picked from commit 8ce86722d78d8b2a1e7d9cb29571beb791c9f3d7)
7a3408
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/qemu/qemu_domain.c  | 32 +++++++++++++++++++++++++++++++-
7a3408
 tests/qemuxml2xmltest.c |  3 ++-
7a3408
 tests/testutilsqemu.c   |  2 ++
7a3408
 3 files changed, 35 insertions(+), 2 deletions(-)
7a3408
7a3408
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
7a3408
index ca41ca4..3b542f5 100644
7a3408
--- a/src/qemu/qemu_domain.c
7a3408
+++ b/src/qemu/qemu_domain.c
7a3408
@@ -618,21 +618,33 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf,
7a3408
         virBufferAddLit(buf, "</devices>\n");
7a3408
     }
7a3408
 
7a3408
+    if (priv->autoNodeset) {
7a3408
+        char *nodeset = virBitmapFormat(priv->autoNodeset);
7a3408
+
7a3408
+        if (!nodeset)
7a3408
+            return -1;
7a3408
+
7a3408
+        virBufferAsprintf(buf, "<numad nodeset='%s'/>\n", nodeset);
7a3408
+        VIR_FREE(nodeset);
7a3408
+    }
7a3408
+
7a3408
     return 0;
7a3408
 }
7a3408
 
7a3408
 static int
7a3408
 qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
7a3408
                              virDomainObjPtr vm,
7a3408
-                             virDomainDefParserConfigPtr config ATTRIBUTE_UNUSED)
7a3408
+                             virDomainDefParserConfigPtr config)
7a3408
 {
7a3408
     qemuDomainObjPrivatePtr priv = vm->privateData;
7a3408
+    virQEMUDriverPtr driver = config->priv;
7a3408
     char *monitorpath;
7a3408
     char *tmp = NULL;
7a3408
     int n;
7a3408
     size_t i;
7a3408
     xmlNodePtr *nodes = NULL;
7a3408
     virQEMUCapsPtr qemuCaps = NULL;
7a3408
+    virCapsPtr caps = NULL;
7a3408
 
7a3408
     if (VIR_ALLOC(priv->monConfig) < 0)
7a3408
         goto error;
7a3408
@@ -805,15 +817,33 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
7a3408
     }
7a3408
     VIR_FREE(nodes);
7a3408
 
7a3408
+    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
7a3408
+        goto error;
7a3408
+
7a3408
+    if ((tmp = virXPathString("string(./numad/@nodeset)", ctxt))) {
7a3408
+        if (virBitmapParse(tmp, 0, &priv->autoNodeset,
7a3408
+                           caps->host.nnumaCell_max) < 0)
7a3408
+            goto error;
7a3408
+
7a3408
+        if (!(priv->autoCpuset = virCapabilitiesGetCpusForNodemask(caps,
7a3408
+                                                                   priv->autoNodeset)))
7a3408
+            goto error;
7a3408
+    }
7a3408
+    virObjectUnref(caps);
7a3408
+    caps = NULL;
7a3408
+    VIR_FREE(tmp);
7a3408
+
7a3408
     return 0;
7a3408
 
7a3408
  error:
7a3408
     virDomainChrSourceDefFree(priv->monConfig);
7a3408
     priv->monConfig = NULL;
7a3408
     VIR_FREE(nodes);
7a3408
+    VIR_FREE(tmp);
7a3408
     virStringFreeList(priv->qemuDevices);
7a3408
     priv->qemuDevices = NULL;
7a3408
     virObjectUnref(qemuCaps);
7a3408
+    virObjectUnref(caps);
7a3408
     return -1;
7a3408
 }
7a3408
 
7a3408
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
7a3408
index 7a41a18..09806b2 100644
7a3408
--- a/tests/qemuxml2xmltest.c
7a3408
+++ b/tests/qemuxml2xmltest.c
7a3408
@@ -130,7 +130,8 @@ static const char testStatusXMLPrefix[] =
7a3408
 "    <device alias='serial0'/>\n"
7a3408
 "    <device alias='net0'/>\n"
7a3408
 "    <device alias='usb'/>\n"
7a3408
-"  </devices>\n";
7a3408
+"  </devices>\n"
7a3408
+"  <numad nodeset='0-2'/>\n";
7a3408
 
7a3408
 static const char testStatusXMLSuffix[] =
7a3408
 "</domstatus>\n";
7a3408
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
7a3408
index ceaabb6..a2f4299 100644
7a3408
--- a/tests/testutilsqemu.c
7a3408
+++ b/tests/testutilsqemu.c
7a3408
@@ -336,6 +336,8 @@ virCapsPtr testQemuCapsInit(void)
7a3408
 
7a3408
     caps->host.cpu = cpuDefault;
7a3408
 
7a3408
+    caps->host.nnumaCell_max = 4;
7a3408
+
7a3408
     if ((machines = testQemuAllocMachines(&nmachines)) == NULL)
7a3408
         goto cleanup;
7a3408
 
7a3408
-- 
7a3408
2.5.0
7a3408