Using virsh to Manage VMware VMs

By default, libvirt and its command virsh are not compiled with the VMware extension:

$ virsh -c esx://
error: failed to connect to the hypervisor
error: unsupported configuration: libvirt was built without the 'esx' driver

Fortunately this ppa has a version with the esx driver in it. Just add it and install it in Ubuntu 12.04 or Ubuntu 13.10:

$ sudo add-apt-repository ppa:zulcss/esx
$ sudo apt-get update
$ sudo apt-get install libvirt-bin

In an ESXi host:

$ virsh -c esx://root@ list --all
Enter root's password for
 Id    Name                           State
 -     077c7a49-a328-482b-9a9e-e0e0bfbdebd5 shut off
 -     1b6ea2ac-a24e-4497-b75e-0c53db246e16 shut off
 -     maas-node-1                    shut off
 -     nova-compute                   shut off

Start a VM:

$ virsh -c esx://root@ start "vCenter 5.1"
Enter root's password for
Domain vCenter 5.1 started

In the vCenter Server:

$ virsh -c 'vpx://root@' list --all
Enter root's password for
 Id    Name                           State
 171   vCenter 5.1                    running

More info in the libvirt ESX hypervisor driver documentation web page.


2 thoughts on “Using virsh to Manage VMware VMs

  1. How would you manage a VM if your setup is using vMotion to balance the esx servers? The VM constantly move between hosts. So even with the VPX protocol, I wouldn’t know which host the VM is currently residing. It doesn’t seem like Virsh has enough support built in to not specify a host.

    • Hi Jonathan, I don’t have the setup online right now to test it but I believe when the ESXi hosts are part of a vSphere cluster any ESXi host of the cluster can migrate VMs running on another ESXi host of the same Cluster. Having said that, I cannot test it right now. If you have a setup up and running please let me know if it works.

      It is probably worth discussing it in the mailing list ( In the documentation ( they mention it: “A vpx:// connection is currently restricted to a single ESX server. This might be relaxed in the future.” So the developers have had it in mind even if it’s not implemented yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s