separate virDomainDefParseDisksInfo from virDomainDefParseXML,
move virDomainDefParseDisksInfo into virDomainDefParseDeviceInfo
---
 src/conf/domain_conf.c | 78 +++++++++++++++++++++++++++++++-------------------
 1 file changed, 49 insertions(+), 29 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 22db391..903dfec 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -18506,17 +18506,17 @@ typedef virDomainParseTotalParam 
*virDomainParseTotalParamPtr;
 
 struct _virDomainParseTotalParam{
     //input parameters
-    virDomainDefPtr def;
     xmlDocPtr xml;
     xmlNodePtr root;
     xmlXPathContextPtr ctxt;
     virCapsPtr caps;
     virDomainXMLOptionPtr xmlopt;
     void *parseOpaque;
-    virHashTablePtr bootHash;
     unsigned int flags;
 
-    //internal parameters
+    //internal parameters, must assignment before use it
+    virDomainDefPtr def;
+    virHashTablePtr bootHash;
     bool usb_none;
     bool usb_other;
     bool usb_master;
@@ -19869,6 +19869,48 @@ 
virDomainDefParseControllerInfo(virDomainParseTotalParamPtr param)
 
 
 static int
+virDomainDefParseDisksInfo(virDomainParseTotalParamPtr param)
+{
+    virDomainDefPtr def = param->def;
+    virDomainXMLOptionPtr xmlopt = param->xmlopt;
+    xmlXPathContextPtr ctxt = param->ctxt;
+    unsigned int flags = param->flags;
+    virHashTablePtr bootHash = param->bootHash;
+
+    int ret = -1;
+    int n = 0;
+    size_t i;
+    xmlNodePtr *nodes = NULL;
+
+    /* analysis of the disk devices */
+    if ((n = virXPathNodeSet("./devices/disk", ctxt, &nodes)) < 0)
+        goto cleanup;
+
+    if (n && VIR_ALLOC_N(def->disks, n) < 0)
+        goto cleanup;
+
+    for (i = 0; i < n; i++) {
+        virDomainDiskDefPtr disk = virDomainDiskDefParseXML(xmlopt,
+                                                            nodes[i],
+                                                            ctxt,
+                                                            bootHash,
+                                                            def->seclabels,
+                                                            def->nseclabels,
+                                                            flags);
+        if (!disk)
+            goto cleanup;
+
+        virDomainDiskInsertPreAlloced(def, disk);
+    }
+    ret = 0;
+
+ cleanup:
+    VIR_FREE(nodes);
+    return ret;
+}
+
+
+static int
 virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param)
 {
     typedef int (*virDomainPreaseDeviceFuc)(virDomainParseTotalParamPtr param);
@@ -19877,6 +19919,7 @@ virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr 
param)
 
     virDomainPreaseDeviceFuc parseFuc[] = {
             virDomainDefParseControllerInfo,
+            virDomainDefParseDisksInfo,
             NULL
     };
 
@@ -19893,6 +19936,7 @@ virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr 
param)
 
 }
 
+
 static virDomainDefPtr
 virDomainDefParseXML(xmlDocPtr xml,
                      xmlNodePtr root,
@@ -19915,15 +19959,15 @@ virDomainDefParseXML(xmlDocPtr xml,
     bool usb_none = false;
     char *netprefix = NULL;
     virDomainParseTotalParam param = {
-            NULL,
             xml,
             root,
             ctxt,
             caps,
             xmlopt,
             parseOpaque,
-            NULL,
             flags,
+            NULL,
+            NULL,
             false,
             false,
             false,
@@ -19982,30 +20026,6 @@ virDomainDefParseXML(xmlDocPtr xml,
         fun_index++;
     }
 
-    /* analysis of the disk devices */
-    if ((n = virXPathNodeSet("./devices/disk", ctxt, &nodes)) < 0)
-        goto error;
-
-    if (n && VIR_ALLOC_N(def->disks, n) < 0)
-        goto error;
-
-    for (i = 0; i < n; i++) {
-        virDomainDiskDefPtr disk = virDomainDiskDefParseXML(xmlopt,
-                                                            nodes[i],
-                                                            ctxt,
-                                                            bootHash,
-                                                            def->seclabels,
-                                                            def->nseclabels,
-                                                            flags);
-        if (!disk)
-            goto error;
-
-        virDomainDiskInsertPreAlloced(def, disk);
-    }
-    VIR_FREE(nodes);
-
-
-
     /* analysis of the resource leases */
     if ((n = virXPathNodeSet("./devices/lease", ctxt, &nodes)) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
-- 
2.8.3


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

Reply via email to