I’ve been receiving a lot of questions lately from people wanting to use libvirt with virsh and not wanting to use a GUI (e.g. virt-manager). They’ll get gung-ho and install libvirt and start up virsh and be confronted with an error almost right away. Obviously from a user perspective, this is a bad experience so I think a little background is in order.

libvirt runs in two modes called system and session. These terms are identical to D-Bus so if you are familiar with that just think in those terms. If not, system is the instance that runs as a system daemon. It has an init script at /etc/init.d/libvirtd and will run as root. The session instance runs as a normal user. It is not started at boot time but dynamically by someone using virsh. The default when running virsh as root is to connect to the system instance. The default when running virsh as a normal user is to connect to the session instance. This is why people say their virtual machines have disappeared or they can’t connect typically. There are four ways to connect to the system instance as a normal user:

  • virsh -c qemu:///system
  • virsh and at the prompt connect qemu:///system
  • export LIBVIRT_DEFAULT_URI=qemu:///system and running virsh
  • edit /etc/libvirt/libvirt.conf and set uri_default=qemu:///system

Now if you haven’t built libvirt with PolicyKit support, by default only root will be able to communicate with the system instance. You will have to edit /etc/libvirt/libvirtd.conf and change unix_sock_rw_perms to something more open like 0770 or 0777 (the former will require changing unix_sock_group to a group your user is part of). Then restart libvirtd to get the new permissions.

The last issue to befall people relates to libvirt’s recent switch to using XDG_RUNTIME_DIR and XDG_CONFIG_HOME from the XDG Base Directory Spec. The defaults for these are $HOME/.cache/ and $HOME/.config/ respectively. The issue that gets people is that your X session manager creates these directories for you if they don’t exist but libvirt does not. So for people logging into a user that never uses X, they won’t have these directories. As a result when exiting virsh you will get an error that it couldn’t save your command history. Additionally you will not be able to start a session instance without these directories present. The simplest fix is to just do mkdir $HOME/{.cache,.config} and all should be well. Note: This last issue is now resolved for the forth coming 0.10.0 release.

Users of qemu-kvm may have noticed that as of 0.15.1 it has a new dependency on sys-apps/seabios from the Coreboot project. Previously we used the pre-built versions that shipped with qemu-kvm, however this version is typically out of date and has recently caused problems for some users. Ubuntu and Fedora have switched to not using the pre-built versions and building their own versions of all the binary blobs recently as well so for Gentoo we’ll do the same. The issue however is that some of these can only be built with a x86 toolchain so we will have to come up with a solution for ppc. Any suggestions are welcome.

kvm changes in Gentoo

November 22, 2009

Since I got saddled with maintaining kvm without really having the desire (I use it but not all that often) and not really having the time to maintain it, I asked for someone to take over maintainership. Unfortunately I didn’t get any replies so the package has remained fairly unmaintained and dead-ish. Well I’ve decided today to take some time and clean it up a little bit and get it up to speed a little. However, this means that there are some changes coming.

We will use qemu-kvm releases and will no longer rename everything to make it play nicer together. External kernel modules won’t be supported and you’ll be expected to build the right settings into the kernel. If you want to use the external kernel modules, that’s up to you. qemu and qemu-kvm will be blockers since they will overlay greatly.

Really the optimal thing would be for a group of people to take over kvm and qemu and maintain them together.


Get every new post delivered to your Inbox.