My new Dell Latitude E6400 laptop, is my first system which support hardware visualization. It also has 4 GB RAM, making this an ideal machine to start experimenting with KVM, the kernel based virtual machine system which is now integrated in Linux itself.
In the past I had already used different virtualization systems. VMWare Server is annoying because you have to rebuild the kernel modules by hand each time you install a new kernel and it’s not Free (as in Free Speech). Virtualbox handles the modules rebuild nicely thanks to the use of DKMS in Mandriva, but always randomly crashes on an assert, making it totally unusable for serious work. Also it does not really include a server mode, where virtual machines just run in the background. Xen is especially nice if you have a system which does not support hardware virtualization and you just want to run a paravirtualized Linux in it. However, the host system (Dom0) needs to run a very specific kernel version (normally version 2.6.18, although Debian has a 2.6.26 based one now). OpenVZ is nice for lightweight Linux server containers (some kind of chroot on steroids), but is not a complete virtualization solution.
Because KVM is built into the standard Linux kernel, this means there won’t be any problems with kernel modules which have to be installed separately. It’s a complete virtualization system which means that you can run all kind of operating systems on it, like for example also Windows. KVM is evolving very quickly and its performance and features are constantly improving. Thanks to libvirt and virt-manager, it also has a nice GUI front-end which make configuring and managing virtual machines very easy (libvirt and virt-manager also include support for Xen and OpenVZ, but I don’t know how well that works).
Installing and using KVM on Mandriva 2009.0
Before installing KVM, it’s important to verify that the CPU on your system has hardware virtualization support. Start up a terminal, and run
$ cat /proc/cpuinfo
If you have an Intel CPU, you should have vmx in the flags. If you are using an AMD CPU, you should have svm.
It’s best to use KVM, libvirt and virt-manager from Mandriva’s backports repositories. The versions included there, are the most recent ones, and fix a few problems which made networking not work out of the box with the ones included in the standard repositories. So start up the Mandriva Control Center (Tools – System Tools – Configure Your Computer), and in the Software category, launch the media sources configuration tool and enable the Main Backports and Contrib Backports sources by checking the checkboxes.
Before we install the necessary packages, it’s necessary to make a change to udev’s configuration file to prevent the virbr* and vnet* virtual ethernet devices and bridges being configured automatically by Mandriva’s configuration tools. To do so, edit the file /etc/sysconfig/udev_net and add virbr* and vnet* to the BLACKLIST_ALL line if they are not there yet. The line should look like this:
Then install the kvm and virt-manager packages with the graphical software installation utility or with urpmi. Some extra dependencies will be installed, such as dnsmasq-base, libvirt-utils and python-virtinst.
After the installation, make sure that the libvirtd service is running. You can use the graphical tool in the Mandriva Control Center in the category System – Manager system services, or you can run “service libvirtd status” to verify whether it’s running and “service libvirtd start” to start it.
Now start the Virtual Machine Manager from Tools – Emulators. Choose File – Add Connection and set up a Local QEMU connection. Double click on the localhost/qemu connection in the virtual machine manager, and enter your root password. You can now create new virtual machines by clicking on the New button. To use KVM, choose a fully virtualized system, and choose KVM as hypervisor. If you want to run Mandriva 2009.0 or later in a KVM based virtual machine, you can probably choose Linux as OS type and Ubuntu Hardy as OS variant, because that should give better performance than the generic options.
I currently have Windows Vista and Debian Lenny running in KVM. It works very fast and very reliably. The only problem I encounter, is that sometimes I cannot switch back from my Windows virtual machine to my host system: the mouse and keyboard cannot leave the VNC window anymore and also the Ctrl-Alt keystroke does not release the mouse pointer. The only solution is to shut down the Windows system.