[PATCH 1/5] conf: Split out parsing of emulatorpin

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

 



Split up parts of virDomainVcpuPinDefParseXML into
virDomainEmulatorPinDefParseXML.
---
 src/conf/domain_conf.c | 50 +++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 37 insertions(+), 13 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1763305..ec7f9c9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13171,7 +13171,6 @@ static virDomainPinDefPtr
 virDomainVcpuPinDefParseXML(xmlNodePtr node,
                             xmlXPathContextPtr ctxt,
                             int maxvcpus,
-                            bool emulator,
                             bool iothreads)
 {
     virDomainPinDefPtr def;
@@ -13186,7 +13185,7 @@ virDomainVcpuPinDefParseXML(xmlNodePtr node,

     ctxt->node = node;

-    if (!emulator && !iothreads) {
+    if (!iothreads) {
         ret = virXPathInt("string(./@vcpu)", ctxt, &vcpuid);
         if ((ret == -2) || (vcpuid < -1)) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -13235,10 +13234,7 @@ virDomainVcpuPinDefParseXML(xmlNodePtr node,
     }

     if (!(tmp = virXMLPropString(node, "cpuset"))) {
-        if (emulator)
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("missing cpuset for emulatorpin"));
-        else if (iothreads)
+        if (iothreads)
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("missing cpuset for iothreadpin"));
         else
@@ -13262,6 +13258,38 @@ virDomainVcpuPinDefParseXML(xmlNodePtr node,
 }


+/* Parse the XML definition for emulatorpin.
+ * emulatorpin has the form of
+ *   <emulatorpin cpuset='0'/>
+ */
+static virDomainPinDefPtr
+virDomainEmulatorPinDefParseXML(xmlNodePtr node)
+{
+    virDomainPinDefPtr def;
+    char *tmp = NULL;
+
+    if (VIR_ALLOC(def) < 0)
+        return NULL;
+
+    if (!(tmp = virXMLPropString(node, "cpuset"))) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("missing cpuset for emulatorpin"));
+        goto error;
+    }
+
+    if (virBitmapParse(tmp, 0, &def->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0)
+        goto error;
+
+    VIR_FREE(tmp);
+    return def;
+
+ error:
+    VIR_FREE(tmp);
+    VIR_FREE(def);
+    return NULL;
+}
+
+
 int
 virDomainDefMaybeAddController(virDomainDefPtr def,
                                int type,
@@ -13942,7 +13970,7 @@ virDomainDefParseXML(xmlDocPtr xml,
     for (i = 0; i < n; i++) {
         virDomainPinDefPtr vcpupin = NULL;
         vcpupin = virDomainVcpuPinDefParseXML(nodes[i], ctxt,
-                                              def->maxvcpus, false, false);
+                                              def->maxvcpus, false);

         if (!vcpupin)
             goto error;
@@ -14012,11 +14040,7 @@ virDomainDefParseXML(xmlDocPtr xml,
             goto error;
         }

-        def->cputune.emulatorpin = virDomainVcpuPinDefParseXML(nodes[0],
-                                                               ctxt, 0,
-                                                               true, false);
-
-        if (!def->cputune.emulatorpin)
+        if (!(def->cputune.emulatorpin = virDomainEmulatorPinDefParseXML(nodes[0])))
             goto error;
     }
     VIR_FREE(nodes);
@@ -14035,7 +14059,7 @@ virDomainDefParseXML(xmlDocPtr xml,
         virDomainPinDefPtr iothreadpin = NULL;
         iothreadpin = virDomainVcpuPinDefParseXML(nodes[i], ctxt,
                                                   def->iothreads,
-                                                  false, true);
+                                                  true);
         if (!iothreadpin)
             goto error;

-- 
2.2.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]