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.01 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. -
Using
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. I’ve line-wrapped it here for readability: -
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). -
Once the
configurecommand completes, then complete the process withmakeandmake install. Note that I usedsudo 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-binandinitctl start libvirt-bin. (Yes, you could useinitctl 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 theinitctljob for libvirt. I chose the first approach. -
As a final verification step, run
virsh --versionorlibvirtd --versionto verify that you’re running libvirt 1.0.0.
./configure --prefix=/usr --localstatedir=/var \ --sysconfdir=/etc --with-esx=yes
make sudo make install
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, Linux, OSS, Ubuntu, Virtualization
-
Scott,
Nice writeup! With all of the apt challenges that get added in with compiling your own apps on any debian based distro, I tend to stick with known good repos or build my own .deb packages to try at least to keep my servers aware of potential issues.
It’s just a matter of time before the ubuntu virtualization team has 1.0 packaged up, and I tend to leverage this repository heavily:
-
Well, I figured it out and installed libyajl-dev afterwards, but as my second comment said, libvirtd initialization failed. I checked the log, and found(ignored warnings and duplicated errors):
2012-11-08 09:49:02.728+0000: 4256: error : networkCheckRouteCollision:2036 : internal error Network is already in use by interface br0
2012-11-08 09:49:02.785+0000: 4256: error : virExecWithHook:419 : Cannot find ‘pm-is-supported’ in path: No such file or directory
For the network part, I added a br0 and eth0 to it.
-
For the ‘pm-is-supported’ error, I got https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/994476/comments/2
The first error is related to the configuration of ovs. I managed to solve it, but haven’t got a clear idea about it.
And a new question comes to me: is it OK to first install a lower version libvirt using apt-get and then manually compile a new one to replace it? Have you met any problems related to this approach?
-
I don’t seem to have any daemon named libvirt-bin. Is this a problem?
I can start libvirtd daemon through “sudo libvirtd -d” though.
-
hi?i want to know when i shut down or reboot the host?and how libvirt or OS deal with the vms on this host?
-
Thank you for your post. It proved really useful. Here is complete list of packages I needed to install, before I was able to compile libvirt on completely new system: “libcurl4-gnutls-dev libncurses5-dev libdevmapper-dev libxml2-dev libnuma-dev libpciaccess-dev python-dev libnl-dev”.
As of my experience with compiled libvirt… Well, I wouldn’t consider using it in production environment. Ubuntu proved to be quite unstable, with library problems now and then, with libvirt compiled this way. But maybe it was “checkinstall” package’s problem(I used it, because I wanted to be able to remove all the components easily, but checkinstall has failed few times, leaving various unneeded files behind). Anyway, for test/development environment it can be useful to test new features, but for the production environment the downside is too big. -
I have created a Video for newbies to show How to Compile and Install libvirt 1.0.0 on Ubuntu
-
Is there a way to enable xen (–with-xen=yes) after installing using yum install in fedora-18?
-
Scott said in the post above:
“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!)”The command to “freeze” a package (prevent it from being updated) is:
(sudo) apt-mark hold [package_name]For instance, I have the following libvirt packages on my Ubuntu 12.04 system:
root@server:~# dpkg -l | grep libvirt
ii libvirt-bin 0.9.8-2ubuntu17.7 programs for the libvirt library
ii libvirt0 0.9.8-2ubuntu17.7 library for interfacing with different virtualization systemsI can see their update status by issuing the command:
root@server:~# dpkg –get-selections | grep libvirt
libvirt-bin install
libvirt0 install(status “install” means “update”)
So then we can set them to “hold” status (meaning “do not update”):
root@server:~# apt-mark hold libvirt-bin
libvirt-bin set on hold.
root@server:~# apt-mark hold libvirt0
libvirt0 set on hold.Then to confirm:
root@server:~# dpkg –get-selections | grep libvirt
libvirt-bin hold
libvirt0 holdNow they will not be updated any longer (unless the hold is removed.)
-
Trying to compile I get this issue (from git version)
CCLD virnettlscontexttest
/usr/bin/ld: virnettlscontexttest.o: undefined reference to symbol ‘gnutls_x509_crt_set_activation_time@@GNUTLS_1_4′
/usr/bin/ld: note: ‘gnutls_x509_crt_set_activation_time@@GNUTLS_1_4′ is defined in DSO /usr/lib/x86_64-linux-gnu/libgnutls.so.26 so try adding it to the linker command line
/usr/lib/x86_64-linux-gnu/libgnutls.so.26: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make[2]: *** [virnettlscontexttest] Error 1



15 comments
Comments feed for this article