[libvirt] [PATCH 07/11] iscsi: Change order of checks in createVport

Eric Farman farman at linux.vnet.ibm.com
Thu Dec 8 15:39:34 UTC 2016



On 11/18/2016 09:26 AM, John Ferlan wrote:
> Move the check for an already existing vHBA to the top of the function.
> No sense in first decoding a provided parent if the next thing we're going
> to do is fail if a provided wwnn/wwpn already exists.
>
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>   src/storage/storage_backend_scsi.c | 28 ++++++++++++++--------------
>   1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
> index cf93fdc..9863880 100644
> --- a/src/storage/storage_backend_scsi.c
> +++ b/src/storage/storage_backend_scsi.c
> @@ -706,20 +706,6 @@ createVport(virConnectPtr conn,
>                 conn, NULLSTR(configFile), NULLSTR(adapter->data.fchost.parent),
>                 adapter->data.fchost.wwnn, adapter->data.fchost.wwpn);
>
> -    /* 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)
> -            return -1;
> -
> -        if (!virIsCapableFCHost(NULL, parent_host)) {
> -            virReportError(VIR_ERR_XML_ERROR,
> -                           _("parent '%s' specified for vHBA "
> -                             "is not vport capable"),
> -                           adapter->data.fchost.parent);
> -            return -1;
> -        }
> -    }
> -
>       /* If we find an existing HBA/vHBA within the fc_host sysfs
>        * using the wwnn/wwpn, then a nodedev is already created for
>        * this pool and we don't have to create the vHBA
> @@ -736,6 +722,20 @@ 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)
> +            return -1;
> +
> +        if (!virIsCapableFCHost(NULL, parent_host)) {
> +            virReportError(VIR_ERR_XML_ERROR,
> +                           _("parent '%s' specified for vHBA "
> +                             "is not vport capable"),
> +                           adapter->data.fchost.parent);
> +            return -1;
> +        }
> +    }
> +
>       if (!adapter->data.fchost.parent) {

This could be an else now.

  - Eric

>           if (!(parent_hoststr = virFindFCHostCapableVport(NULL))) {
>               virReportError(VIR_ERR_XML_ERROR, "%s",




More information about the libvir-list mailing list