Slow VM installation on KVM

I had this issue with KVM (CentOS EL 6.4) so I ran a benchmark to find out what was happening. Turns out my guest VM was running only 15% as fast as the host (bare metal OS). I had checked the prerequisites of kvm and verified my Intel processor has the VT-x (vmx) [AMD calls it svm].

cat /proc/cpuinfo | grep vmx

Why then the slow performance?? Turns out that I needed to enable VT-x in the BIOS of the system (older machine circa 2006). To verify that this was the problem, I checked to see if kernel module kvm_intel was running:

lsmod | grep kvm

Turns out that it was not running with kvm_intel. When I had installed my virtual machine, libvirt defined the domain type as qemu. But this should be type kvm. You can check:

virsh edit your_vm_guest_domain

... check the line at the top ...

<domain type='qemu'>

That was libvirt telling me it didn't detect the kvm_intel presence on my system and defaulted to plain qemu emulation.

When I enabled the VT-x in the BIOS, I found that I could load the kvm_intel module and then changed the <domain type='kvm'>. I executed the same benchmark again and found virtually no difference in speed between the guest VM and the host OS.


The default disk cache mode is writethrough, which is very slow. Switch the disks to writeback mode and you will enjoy a very significant I/O performance boost.

Before someone complains about that: with relatively recent (CentOS 6+) libvirt/qemu/kvm versions, writeback disks are safe unless the guest OS does not support/activate write barriers (which are supported and enabled by any recent guest OS I can think of).

Some more information can be found here and here