Some experiences with KVM

Posted on Sun 01 May 2011 in Linux

On my workstation I am running Fedora and KVM for testing some Linux based configurations. It's an AMD based system with 2 x Dual-Core AMD Opteron(tm) Processor 2216, 8Gb of Ram and normal SATA hard discs. Works still o.k for everything I am experimenting with and has enough power to run a few virtual machines with no impact on the host systems normal stuff.

As you can see I run different Linux distributions for testing and a FreeBSD installation as well. Screenshot-Virtual Machine Manager

If there is a limitation of performance in the most cases it's I/O limitation because of slow SATA discs and a cheap raid controller or board chipset. I still have no SSD bought because I work on my Laptop most of the time and there is no need to pimp this machine for the things I am doing with it. Maybe if you run some I/O intensive applications this can boost your system but I will maybe test this in the next weeks or month and report my experiences here. I know it from my Mac Book when I use VMware Fusion or Virtual Box it's o.k for doing some normal testing in your VM but if you want to run more virtual machines and still want to use you host system with fast responding you will become old while waiting on changing from virtual machine to virtual machine or check you emails and things like that. Everything on your computer gets really slow if you use such a solution in a more professional way.

My experiences with KVM and all my Linux based virtualization stuff are quite positive up to now. I am compiling quite often some software packages within my Gentoo and FreeBSD without bigger impact on the speed of my desktop applications or hanging mouse effect. Only thing I don't use at the moment is a graphical interface within my VMs, because I don't need it. As I wrote before which makes the system slow is big I/O on the disc. If you start some copy jobs in more virtual machines you see the discs coming under stress.

One of the next things I want to test is how the system works with an Windows 2008 R2 virutal machine. I virtualized Windows on XEN before and it works good. The Xen Hypervisor is sill a good solution and a powerful peace of software. In my eyes the negative point was that it wasn't pushed like KVM for its kernel integration. And now after RedHat started to create a powerful toolset around KVM the marked will change again.

For me KVM will be my OSS solution for the next time because of its integration within the Linux kernel. I hope there will be some powerful solutions built around this core and it will become a mature and secure solution.

If you want to know how to install KVM on Fedora you can use the CentOS tutorial I wrote some time ago.

For console administration you can use the virsh command shell:


with this command you enter the virsh shell. To see all command available type help. In the default configuration your configuration files for your virtual machines are located in /etc/libvirt/qemu. To start just use virsh create <configuration_file>, for example:

virsh create Fedora-Minimal.xml

or with full path:

virsh create /etc/libvirt/qemu/Fedora-Minimal.xml

To check if the machine is active use:

virsh list

The output looks something like that:

Id Name                 State
1 Fedora-Minimal       running

I use VNC and ssh X forwarding to connect to the host machine from remote and use the guest machines console. First check which display id your virtual machine has.

virsh vncdisplay Fedora-Minimal

In this case it's the only running machine so it has display :0

Run the vncviewer command if you already have connected via ssh with the -X option.

vncviewer :0

Now on your administration machine should open a vncviewer window like you see it in the screenshot. This should work on every Linux and Mac OS X system out of the box. If you are on Windows you need to install a X server and configure Putty to use X forwarding.

VNCViewer Window which shows virtual machine output

Over slow connections this can be a bad solution. There is also an option only to see the console but therefor you need to add some kernel parameter to the guest systems boot configuration. Edit the /boot/grub/menu.lst and add this option at the end of your kernel options:

console=tty0 console=ttyS0,11520

Here an example menu.lst:

# grub.conf generated by anaconda
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_proxy-lv_root
#          initrd /initrd-[generic-]version.img
title Fedora (
root (hd0,0)
kernel /vmlinuz- ro root=/dev/mapper/vg_proxy-lv_root rd_LVM_LV=vg_proxy/lv_root rd_LVM_LV=vg_proxy/lv_swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=de-latin1-nodeadkeys rhgb quiet console=tty0 console=ttyS0,115200
initrd /initramfs-

Now you can use the virsh console command to open a shell. Example:

virsh console Fedora-Minimal