virStorageAdapterParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Tim Wiederhake 2021-05-19 16:10:11 +02:00 committed by Michal Privoznik
parent 058d4ed47e
commit 99037fb2b9

View File

@ -170,18 +170,16 @@ virStorageAdapterParseXML(virStorageAdapter *adapter,
{ {
int type; int type;
VIR_XPATH_NODE_AUTORESTORE(ctxt) VIR_XPATH_NODE_AUTORESTORE(ctxt)
g_autofree char *adapter_type = NULL;
ctxt->node = node; ctxt->node = node;
if ((adapter_type = virXMLPropString(node, "type"))) { if ((type = virXMLPropEnum(node, "type",
if ((type = virStorageAdapterTypeFromString(adapter_type)) <= 0) { virStorageAdapterTypeFromString,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, VIR_XML_PROP_NONZERO, &adapter->type)) < 0)
_("Unknown pool adapter type '%s'"),
adapter_type);
return -1; return -1;
}
adapter->type = type; if (type == 0)
return virStorageAdapterParseXMLLegacy(node, ctxt, adapter);
if ((adapter->type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST) && if ((adapter->type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST) &&
(virStorageAdapterParseXMLFCHost(node, &adapter->data.fchost)) < 0) (virStorageAdapterParseXMLFCHost(node, &adapter->data.fchost)) < 0)
@ -191,10 +189,6 @@ virStorageAdapterParseXML(virStorageAdapter *adapter,
(virStorageAdapterParseXMLSCSIHost(node, ctxt, (virStorageAdapterParseXMLSCSIHost(node, ctxt,
&adapter->data.scsi_host)) < 0) &adapter->data.scsi_host)) < 0)
return -1; return -1;
} else {
if (virStorageAdapterParseXMLLegacy(node, ctxt, adapter) < 0)
return -1;
}
return 0; return 0;
} }