Compiling libvirt 0.10.1 on Ubuntu 12.04

I guess I’m a glutton for punishment, because after successfully compiling libvirt 0.10.1 on CentOS 6.3, I came back to try it again on Ubuntu (my first attempt was not successful). Here is the process I followed to get libvirt 0.10.1 compiled and running on Ubuntu 12.04.

I started with a clean install of Ubuntu 12.04, then installed KVM and Open vSwitch per these instructions. At the end of those instructions, I had an Ubuntu Server 12.04.1 system running KVM and libvirt 0.9.8.

Once I verified the system was working as expected (I ran a few virsh commands to check for errors), I followed these steps:

  1. As with the CentOS effort, I first downloaded the tarball for libvirt 0.10.1 from the libvirt.org HTTP server.

  2. Next, I extracted the files using this command:

  3. gunzip -c libvirt-0.10.1.tar.gz | tar xvf -
  4. Using apt-get, I installed the following packages: libxml2-dev, libgnutls-dev, libyajl-dev, libnl-dev, pkg-config, libdevmapper-dev, libcurl4-gnutls-dev, and python-dev. (Note that you can omit the libcurl4-gnutls-dev package if you don’t want ESX support in libvirt.) Just like with the CentOS procedure, I determined the necessary list of packages by repeatedly running the configure command.

  5. With all the dependencies now satisfied, I ran the configure command from the extracted libvirt-0.10.1 directory. I specified particular directories because that matched where the existing binaries were on the system (there’s probably an easier way). I’ve line-wrapped the command here for readability:

  6. ./configure --prefix=/usr --localstatedir=/var \
    --sysconfdir=/etc --with-esx=yes
  7. The above command results in a libvirt that supports KVM, OpenVZ, LXC, etc., including ESX. You’d have to add the --with-xen parameter to the configure command to include support for Xen; that might also change the list of dependencies that need to be installed first.

  8. After the configure command completed successfully, it was very straightforward:

  9. make
    make install
  10. Finally, I restarted libvirtd with initctl stop libvirt-bin and initctl start libvirt-bin. I probably could have used initctl restart, but I wanted to see the shutdown and startup separately. In this case, the libvirt daemon shutdown and started back up cleanly and without any errors.

From there, I was able to run libvirtd --version or virsh --version to verify that the system was, in fact, running libvirt 0.10.1.

The one big difference between this effort and the CentOS effort earlier was that Open vSwitch was installed and working on this system, so I ran ovs-vsctl show to double-check the OVS configuration and operation. I noted that the system had re-created the default bridge, so I got rid of that with these two commands:

virsh net-destroy default
virsh net-autostart --disable default

That removed virbr0 from the OVS configuration, leaving only the OVS bridge that I created during the KVM+Open vSwitch installation earlier.

Now that my test system has both OVS and a version of libvirt that supports OVS, the next steps will be to conduct some more in-depth libvirt+OVS tests and document the results. Stay tuned!

Tags: , , , ,

  1. Dmitri Kalintsev’s avatar

    Hi Scott,

    Just a quick tip on dealing with tgz/tar.gz archives – just use “tar xvzf blah.tar.gz” to extract them :)

  2. Anthony Chow’s avatar

    Thanks Scott for sharing this. I am thinking of loading Ubuntu Server on an “older” pc and play with KVM also. Actually, in specific I want to see how KVM supports the EVB protocol.

    Do you also try any KVM management package such as any of these:
    http://www.linux-kvm.org/page/Management_Tools

    Thanks again and have a nice week.

  3. wopub’s avatar

    Hi Scott,
    i have a question about ubuntu’s libvirt. I found when i reboot or shutdown the host,then vm process will be killed by system. But use centos OS, when the host reboot or shutdown, there is a /etc/init.d/libvirt-guest script will be exec?Is there a way to shutdown a kvm-guest without the usage of libvirt/virsh?