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,31 +170,25 @@ virStorageAdapterParseXML(virStorageAdapter *adapter,
{
int type;
VIR_XPATH_NODE_AUTORESTORE(ctxt)
g_autofree char *adapter_type = NULL;
ctxt->node = node;
if ((adapter_type = virXMLPropString(node, "type"))) {
if ((type = virStorageAdapterTypeFromString(adapter_type)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unknown pool adapter type '%s'"),
adapter_type);
return -1;
}
adapter->type = type;
if ((type = virXMLPropEnum(node, "type",
virStorageAdapterTypeFromString,
VIR_XML_PROP_NONZERO, &adapter->type)) < 0)
return -1;
if ((adapter->type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST) &&
(virStorageAdapterParseXMLFCHost(node, &adapter->data.fchost)) < 0)
return -1;
if (type == 0)
return virStorageAdapterParseXMLLegacy(node, ctxt, adapter);
if ((adapter->type == VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST) &&
(virStorageAdapterParseXMLSCSIHost(node, ctxt,
&adapter->data.scsi_host)) < 0)
return -1;
} else {
if (virStorageAdapterParseXMLLegacy(node, ctxt, adapter) < 0)
return -1;
}
if ((adapter->type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST) &&
(virStorageAdapterParseXMLFCHost(node, &adapter->data.fchost)) < 0)
return -1;
if ((adapter->type == VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST) &&
(virStorageAdapterParseXMLSCSIHost(node, ctxt,
&adapter->data.scsi_host)) < 0)
return -1;
return 0;
}