[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 3/5] qemu: domain: Store and restore autoCpuset to status XML



Decouple them by storing them in the XML separately rather than
regenerating them. This will simplify upcoming fixes.
---
 src/qemu/qemu_domain.c  | 32 +++++++++++++++++++++++++-------
 tests/qemuxml2xmltest.c |  2 +-
 2 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 92e5609ad..8c29db15f 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1765,20 +1765,30 @@ qemuDomainObjPtrivateXMLFormatAutomaticPlacement(virBufferPtr buf,
                                                  qemuDomainObjPrivatePtr priv)
 {
     char *nodeset = NULL;
+    char *cpuset = NULL;
     int ret = -1;

-    if (!priv->autoNodeset)
+    if (!priv->autoNodeset && !priv->autoCpuset)
         return 0;

-    if (!(nodeset = virBitmapFormat(priv->autoNodeset)))
+    if (priv->autoNodeset &&
+        !((nodeset = virBitmapFormat(priv->autoNodeset))))
         goto cleanup;

-    virBufferAsprintf(buf, "<numad nodeset='%s'/>\n", nodeset);
+    if (priv->autoCpuset &&
+        !((cpuset = virBitmapFormat(priv->autoCpuset))))
+        goto cleanup;
+
+    virBufferAddLit(buf, "<numad");
+    virBufferEscapeString(buf, " nodeset='%s'", nodeset);
+    virBufferEscapeString(buf, " cpuset='%s'", cpuset);
+    virBufferAddLit(buf, "/>\n");

     ret = 0;

  cleanup:
     VIR_FREE(nodeset);
+    VIR_FREE(cpuset);
     return ret;
 }

@@ -1958,11 +1968,13 @@ qemuDomainObjPrivateXMLParseAutomaticPlacement(virQEMUDriverPtr driver,
 {
     virCapsPtr caps = NULL;
     char *nodeset;
+    char *cpuset;
     int ret = -1;

     nodeset = virXPathString("string(./numad/@nodeset)", ctxt);
+    cpuset = virXPathString("string(./numad/@cpuset)", ctxt);

-    if (!nodeset)
+    if (!nodeset && !cpuset)
         return 0;

     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
@@ -1971,15 +1983,21 @@ qemuDomainObjPrivateXMLParseAutomaticPlacement(virQEMUDriverPtr driver,
     if (virBitmapParse(nodeset, &priv->autoNodeset, caps->host.nnumaCell_max) < 0)
         goto cleanup;

-    if (!(priv->autoCpuset = virCapabilitiesGetCpusForNodemask(caps,
-                                                               priv->autoNodeset)))
-        goto cleanup;
+    if (cpuset) {
+        if (virBitmapParse(cpuset, &priv->autoCpuset, VIR_DOMAIN_CPUMASK_LEN) < 0)
+            goto cleanup;
+    } else {
+        if (!(priv->autoCpuset = virCapabilitiesGetCpusForNodemask(caps,
+                                                                   priv->autoNodeset)))
+            goto cleanup;
+    }

     ret = 0;

  cleanup:
     virObjectUnref(caps);
     VIR_FREE(nodeset);
+    VIR_FREE(cpuset);

     return ret;
 }
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 79347671f..24d1eb33c 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -95,7 +95,7 @@ static const char testStatusXMLPrefixFooter[] =
 "    <device alias='net0'/>\n"
 "    <device alias='usb'/>\n"
 "  </devices>\n"
-"  <numad nodeset='0-2'/>\n"
+"  <numad nodeset='0-2' cpuset='1,3'/>\n"
 "  <libDir path='/tmp'/>\n"
 "  <channelTargetDir path='/tmp/channel'/>\n";

-- 
2.12.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]