[libvirt] [PATCHv3 1/2] VMware: Support more than 2 driver backends

Matthias Bolte matthias.bolte at googlemail.com
Fri Sep 27 09:24:53 UTC 2013


2013/9/24 Doug Goldstein <cardoe at cardoe.com>:
> Currently the VMware version check code only supports two types of
> VMware backends, Workstation and Player. But in the near future we will
> have an additional one so we need to support more. Additionally, we
> discover and cache the path to the vmrun binary so we should use that
> path when using the cooresponding binary from the VMware VIX SDK.

s/cooresponding/corresponding/

> ---
>
> change from v2:
> * No change
>
> change from v1:
> * Added default case so we don't potentially pass NULL to virCommand
>
> ---
>  src/vmware/vmware_conf.c   | 28 +++++++++++++++++++++++++---
>  src/vmware/vmware_driver.c | 20 ++++++++++++++++++--
>  2 files changed, 43 insertions(+), 5 deletions(-)

> diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
> index 4e56971..01d65ed 100644
> --- a/src/vmware/vmware_driver.c
> +++ b/src/vmware/vmware_driver.c

> @@ -144,8 +145,23 @@ vmwareConnectOpen(virConnectPtr conn,
>      if (virMutexInit(&driver->lock) < 0)
>          goto cleanup;
>
> -    driver->type = STRNEQ(conn->uri->scheme, "vmwareplayer") ?
> -      VMWARE_DRIVER_WORKSTATION : VMWARE_DRIVER_PLAYER;
> +    if ((tmp = STRSKIP(conn->uri->scheme, "vmware")) == NULL) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to parse URI "
> +                       "scheme '%s'"), conn->uri->scheme);
> +        goto cleanup;
> +    }
> +
> +    driver->type = -1;
> +    for (i = 0; i < VMWARE_DRIVER_LAST; i++) {
> +        if (STREQ(tmp, vmwareDriverTypeToString(i)))
> +            driver->type = i;

As a micro optimization you could break the loop once the type is found.

> +    }
> +

ACK.

-- 
Matthias Bolte
http://photron.blogspot.com




More information about the libvir-list mailing list