From: Tim Wiederhake Date: Tue, 11 May 2021 15:01:57 +0000 (+0200) Subject: virStoragePoolDefParseXML: Use virXMLProp* X-Git-Tag: v7.4.0-rc1~146 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=210bdb61ffd08e4c6db8d22e9bb35f97394a0904;p=thirdparty%2Flibvirt.git virStoragePoolDefParseXML: Use virXMLProp* Signed-off-by: Tim Wiederhake Reviewed-by: Laine Stump --- diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 10b46ac368..e481cac75c 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -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;