[libvirt] [PATCH v1 08/51] util: conf: separate virDomainDefParseVcpuInfo from virDomainDefParseXML

xinhua.Cao caoxinhua at huawei.com
Thu Feb 8 06:46:06 UTC 2018


separate virDomainDefParseVcpuInfo from virDomainDefParseXML
---
 src/conf/domain_conf.c | 92 +++++++++++++++++++++++++++++++-------------------
 1 file changed, 58 insertions(+), 34 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 809c06a..4453621 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -18930,6 +18930,62 @@ virDomainDefParseMemoryInfo(virDomainParseTotalParamPtr param)
 }
 
 
+static int
+virDomainDefParseBikiotuneInfo(virDomainParseTotalParamPtr param)
+{
+    virDomainDefPtr def = param->def;
+    xmlXPathContextPtr ctxt = param->ctxt;
+    int ret = -1;
+    int n;
+    size_t i, j;
+    xmlNodePtr *nodes = NULL;
+
+    /* Extract blkio cgroup tunables */
+    if (virXPathUInt("string(./blkiotune/weight)", ctxt,
+                     &def->blkio.weight) < 0)
+        def->blkio.weight = 0;
+
+    if ((n = virXPathNodeSet("./blkiotune/device", ctxt, &nodes)) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       "%s", _("cannot extract blkiotune nodes"));
+        goto cleanup;
+    }
+    if (n && VIR_ALLOC_N(def->blkio.devices, n) < 0)
+        goto cleanup;
+
+    for (i = 0; i < n; i++) {
+        if (virDomainBlkioDeviceParseXML(nodes[i],
+                                         &def->blkio.devices[i]) < 0)
+            goto cleanup;
+        def->blkio.ndevices++;
+        for (j = 0; j < i; j++) {
+            if (STREQ(def->blkio.devices[j].path,
+                      def->blkio.devices[i].path)) {
+                virReportError(VIR_ERR_XML_ERROR,
+                               _("duplicate blkio device path '%s'"),
+                               def->blkio.devices[i].path);
+                goto cleanup;
+            }
+        }
+    }
+    ret = 0;
+
+ cleanup:
+    VIR_FREE(nodes);
+    return ret;
+}
+
+
+static int
+virDomainDefParseVcpuInfo(virDomainParseTotalParamPtr param)
+{
+    if (virDomainVcpuParse(param->def, param->ctxt, param->xmlopt) < 0)
+        return -1;
+
+    return 0;
+}
+
+
 static virDomainDefPtr
 virDomainDefParseXML(xmlDocPtr xml,
                      xmlNodePtr root,
@@ -18976,6 +19032,8 @@ virDomainDefParseXML(xmlDocPtr xml,
             virDomainDefParseDomainInfo,
             virDomainDefParseSecurityLabelInfo,
             virDomainDefParseMemoryInfo,
+            virDomainDefParseBikiotuneInfo,
+            virDomainDefParseVcpuInfo,
             NULL
     };
 
@@ -19003,40 +19061,6 @@ virDomainDefParseXML(xmlDocPtr xml,
         fun_index++;
     }
 
-
-    /* Extract blkio cgroup tunables */
-    if (virXPathUInt("string(./blkiotune/weight)", ctxt,
-                     &def->blkio.weight) < 0)
-        def->blkio.weight = 0;
-
-    if ((n = virXPathNodeSet("./blkiotune/device", ctxt, &nodes)) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       "%s", _("cannot extract blkiotune nodes"));
-        goto error;
-    }
-    if (n && VIR_ALLOC_N(def->blkio.devices, n) < 0)
-        goto error;
-
-    for (i = 0; i < n; i++) {
-        if (virDomainBlkioDeviceParseXML(nodes[i],
-                                         &def->blkio.devices[i]) < 0)
-            goto error;
-        def->blkio.ndevices++;
-        for (j = 0; j < i; j++) {
-            if (STREQ(def->blkio.devices[j].path,
-                      def->blkio.devices[i].path)) {
-                virReportError(VIR_ERR_XML_ERROR,
-                               _("duplicate blkio device path '%s'"),
-                               def->blkio.devices[i].path);
-                goto error;
-            }
-        }
-    }
-    VIR_FREE(nodes);
-
-    if (virDomainVcpuParse(def, ctxt, xmlopt) < 0)
-        goto error;
-
     if (virDomainDefParseIOThreads(def, ctxt) < 0)
         goto error;
 
-- 
2.8.3





More information about the libvir-list mailing list