Linux KVM on FreeBSD

Description

Linux KVM (Kernel-based Virtual Machine) is a software package that can be used to create virtual machines fully emulating x86 hardware on top of machines supporting Intel VT-x or AMD-V virtualization extensions, available on newer AMD and Intel processors, e.g., recent Athlon64, Core 2 Duo, Xeon and so on.

Linux KVM has been ported to FreeBSD as a loadable kernel module, using the linux-kmod-compat port (in /usr/ports/devel/) to use as much as possible of the original source code, plus an userspace client consisting in a modified version of qemu, that uses KVM for the execution of its guests.

The porting started as a Google Summer of Code 2007 project, its original page is available here.

Project Status

The porting is completed, even if the code is not in sync with mainline KVM, and has been tested on a limited set of configurations, with FreeBSD-CURRENT both as an host (on Intel and AMD processors, on 32 and 64 bit installations,) and a guest. By now multiple clients are not supported.

To move on more testing is needed, and any kind of feedback in this sense will be appreciated.

Trying the Code

The latest source code is available through git, to clone it you can use:

> git clone git://feanor.sssup.it/lkvm.git

It can also be browsed using the git web interface. Snapshots of the project are available for testing, the latest one can be downloaded from here.

In order to compile the source code the build dependencies for qemu have to be installed, the best way to get them is to build and install qemu from /usr/ports/emulators/qemu/. To compile KVM the needed commands are the following:

> tar -xzf lkvm-xxxxxxxx.tar.gz > cd lkvm-xxxxxxxx/kvm-17 > ./configure > gmake > cd ../lkvm > make -f Makefile.kld KERNBUILDDIR=<path-to-smp-build>

To execute it, as root:

# kldload ./lkvm.ko ./svm.ko # <path-to-qemu-system-x86-64> <options>

Last updated October 4th, 2007