Speed up QEMU with KVM

  • February 24, 2008
  • Avatar for jacob
    Jacob
    Peddicord

If you have been using QEMU for emulating other operating systems, you will find that it runs fairly slow. QEMU does not take advantage of your hardware to speed anything up, so all of the load comes from translating between processors. On average, QEMU will only run at about 20% of the speed of your host system.

Obviously, this is a problem. If you want reliable testing of any OS in a virtual machine, you'll want it to run at near-full speed. This is where KVM comes in. No, not those hardware input switches, but rather the Kernel-based Virtual Machine. KVM allows you to take advantage of your processor to achieve near-native speeds.

None of this comes without a catch, however. First off, KVM only allows you to emulate and run on x86 and x86_64 systems. Second, your processor must support it. To check, run the following command, taken from the KVM package itself:

egrep '^flags.*(vmx|svm)' /proc/cpuinfo

If you don't get anything from that command, you might as well stop reading. But if you get a line or two with a bunch of seemingly random words, then you're all set to run KVM.

The neat thing about KVM is that it works as a drop-in replacement for QEMU. So, if you were running QEMU from the terminal to begin with, all you have to do is replace qemu with kvm.

When running kvm in a terminal, you may get a "permission denied" error. To fix this, add yourself to the kvm group:

adduser username kvm

You can also chmod 0777 /dev/kvm if you are the only user on the system or do not care who has access to it.

If you are using Qemu Launcher or another GUI, all you have to do is change the path to QEMU from /usr/bin/qemu to /usr/bin/kvm. There you have it, now go run your VMs in full speed!

Avatar for jacob Jacob Peddicord

Home » Articles »