[libvirt] [PATCH 28/34] conf: Use virDomainStorageSourceParseFull in virDomainDiskDefMirrorParse

Peter Krempa pkrempa at redhat.com
Mon Mar 18 15:55:17 UTC 2019


Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/conf/domain_conf.c | 25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ec666d8d8c..5790b19315 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9334,15 +9334,11 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def,
                             unsigned int flags,
                             virDomainXMLOptionPtr xmlopt)
 {
-    xmlNodePtr mirrorNode;
     VIR_AUTOFREE(char *) mirrorFormat = NULL;
     VIR_AUTOFREE(char *) mirrorType = NULL;
     VIR_AUTOFREE(char *) ready = NULL;
     VIR_AUTOFREE(char *) blockJob = NULL;

-    if (!(def->mirror = virStorageSourceNew()))
-        return -1;
-
     if ((blockJob = virXMLPropString(cur, "job"))) {
         if ((def->mirrorJob = virDomainBlockJobTypeFromString(blockJob)) <= 0) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -9354,25 +9350,18 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def,
     }

     if ((mirrorType = virXMLPropString(cur, "type"))) {
-        if ((def->mirror->type = virStorageTypeFromString(mirrorType)) <= 0) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("unknown mirror backing store type '%s'"),
-                           mirrorType);
+        if (!(def->mirror = virDomainStorageSourceParseFull("string(./mirror/@type)",
+                                                            NULL,
+                                                            "./mirror/source",
+                                                            NULL,
+                                                            false, ctxt, flags, xmlopt)))
             return -1;
-        }

         mirrorFormat = virXPathString("string(./mirror/format/@type)", ctxt);
-
-        if (!(mirrorNode = virXPathNode("./mirror/source", ctxt))) {
-            virReportError(VIR_ERR_XML_ERROR, "%s",
-                           _("mirror requires source element"));
+    } else {
+        if (!(def->mirror = virStorageSourceNew()))
             return -1;
-        }

-        if (virDomainStorageSourceParse(mirrorNode, ctxt, def->mirror,
-                                        flags, xmlopt) < 0)
-            return -1;
-    } else {
         /* For back-compat reasons, we handle a file name
          * encoded as attributes, even though we prefer
          * modern output in the style of backingStore */
-- 
2.20.1




More information about the libvir-list mailing list