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

[libvirt] [PATCH 03/13] conf: move iothread parse code into its own function



Signed-off-by: Pavel Hrdina <phrdina redhat com>
---
 src/conf/domain_conf.c | 93 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 56 insertions(+), 37 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 71cd572a30..b303c3f46c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15555,6 +15555,61 @@ virDomainIOThreadIDDefParseXML(xmlNodePtr node,
 }
 
 
+static int
+virDomainDefParseIOThreads(virDomainDefPtr def,
+                           xmlXPathContextPtr ctxt)
+{
+    size_t i;
+    char *tmp;
+    int n = 0;
+    unsigned int iothreads = 0;
+    xmlNodePtr *nodes = NULL;
+
+    tmp = virXPathString("string(./iothreads[1])", ctxt);
+    if (tmp && virStrToLong_uip(tmp, NULL, 10, &iothreads) < 0) {
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("invalid iothreads count '%s'"), tmp);
+        goto error;
+    }
+    VIR_FREE(tmp);
+
+    /* Extract any iothread id's defined */
+    if ((n = virXPathNodeSet("./iothreadids/iothread", ctxt, &nodes)) < 0)
+        goto error;
+
+    if (n > iothreads)
+        iothreads = n;
+
+    if (n && VIR_ALLOC_N(def->iothreadids, n) < 0)
+        goto error;
+
+    for (i = 0; i < n; i++) {
+        virDomainIOThreadIDDefPtr iothrid = NULL;
+        if (!(iothrid = virDomainIOThreadIDDefParseXML(nodes[i], ctxt)))
+            goto error;
+
+        if (virDomainIOThreadIDFind(def, iothrid->iothread_id)) {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("duplicate iothread id '%u' found"),
+                           iothrid->iothread_id);
+            virDomainIOThreadIDDefFree(iothrid);
+            goto error;
+        }
+        def->iothreadids[def->niothreadids++] = iothrid;
+    }
+    VIR_FREE(nodes);
+
+    if (virDomainIOThreadIDDefArrayInit(def, iothreads) < 0)
+        goto error;
+
+    return 0;
+
+ error:
+    VIR_FREE(nodes);
+    return -1;
+}
+
+
 /* Parse the XML definition for a vcpupin
  *
  * vcpupin has the form of
@@ -16755,43 +16810,7 @@ virDomainDefParseXML(xmlDocPtr xml,
     if (virDomainVcpuParse(def, ctxt, xmlopt) < 0)
         goto error;
 
-    /* Optional - iothreads */
-    unsigned int iothreads;
-    tmp = virXPathString("string(./iothreads[1])", ctxt);
-    if (tmp && virStrToLong_uip(tmp, NULL, 10, &iothreads) < 0) {
-        virReportError(VIR_ERR_XML_ERROR,
-                       _("invalid iothreads count '%s'"), tmp);
-        goto error;
-    }
-    VIR_FREE(tmp);
-
-    /* Extract any iothread id's defined */
-    if ((n = virXPathNodeSet("./iothreadids/iothread", ctxt, &nodes)) < 0)
-        goto error;
-
-    if (n > iothreads)
-        iothreads = n;
-
-    if (n && VIR_ALLOC_N(def->iothreadids, n) < 0)
-        goto error;
-
-    for (i = 0; i < n; i++) {
-        virDomainIOThreadIDDefPtr iothrid = NULL;
-        if (!(iothrid = virDomainIOThreadIDDefParseXML(nodes[i], ctxt)))
-            goto error;
-
-        if (virDomainIOThreadIDFind(def, iothrid->iothread_id)) {
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("duplicate iothread id '%u' found"),
-                           iothrid->iothread_id);
-            virDomainIOThreadIDDefFree(iothrid);
-            goto error;
-        }
-        def->iothreadids[def->niothreadids++] = iothrid;
-    }
-    VIR_FREE(nodes);
-
-    if (virDomainIOThreadIDDefArrayInit(def, iothreads) < 0)
+    if (virDomainDefParseIOThreads(def, ctxt) < 0)
         goto error;
 
     /* Extract cpu tunables. */
-- 
2.11.1


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