Testing new libvirt features on Ubuntu 12.04

If you are like me and you want to experiment with cutting edge virtualization technologies on LTS version of Ubuntu(12.04 aka Precise Pangolin), you will soon find out that this is not so easy. But, of course, it is still possible. First of all, keep in mind that to achieve this, you will be turning your stable LTS system into unstable one and I can’t guarantee that everything will work as expected or work at all. You have been warned… 🙂

When I first decided that I want live snapshooting to be able to backup my virtual machines, I was disappointed that Ubuntu 12.04 LTS doesn’t offer this feature yet. I even doubt that we will see libvirt version with live snapshooting support before next LTS release. So I decided to compile the new libvirt version myself. I have used Scott Lowe’s post on the subject. Sadly, this plan didn’t work out. The system proved to be too unstable. During my testing something constantly broke. It was real dependencies’ hell like in early years of Linux.

This failure didn’t discourage me and I decided to get the packages from the current development release aka Raring Ringtail. Raring’s repositories contain already the latest 1.0.2 version of libvirt. Just what we need. By the way, one post proved really useful in the process: Ubuntu Precise – Install youtube-dl package using Quantal repo by Milosz Galazka.

To begin with, we will need to open /etc/apt/apt.conf.d/00release and add following text there:

APT::Default-Release "precise";

This way we are telling for aptitude that we would like to stay on Precise Pangolin release. To be able to use Raring Ringtail packages on Precise system, add Raring repository to /etc/apt/sources.list:

deb http://de.archive.ubuntu.com/ubuntu/ raring main restricted universe multiverse

Now update package list as usual:

apt-get update

Be sure to upgrade the system to up to date state, before proceeding any further:

apt-get upgrade

Now you will need to create a new file /etc/apt/preferences.d/libvirt and add fill it with following content:

Package: libvirt-bin
Pin: release a=raring
Pin-Priority: 990

Package: libvirt0
Pin: release a=raring
Pin-Priority: 990

Package: python-libvirt
Pin: release a=raring
Pin-Priority: 990

Package: qemu
Pin: release a=raring
Pin-Priority: 990

Package: kvm
Pin: release a=raring
Pin-Priority: 990

Package: libc6
Pin: release a=raring
Pin-Priority: 990

Package: libgnutls26
Pin: release a=raring
Pin-Priority: 990

Package: libnl-3-200
Pin: release a=raring
Pin-Priority: 990

Package: libnih-dbus1
Pin: release a=raring
Pin-Priority: 990

Package: libnih1
Pin: release a=raring
Pin-Priority: 990

Package: libnetcf1
Pin: release a=raring
Pin-Priority: 990

Package: libnl-route-3-200
Pin: release a=raring
Pin-Priority: 990

Package: qemu-system
Pin: release a=raring
Pin-Priority: 990

Package: qemu-utils
Pin: release a=raring
Pin-Priority: 990

Package: qemu-user
Pin: release a=raring
Pin-Priority: 990

Package: qemu-system-arm
Pin: release a=raring
Pin-Priority: 990

Package: qemu-system-mips
Pin: release a=raring
Pin-Priority: 990

Package: qemu-system-ppc
Pin: release a=raring
Pin-Priority: 990

Package: qemu-system-sparc
Pin: release a=raring
Pin-Priority: 990

Package: qemu-system-x86
Pin: release a=raring
Pin-Priority: 990

Package: qemu-system-misc
Pin: release a=raring
Pin-Priority: 990

Package: libspice-server1
Pin: release a=raring
Pin-Priority: 990

Package: libxen-4.2
Pin: release a=raring
Pin-Priority: 990

Package: qemu-system-common
Pin: release a=raring
Pin-Priority: 990

Package: qemu-keymaps
Pin: release a=raring
Pin-Priority: 990

Package: liblzma5
Pin: release a=raring
Pin-Priority: 990

Package: vgabios
Pin: release a=raring
Pin-Priority: 990

Package: seabios
Pin: release a=raring
Pin-Priority: 990

I got this list by trial and error and hopefully you will be able to save some time. Now you can run apt-get upgrade once again and install everything what is offered. But I wasn’t been able to install everything what I needed:

The following packages have been kept back:
 libc6 libgnutls26 libnl-3-200 libvirt-bin libvirt0 linux-headers-server linux-image-server linux-server python-libvirt qemu qemu-keymaps qemu-system qemu-user qemu-utils

But we shouldn’t encounter any problems, when installing this way:

apt-get install libvirt-bin
apt-get install qemu
apt-get upgrade

Normally you would think that that’s it. Everything is installed, dependencies are satisfied and we could proceed to experiment with libvirt, right? Wrong! When you try to run virsh version, you will see this cryptic error message:

Compiled against library: libvirt 1.0.2
 Using library: libvirt 1.0.2
 Using API: QEMU 1.0.2
 error: failed to get the hypervisor version
 error: internal error Child process (LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin /usr/bin/qemu-system-x86_64 -help) unexpected exit status 127: /usr/bin/qemu-system-x86_64: symbol lookup error: /usr/bin/qemu-system-x86_64: undefined symbol: rbd_aio_discard

Apparently, we have just encountered the Debian bug #680307 and because of it not every dependency was truly satisfied. To fix this, I added two more packages to the same file:

Package: librbd1
Pin: release a=raring
Pin-Priority: 990

Package: librados2
Pin: release a=raring
Pin-Priority: 990

And run:

apt-get install librbd1

Now everything was looking truly fine, virsh version was showing nice and predictable results, so I decided at this point that this is a good time to reboot the test machine and see, if everything is really as good as it looks. Well, it wasn’t. I had no kernel to load from! Somehow few critical packages were deleted during libvirt/qemu upgrade process and the kernel wasn’t rebuild properly. Of course, I was able to boot from LiveCD and rescue my system, but to avoid my mistake, just install linux-image-server before rebooting your system.

But at that moment I actually was thinking something like “what the heck? Why can’t I use a new kernel with all the nice security updates and new features?” and I ended up installing the kernel from Raring distro. To achieve this, just add following lines to the same file we were using(/etc/apt/preferences.d/libvirt):

Package: libnl-genl-3-200
Pin: release a=raring
Pin-Priority: 990

Package: crda
Pin: release a=raring
Pin-Priority: 990

Package: linux-image-server
Pin: release a=raring
Pin-Priority: 990

Package: linux-image-generic
Pin: release a=raring
Pin-Priority: 990

Finally run apt-get install linux-image-server/raring. The system should be safe now. You can recheck your /boot directory, just to be sure that the kernel is really present there. Of course, at this point you will have not a real Precise Pangolin Ubuntu system, but a Precise/Raring hybrid and may be, just may be, it would make more sense to migrate to Raring completely. But I have no answer to this question yet, I am just beginning to test the system and only time will actually tell.

Upd. (2013-03-18): Additional info.

4 thoughts on “Testing new libvirt features on Ubuntu 12.04”

Leave a Reply

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

Are you human? *