Using virsh to Manage VMware VMs

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

$ virsh -c esx://192.168.2.202
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@192.168.2.200?no_verify=1 list --all
Enter root's password for 192.168.2.200:
 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@192.168.2.202?no_verify=1 start "vCenter 5.1"
Enter root's password for 192.168.2.202:
Domain vCenter 5.1 started

In the vCenter Server:

$ virsh -c 'vpx://root@192.168.2.22/Fusion%20Datacenter/Fusion%20Cluster/192.168.2.202?no_verify=1' list --all
Enter root's password for 192.168.2.22:
 Id    Name                           State
----------------------------------------------------
 171   vCenter 5.1                    running

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

Advertisements

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 (http://www.redhat.com/mailman/listinfo/libvir-list). In the documentation (http://libvirt.org/drvesx.html#uriformat) 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:

WordPress.com Logo

You are commenting using your WordPress.com 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