On Fri, Sep 20, 2013 at 03:06:50PM -0500, Doug Goldstein wrote: > 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. > --- > src/vmware/vmware_conf.c | 23 ++++++++++++++++++++--- > src/vmware/vmware_driver.c | 20 ++++++++++++++++++-- > 2 files changed, 38 insertions(+), 5 deletions(-) > > diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c > index 261a4f6..d7ea8c4 100644 > --- a/src/vmware/vmware_conf.c > +++ b/src/vmware/vmware_conf.c > @@ -257,10 +257,25 @@ vmwareExtractVersion(struct vmware_driver *driver) > { > unsigned long version = 0; > int ret = -1; > - virCommandPtr cmd; > + virCommandPtr cmd = NULL; > char * outbuf = NULL; > - const char * bin = (driver->type == VMWARE_DRIVER_PLAYER) ? > - "vmplayer" : "vmware"; > + char *bin = NULL; > + char *vmwarePath = NULL; > + > + if ((vmwarePath = mdir_name(driver->vmrun)) == NULL) > + goto cleanup; > + > + switch (driver->type) { > + case VMWARE_DRIVER_PLAYER: > + if (virAsprintf(&bin, "%s/%s", vmwarePath, "vmplayer")) > + goto cleanup; > + break; > + > + case VMWARE_DRIVER_WORKSTATION: > + if (virAsprintf(&bin, "%s/%s", vmwarePath, "vmware")) > + goto cleanup; > + break; > + } I think we should have a 'default' in here, otherwise we could end up passing 'NULL' for the 'bin' parameter below in the future. > > cmd = virCommandNewArgList(bin, "-v", NULL); > virCommandSetOutputBuffer(cmd, &outbuf); > @@ -276,6 +291,8 @@ vmwareExtractVersion(struct vmware_driver *driver) > cleanup: > virCommandFree(cmd); > VIR_FREE(outbuf); > + VIR_FREE(bin); > + VIR_FREE(vmwarePath); > return ret; > } Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list