1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 07:59:00 +00:00

scsi: Converge more createVport checks

Remove duplicated code - make one simple path through

Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
John Ferlan 2017-01-03 17:00:36 -05:00
parent 476ecf2a2a
commit 9fdc8c4269

View File

@ -722,27 +722,17 @@ createVport(virConnectPtr conn,
goto cleanup;
}
/* If a parent was provided, then let's make sure it's vhost capable */
if (adapter->data.fchost.parent) {
if (virGetSCSIHostNumber(adapter->data.fchost.parent, &parent_host) < 0)
if (VIR_STRDUP(parent_hoststr, adapter->data.fchost.parent) < 0)
goto cleanup;
if (!virIsCapableFCHost(NULL, parent_host)) {
virReportError(VIR_ERR_XML_ERROR,
_("parent '%s' specified for vHBA "
"is not vport capable"),
adapter->data.fchost.parent);
goto cleanup;
}
}
if (!adapter->data.fchost.parent) {
} else {
if (!(parent_hoststr = virFindFCHostCapableVport(NULL))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("'parent' for vHBA not specified, and "
"cannot find one on this host"));
goto cleanup;
}
}
if (virGetSCSIHostNumber(parent_hoststr, &parent_host) < 0)
goto cleanup;
@ -755,6 +745,11 @@ createVport(virConnectPtr conn,
* parent. Besides we have a way to determine the parent based on
* the 'name' field.
*/
if (adapter->data.fchost.parent && !virIsCapableFCHost(NULL, parent_host)) {
virReportError(VIR_ERR_XML_ERROR,
_("parent '%s' specified for vHBA is not vport capable"),
parent_hoststr);
goto cleanup;
}
/* Since we're creating the vHBA, then we need to manage removing it