Compiling libvirt 1.0.0 on Ubuntu 12.04 and 12.105 November 2012 · Filed in Tutorial
In case you hadn’t noticed late last week, the open source virtualization API project libvirt released version 1.0.0–a major milestone, obviously. To celebrate the 1.0.0 release, here are instructions for compiling the libvirt 1.0.0 release on Ubuntu 12.04 and 12.10.
(If you need instructions on compiling an earlier release of libvirt on Ubuntu, see this post. It works for libvirt 0.10.1 and 0.10.2 on Ubuntu 12.04 LTS; I haven’t yet tested it on Ubuntu 12.10.)
These instructions assume that you have built a plain-jane Ubuntu system (either 12.04 LTS or 12.10). I tested these instructions on an Ubuntu 12.04.1 LTS VM, freshly built and updated using
apt-get update && apt-get upgrade, on a freshly-built Ubuntu 12.10 VM (also up to date), and a physical system running an up-to-date instance of Ubuntu 12.04.1 that also had KVM and an earlier version of libvirt installed. These instructions worked in all three cases.
Ready? Let’s get started!
Download the libvirt-1.0.0.tar.gz tarball from the libvirt.org HTTP server.
Extract the tarball using
tar -xvzf libvirt-1.0.0.tar.gz.
apt-get, ensure that the following packages are installed: gcc, make, pkg-config (already installed in my testing), libxml2-dev, libgnutls-dev, libdevmapper-dev, libcurl4-gnutls-dev, and python-dev. (Interestingly enough, earlier versions also required libyajl-dev, but this version didn’t seem to need it.) You can probably omit the libcurl4-gnutls-dev package if you don’t want ESX support; I did want ESX support, so I included it.
From within the extracted libvirt-1.0.0 directory, run the
configurecommand. I specified particular directories because that’s where the prebuilt binaries from Ubuntu are normally placed, so the final command was
./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc --with-esx=yes.
The above command does not include Xen support; if you need Xen support, you’ll need to add
--with-xen=yesto the command, and your list of prerequisite packages will change (there are additional packages you’ll need to install).
configurecommand completes, then complete the process with
make install. Note that I used
sudo make installhere because I’m installing files into privileged system locations.
Finally, to verify that everything seems to be working as expected, restart libvirt with
initctl stop libvirt-binand
initctl start libvirt-bin. (Yes, you could use
initctl restart, but this allows you to see the clean stop and start of the libvirt daemon.) As an aside, note that this step only works if you either a) had a previous version of libvirt installed, or b) create the
initctljob for libvirt. I chose the first approach.
As a final verification step, run
libvirtd --versionto verify that you’re running libvirt 1.0.0.
That’s it! Now, as others have pointed out, this will create some potential system administration challenges, in that
apt-get will still suggest new libvirt packages to install when you try to update the system. I think that there are some commands you can run to keep the manually compiled version instead of the version
apt-get is suggesting, but I haven’t yet determined exactly which commands to use. (If you have more information, please speak up in the comments!)
I have a series of new libvirt-related blog posts in the works, so stay tuned for those. In the meantime, feel free to post any questions, corrections, or clarifications in the comments below. Courteous comments are always welcome.Tags: Interoperability · Libvirt · Linux · OSS · Ubuntu · Virtualization Previous Post: Layer 3 Routing with Open vSwitch Next Post: A Quick Warning About Compiling libvirt