From Sabayon Wiki
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:

# 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.

# chown root:kvm /dev/kvm

# chmod 660 /dev/kvm

And make a user a member of this group:

# 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.local
           && subject.isInGroup("libvirt")) {
       return polkit.Result.YES;

Create a group: libvirt and add user to this group:

# groupadd libvirt
# gpasswd -a <user> libvirt

Getting started

Start the libvirtd daemon and make it started at boot.

# systemctl enable libvirtd 
# systemctl start libvirtd

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 an shared library with ISO files. The best way to do this:

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

And add it to the storage pool in virt-manager.