Setting up a kavoom host

Kavoom is a thin wrapper around the kvm binary. It provides a command line driven management interface to kvm without running any additional daemons. See the project page.

Table of contents

The operating system

This manual assumes you run Debian GNU/Linux 7 “wheezy”. Instructions for installing the operating system are outside the scope of this document, but it is strongly recommended that you:

Installing the software

Add the repositories as explained on the main kavoom page. Then:

apt-get install kavoom

Preparing the network

Make sure you're not logged in over the network (as we're going to reconfigure it) and:

ifdown eth0

Edit the file /etc/network/interfaces and replace all occurrences of eth0 with br0. Add the following lines to the stanza:

    bridge-ports eth0
    bridge-fd 0
    bridge-maxwait 0

The final result should look something like:

auto br0
iface br0 inet static
    bridge-ports eth0
    bridge-fd 0
    bridge-maxwait 0
    address 192.0.2.2/24
    gateway 192.0.2.1

Now bring the network up again:

ifup br0

And you're done! You now have a fully functional VM host. You could read the user manual to set up your first VM.

Some optional but recommended tweaks

Using hugepages

Hugepages are a more efficient way to manage memory. If your host is a dedicated VM host, you can reserve a chunk of memory for use as hugepages. Kavoom will automatically pick this up and will tell KVM to allocate its memory from that chunk.

Hugepages are 2MiB in size, and you need some space for the OS itself. On a server with 16GiB that means 7500 is a reasonable number of hugepages.

Add hugepages=7500 to GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub.

Then run:

update-grub
mkdir /lib/udev/devices/hugepages

And add this line to your /etc/fstab:

hugepages  /dev/hugepages  hugetlbfs  defaults

If you don't like to reboot to make these changes take effect, you can run these commands:

mkdir /dev/hugepages
mount /dev/hugepages
sysctl -w vm.nr_hugepages=7500

However, that last command is likely to fail if your server has been up and running for a while. In that case rebooting is the only way to effect the desired number of hugepages.

Using scheduling groups

Note: unfortunately the linux kernel does not allow two separate cgroup mountpoints, and systemd mounts one as well. That means that you should not follow the instructions below if on a systemd distribution. The way systemd handles this is actually much nicer but I just haven't gotten around to writing the integration.

Scheduling groups (also called cgroups) are a fairer way to distribute the CPU over VMs. It prevents one VM from hogging the CPU by creating a large number of threads. To use scheduling groups with kavoom, create a file /etc/kavoom/wrapper:

#! /bin/sh

set -e

group=/dev/scheduler/vm_$kavoom_name
mkdir -p "$group"
echo $$ >"$group/tasks"

exec kvm "$@"

This puts every VM in its own scheduling group when it starts.

To make this script active, append the following line to /etc/kavoom.cfg:

kvm = /etc/kavoom/wrapper

You also need the /dev/scheduler filesystem, so put this in /etc/fstab:

scheduler  /dev/scheduler  cgroup  cpu

And run the following commands once:

chmod 755 /etc/kavoom/wrapper
mkdir /dev/scheduler /lib/udev/devices/scheduler
mount /dev/scheduler

Back to the index page

mail me