[libvirt] [PATCH v2 23/29] qemu: Use virDomainStorageSourceParseBase in qemuDomainObjPrivateXMLParseJobNBDSource

Peter Krempa pkrempa at redhat.com
Fri Mar 22 18:00:59 UTC 2019


The slight possible regression in error message descriptivness doesn't
matter much as the function parses private data which should not be
touched by users in the first place.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_domain.c | 25 ++++---------------------
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c7454ce821..0c06e3b23a 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2725,32 +2725,15 @@ qemuDomainObjPrivateXMLParseJobNBDSource(xmlNodePtr node,
     if (!(ctxt->node = virXPathNode("./migrationSource", ctxt)))
         return 0;

-    if (!(migrSource = virStorageSourceNew()))
-        return -1;
-
-    if (!(type = virXMLPropString(ctxt->node, "type"))) {
-        virReportError(VIR_ERR_XML_ERROR, "%s",
-                       _("missing storage source type"));
-        return -1;
-    }
-
-    if (!(format = virXMLPropString(ctxt->node, "format"))) {
+    if (!(type = virXMLPropString(ctxt->node, "type")) ||
+        !(format = virXMLPropString(ctxt->node, "format"))) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
-                       _("missing storage source format"));
+                       _("missing NBD migration storage source type or format"));
         return -1;
     }

-    if ((migrSource->type = virStorageTypeFromString(type)) <= 0) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("unknown storage source type '%s'"), type);
-        return -1;
-    }
-
-    if ((migrSource->format = virStorageFileFormatTypeFromString(format)) <= 0) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("unknown storage source format '%s'"), format);
+    if (!(migrSource = virDomainStorageSourceParseBase(type, format, NULL)))
         return -1;
-    }

     if ((sourceNode = virXPathNode("./source", ctxt)))
         ctxt->node = sourceNode;
-- 
2.20.1




More information about the libvir-list mailing list