[libvirt] [PATCH v3] storage: Disallow usage of the HBA for a fc_host backing

Erik Skultety eskultet at redhat.com
Tue Jul 25 15:08:25 UTC 2017


> +/**
> + * @name: Name from a wwnn/wwpn lookup
> + *
> + * Validate that the @name fetched from the wwnn/wwpn is a vHBA
> + * and not an HBA as that should be a configuration error. It's only
> + * possible to use an existing wwnn/wwpn of a vHBA because that's
> + * what someone would have created using the node device create via XML
> + * functionality. Using the HBA "just because" it has a wwnn/wwpn and
> + * the characteristics of a vHBA is just not valid
> + *
> + * Returns true if the @name is OK, false on error
> + */
> +static bool
> +checkName(const char *name)
> +{
> +    unsigned int host_num;
> +
> +    if (virSCSIHostGetNumber(name, &host_num) &&

I expressed my doubts about ^this if it fails...I was wrong, if that fails,
we've got other problems, IOW virVHBAGetHostByWWN always must feed us a valid
name, since it's fetching it from the filesystem, so we should not have any
problem parsing it, thus extracting @host_num from it.

So, I'm sorry I didn't see it right away, ACK.

Erik

> +        virVHBAIsVportCapable(NULL, host_num))
> +        return true;
> +
> +    virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> +                   _("the wwnn/wwpn for '%s' are assigned to an HBA"), name);
> +    return false;
> +}
> +
> +
>  /*
>   * Using the host# name found via wwnn/wwpn lookup in the fc_host
>   * sysfs tree to get the parent 'scsi_host#' to ensure it matches.
> @@ -288,6 +315,9 @@ createVport(virConnectPtr conn,
>       * this pool and we don't have to create the vHBA
>       */
>      if ((name = virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn))) {
> +        if (!(checkName(name)))
> +            goto cleanup;
> +
>          /* If a parent was provided, let's make sure the 'name' we've
>           * retrieved has the same parent. If not this will cause failure. */
>          if (!fchost->parent || checkParent(conn, name, fchost->parent))
> --
> 2.9.4
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list




More information about the libvir-list mailing list