From Sabayon Wiki
Revision as of 12:00, 17 March 2013 by Inktvis75 (Talk | contribs) (first submit)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
i18n: en


KVM (for Kernel-based Virtual Machine) is a full virtualization solution for Linux on x86 hardware containing virtualization extensions (Intel VT or AMD-V). It consists of a loadable kernel module, kvm.ko, that provides the core virtualization infrastructure and a processor specific module, kvm-intel.ko or kvm-amd.ko.

Qemu is the virtual machine monitor (VMM), to provide virtual machine hardware.

Libvirt is a layer providing a hypervisor agnostic management layer and api between the hypervisor and a management tool like virsh and virt-manager.

Virt-manager is a graphical tool to configure and manage storage, network and virtual machines.


These instructions assume that you have enough rights to install software. In this howto I am using the sudo mechanisme (Sabayon default: the user is a member of the wheel group).

Install qemu, libvirt and virt-manager:

# sudo equo install qemu libvirt virt-manager


The kvm module exports a device called /dev/kvm. By default the permissions on the device /dev/kvm are not enough to use KVM as a non-privileged user. You can correct this to change the group owner of this device to the group kvm.

# sudo chown root:kvm /dev/kvm

# sudo chmod 660 /dev/kvm

And make a user a member of this group:

# sudo gpasswd -a <user> kvm

Also qemu must be a member of the kvm group:

# gpasswd -a qemu kvm

This solution is not persistent across reboots, for that you have to create an udev rule: /etc/udev/rules.d/65-kvm.rules

KERNEL=="kvm", NAME="%k", GROUP="kvm", MODE="0660"

If you are using virt-manager as a normal user, you're still not able to access libvirt. You have to create a polkit rule to make this possible. Create a file /etc/polkit-1/rules.d/51-libvirt.rules

polkit.addRule(function(action, subject) {
   if ( == "org.libvirt.unix.manage" &&
       subject.user == "<user>") {
       return polkit.Result.YES;

Don't forget to replace <user> with your own username!

Getting started

Start the libvirtd daemon and add it to the default runlevel, so it will started at boot.

# sudo /etc/init.d/libvirtd start
# sudo rc-update add libvirtd default

It's not the purpose of this article to explain KVM and networking, but to getting started and provide networking to the virtual machine via NAT:

1) Start virt-manager for the first time. If there popups a question about installing the KVM packages: ignore it. A connection to the localhost will be made.

2) Go to the menu-item "Edit" and select "Connection Details"

3) Select the tab "Virtual Networks", click on the plus-sign.

4) Choose a name for the virtual network, accept the suggested IPv4 range or fill in another private range ( and enable DHCP. Connect to the physical network (the network of your physical host) by forwarding the virtual network traffic to the destination "Any physical device", mode: NAT.

It's also not the purpose of this artice to explain KVM and networking, but it's a good idea to have a iso library. The best way to do this:

# sudo mkdir /iso
# sudo chmod -R g+rwx /iso
# sudo chmod -R o+rx /iso
# sudo chgrp -R qemu /iso

And add it to the storage pool in virt-manager