Compiling libvirt 0.10.1 on CentOS 6.3

In my post on installing KVM and Open vSwitch on Ubuntu, I mentioned that I was using libvirt as the virtualization API/toolkit by which to manage KVM. Unfortunately, that particular version of libvirt didn’t have built-in support for Open vSwitch; that was added in libvirt 0.9.11 (I think that I was using 0.9.8 in my testing). In any case, I noticed that libvirt had released 0.10.1 on August 31, and it included a couple of OVS fixes regarding VLANs and VLAN support (among a host of other fixes; see here for more details). Considering that OVS is a key focus area for me (it’s foundational to OpenStack Quantum), I thought I’d upgrade my test system to the latest version of libvirt. Because the release was so new, there weren’t yet any precompiled binary packages of the latest version, which meant I had to compile and install it on my own.

My first attempt to do so was using Ubuntu 12.04.1 LTS, and while it appeared successful at first, I soon found that it was horribly broken. While I do really like Ubuntu as a desktop Linux distribution, I’m not entirely convinced (and even less so now) about it’s place as a server distribution. With that in mind, and considering the enormous popularity of Red Hat, I decided to rebuilt my test system with CentOS 6.3 (the “community version” of Red Hat Enterprise Linux 6.3) and try it again there. In order to use libvirt, I naturally had to get KVM installed on CentOS 6.3 first; here is the process I used.

Once KVM was installed, this attempt at compiling the latest version of libvirt was much more successful, so I wanted to document the process for others.

I started out with a CentOS 6.3 x86_64 system that already had KVM and libvirt installed from packages (see this article for full details), and from there I followed these steps:

  1. First I downloaded the tarball for libvirt 0.10.1 from the HTTP server. You could probably use curl or wget to do this directly from the CentOS server; in my case, I downloaded it on my Mac and then used SFTP to push it to the CentOS server.

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

  3. gunzip -c libvirt-0.10.1.tar.gz | tar xvf -
  4. I used cd to change into the newly-created libvirt-0.10.1 directory that resulted from the commands in step 2.

  5. Through process of elimination (in other words, running configure again and again) I determined that the following packages need to be installed before you’ll be able to successfully compile libvirt 0.10.1: gcc, make, libxml2-devel, gnutls-devel, device-mapper-devel, python-devel, and libnl-devel. I used yum install to install each of these packages.

  6. With all the dependencies now satisfied, I ran the configure command from the extracted libvirt-0.10.1 directory. I selected the specified directories because that matched where the existing binaries were on the system (there’s probably an easier way):

  7. ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc
  8. The above command results in a libvirt that supports KVM, OpenVZ, LXC, etc., but doesn’t support Xen or ESX. You’d have to add the --with-xen or --with-esx parameters to the configure command to include support for those. Following completion of the previous command, it was very straightforward:

  9. make
    make install
  10. Finally, I restarted libvirtd with service libvirtd restart. The daemon restarted on my system cleanly and without any errors.

Failing to run ldconfig at the end, by the way, resulted in numerous errors when trying to run virsh.

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. All in all, it was pretty straightforward, and I was pleasantly surprised that it wasn’t more complicated or troublesome.

Now, if only the story with Open vSwitch and CentOS 6.3 was as simple…but that is a post for another day. Until then, feel free to speak up in the comments below.

Tags: , , , , ,

  1. Daniel Veillard’s avatar

    Aie aie aie … if you are updating a Red Hat/CentOS/Fedora system use the rpm packages !!! Do not make install and get into an unmaintainable mess …

    fettch the src.rpm
    rpmbuild –rebuild libvirt 0.10.1-1.src.rpm
    make sure you have all the needed dependencies
    once the build succeeds
    rpm -U ….. list of new packages created.
    then you can roll back to older version or new ones cleanly.


  2. Chris Cowley’s avatar

    @Daniel An alternative would be to install it from my repo ( Saves the dependency hell that we have now left behind.

    Sorry Scott, I blatantly stood on the shoulders of giants :)

  3. slowe’s avatar

    Chris, do you have a libvirt 1.0.0 package in your repo? :-)

  4. Yuriy’s avatar

    Chris, is there libvirt 1.0.0 build with xen support in your repository? Or give SRPM for it, please.

  5. Arvind’s avatar

    I am trying to install libvirt in centos 63 as well. However I try add the source rpm of all the dependencies in our build as we dont have yum support in the final image of centos. I am having trouble finding some of the development source rpm’s. For eg., libvirt depends on libnl-devel. How ever I could not find src rpm for this pkg although I already have libnl source rpm installed. I could not find more info about this library. Any tips on fixing this issue in my environment.


Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>