Bog Roll ::

It's Not Magic, It's Work!

05 Jul 2009

Kernel-based Virtual Machine

I've long used Fabrice Bellard's excellent QEMU system emulator. It's slow but complete, so you can emulate a SPARC system on an AMD64 for example. As long as your host system is fast you can emulate a wide range of other systems acceptably.

Fabrice also released a QEMU accelerator called KQEMU, basically a kernel plug-in that allows QEMU to drop all none guest-kernel calls through to the host CPU unemulated. The upshot is that if you have an x86 CPU host system you can run a x86 guest system on top with nearly real time performance. The rest of the system is still emulated, so graphics isn't fast but it's great for servers.

On the desktop I've been using Sun's VirtualBox which I find faster when running graphical guest systems than QEMU/KQEMU. It also has a nice GUI so it's easier to play with - QEMU is all command line, which is fine once you have it configured but not as easy for dabbling.

This week I thought I try out KVM, which is a mainline Linux kernel plug-in that works with newer AMD/Intel CPUs only. Basically it creates a generic interface that other user-land virtualisation systems can take advantage off. In practice you install KVM into your kernel then basically use QEMU for the rest of the virtual host system. In theory KVM+QEMU should be marginally faster than KQEMU+QEMU on compatible hardware, however you can't use it older CPUs so you need to use KQEMU on them.

It took a few goes to get it working, but so far on my server which has the right hardware, it looks pretty good, marginally faster than KQEMU with lower CPU load on the host system. It's another interesting technology to have to play with.

QEMU is really good stuff, not only is it usable on it's own, but it's the extendible with both KQEMU or KVM and even VirtualBox uses large chunks of it! Open source is great!