[libvirt] [vmware] Fix VMware driver version checking on Linux

ryan woodsmall rwoodsmall at gmail.com
Mon Jan 20 20:19:20 UTC 2014

Recent changes to the VMware driver allow for VMware Fusion version checking on OS X. It looks like the version checking on Linux for VMware Workstation and Player could possibly be broken by the changes. The version check in vmware_conf.c bundled STDOUT and STDERR into a common buffer; when/if something is printed to STDERR, at least on Player, version checking fails.

This example output causes the version check to fail on a RHEL6-based Linux install:
[ryan at os-sl6-controller ~]$ vmplayer -v
Gtk-Message: Failed to load module "canberra-gtk-module": libcanberra-gtk-module.so: cannot open shared object file: No such file or directory
VMware Player 6.0.1 build-1379776

[ryan at os-sl6-controller ~]$ virsh -c vmwareplayer:///session
error: failed to connect to the hypervisor
error: internal error: failed to parse VMware Player version

This patch bundles STDERR into the checked buffer only with the VMware Fusion driver, allowing the VMware Player version check to succeed on Linux even with the above warning. It looks like there's still an issue (see below) but virsh now starts at least.

[ryan at os-sl6-controller ~]$ virsh -c vmwareplayer:///session
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # version
Compiled against library: libvirt 1.2.1
Using library: libvirt 1.2.1
Using API: VMware 1.2.1
Cannot extract running VMware hypervisor version


This is virsh running against VMware Player 6.0.1 on Linux x86_64. I have not tested on OS X since I don't have a license for VMware Fusion. Thanks everyone!


diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c
index c96bd62..502d5c9 100644
--- a/src/vmware/vmware_conf.c
+++ b/src/vmware/vmware_conf.c
@@ -293,7 +293,8 @@ vmwareExtractVersion(struct vmware_driver *driver)
     cmd = virCommandNewArgList(bin, "-v", NULL);
     virCommandSetOutputBuffer(cmd, &outbuf);
-    virCommandSetErrorBuffer(cmd, &outbuf);
+    if (driver->type == VMWARE_DRIVER_FUSION)
+        virCommandSetErrorBuffer(cmd, &outbuf);
     if (virCommandRun(cmd, NULL) < 0)
         goto cleanup;

More information about the libvir-list mailing list