]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virStoragePoolDefParseXML: Use virXMLProp*
authorTim Wiederhake <twiederh@redhat.com>
Tue, 11 May 2021 15:01:57 +0000 (17:01 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 13 May 2021 07:24:09 +0000 (09:24 +0200)
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
src/conf/storage_conf.c

index 10b46ac36840fbdcfce057d336f69879185ada2e..e481cac75c07b73a13675b1f1fbb63c363f61c0e 100644 (file)
@@ -841,24 +841,17 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt)
     virStoragePoolOptions *options;
     xmlNodePtr source_node;
     g_autoptr(virStoragePoolDef) def = NULL;
-    g_autofree char *type = NULL;
+    virStoragePoolType type;
     g_autofree char *uuid = NULL;
     g_autofree char *target_path = NULL;
 
     def = g_new0(virStoragePoolDef, 1);
 
-    type = virXPathString("string(./@type)", ctxt);
-    if (type == NULL) {
-        virReportError(VIR_ERR_XML_ERROR, "%s",
-                       _("storage pool missing type attribute"));
+    if (virXMLPropEnum(ctxt->node, "type", virStoragePoolTypeFromString,
+                       VIR_XML_PROP_REQUIRED, &type) < 0)
         return NULL;
-    }
 
-    if ((def->type = virStoragePoolTypeFromString(type)) < 0) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("unknown storage pool type %s"), type);
-        return NULL;
-    }
+    def->type = type;
 
     if ((options = virStoragePoolOptionsForPoolType(def->type)) == NULL)
         return NULL;