[PATCH v1 43/51] util: conf: separate virDomainDefParseShmemInfo from virDomainDefParseXML

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

 



separate virDomainDefParseShmemInfo from virDomainDefParseXML,
move virDomainDefParseShmemInfo into virDomainDefParseDeviceInfo
---
 src/conf/domain_conf.c | 58 +++++++++++++++++++++++++++++++++-----------------
 1 file changed, 39 insertions(+), 19 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 412e59c..281042f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -20793,6 +20793,44 @@ virDomainDefParsePanicInfo(virDomainParseTotalParamPtr param)
 
 
 static int
+virDomainDefParseShmemInfo(virDomainParseTotalParamPtr param)
+{
+    virDomainDefPtr def = param->def;
+    xmlXPathContextPtr ctxt = param->ctxt;
+    virDomainXMLOptionPtr xmlopt = param->xmlopt;
+    unsigned int flags = param->flags;
+
+    int ret = -1;
+    int n = 0;
+    size_t i;
+    xmlNodePtr *nodes = NULL, node=NULL;
+
+    /* analysis of the shmem devices */
+    if ((n = virXPathNodeSet("./devices/shmem", ctxt, &nodes)) < 0)
+        goto cleanup;
+    if (n && VIR_ALLOC_N(def->shmems, n) < 0)
+        goto cleanup;
+
+    node = ctxt->node;
+    for (i = 0; i < n; i++) {
+        virDomainShmemDefPtr shmem;
+        ctxt->node = nodes[i];
+        shmem = virDomainShmemDefParseXML(xmlopt, nodes[i], ctxt, flags);
+        if (!shmem)
+            goto cleanup;
+
+        def->shmems[def->nshmems++] = shmem;
+    }
+    ctxt->node = node;
+    ret = 0;
+
+ cleanup:
+    VIR_FREE(nodes);
+    return ret;
+}
+
+
+static int
 virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param)
 {
     typedef int (*virDomainPreaseDeviceFuc)(virDomainParseTotalParamPtr param);
@@ -20824,6 +20862,7 @@ virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param)
             virDomainDefParseRedirdevInfo,
             virDomainDefParseRedirFilterInfo,
             virDomainDefParsePanicInfo,
+            virDomainDefParseShmemInfo,
             NULL
     };
 
@@ -20926,25 +20965,6 @@ virDomainDefParseXML(xmlDocPtr xml,
         fun_index++;
     }
 
-    /* analysis of the shmem devices */
-    if ((n = virXPathNodeSet("./devices/shmem", ctxt, &nodes)) < 0)
-        goto error;
-    if (n && VIR_ALLOC_N(def->shmems, n) < 0)
-        goto error;
-
-    node = ctxt->node;
-    for (i = 0; i < n; i++) {
-        virDomainShmemDefPtr shmem;
-        ctxt->node = nodes[i];
-        shmem = virDomainShmemDefParseXML(xmlopt, nodes[i], ctxt, flags);
-        if (!shmem)
-            goto error;
-
-        def->shmems[def->nshmems++] = shmem;
-    }
-    ctxt->node = node;
-    VIR_FREE(nodes);
-
     /* analysis of memory devices */
     if ((n = virXPathNodeSet("./devices/memory", ctxt, &nodes)) < 0)
         goto error;
-- 
2.8.3


--
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]

  Powered by Linux