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 9 “stretch”. 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

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 dedicated server with 16GiB that means 7500 is probably a reasonable number of hugepages.

Do the math for your own system and add hugepages=7500 to GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub.

Then run:

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 (due to fragmentation). In that case rebooting is the only way to effect the desired number of hugepages.

Systems without /dev/hugepages

If your system does not mount hugetlbfs by default (check the output of mount if you don't know), you'll have to mount it yourself.

Add this line to your /etc/fstab:

hugepages  /dev/hugepages  hugetlbfs  defaults

Then run these commands:

mkdir /dev/hugepages /lib/udev/devices/hugepages
mount /dev/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

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