Thursday, 3 March 2011

Should I use QEMU or KVM?

UPDATE: The qemu-kvm.git fork has been merged back into qemu.git as of QEMU 1.3.0. Always use qemu.git for the latest code. See my full post here.

"What is the difference between QEMU and KVM?" comes up regularly because these two pieces of software share a close relationship. I am going to explain how to choose between the two and the nature of their relationship.

Should I install the qemu or qemu-kvm package?

If you want to run x86 virtual machines on x86 physical machines, install qemu-kvm. It has the fastest and most thoroughly tested support for the common x86 virtualization use case.

If you want to run anything else, install qemu. That includes running non-x86 machines and user level emulation instead of full-system emulation.

If you are still not sure which is right for you, take a look at the QEMU and KVM websites.

How do I check that qemu-kvm is using hardware support?

If qemu-kvm is unable to use hardware virtualization extensions it will fall back to emulation which is much slower. If you are worried this might be the case, run the following check:

grep 'svm\|vmx' /proc/cpuinfo

If you get output then the CPU supports virtualization extensions and KVM should work. Otherwise check that virtualization is enabled in your BIOS.

See the processor support KVM wiki page for more information.

It is also a good idea to use the -enable-kvm command-line option to ensure that KVM is used. The libvirt, virt-manager, virsh stack will do this by default.

What is the difference between qemu.git and qemu-kvm.git?

The QEMU codebase is known as qemu.git. That's the git repository that holds the QEMU source code history. The KVM codebase is known as qemu-kvm.git, the git repository that holds the KVM source code history.

The relationship between qemu.git and qemu-kvm.git is as follows. qemu-kvm.git is a fork of qemu.git and periodically merges updates from qemu.git back into qemu-kvm.git. A lot of code changes are merged into qemu.git and become available in qemu-kvm.git after the next periodic merge. KVM-specific enhancements may be merged into qemu-kvm.git and may be sent back upstream to qemu.git.

Efforts are underway to completely merge qemu-kvm.git into qemu.git. This will make qemu-kvm.git obsolete and result in a single codebase. In the future there may only be a qemu package.


  1. Can qemu-kvm run without kvm and vice-versa ?
    I saw 2 git repository at : kvm.git and qemu-kvm.git which stand for "kvm kernel code" and "kvm userspace code" respectively.
    What relationship between these two git ?

  2. You can do qemu-kvm -no-kvm. If you really want dynamic binary translation instead of virtualization then it's probably best to use regular qemu though.

    The KVM repositories to look at are:;a=summary;a=summary

    The first is the linux.git fork where the latest kvm.ko kernel module changes are merged. Linus pulls this into linux.git - this is how KVM kernel changes get merged into Linux.

    The second is the qemu-kvm.git repository - forked from qemu.git. This is the userspace code that gives you the qemu-kvm program.

    Nowadays the KVM kernel support is mature enough that you rarely need to build kvm.git, just use the kvm.ko kernel module which is already shipped with your distro.

    1. Correct me if I`m wrong.
      So if I use qemu-kvm (as a virtualizer), I should combine with kvm to execute guest code directly on the host CPU, if not I should use regular qemu (as a machine emulator) which uses dynamic binary translation.
      And qemu itself can run without kvm, but kvm can`t create, run a VM without qemu/qemu-kvm?

    2. The full story is that if you build qemu-kvm from source it can actually do everything that qemu does. Distro packages typically only build the x86 guest support though - that's why you'd use qemu packages for ARM-on-x86 or other dynamic binary translation guests.

      Usually both qemu-kvm and qemu distro packages can run x86 guests on x86 hosts both with KVM or translated. (However your distro can compile to disable some of these options.) Since qemu-kvm has some additional features/optimizations that qemu does not yet have for KVM mode, you should use qemu-kvm when you use KVM mode.

  3. Thank you for sharing such a nice information. :)

  4. Stephan, nice post
    But I am curious a bit to get to understand what does it mean to install Qemu without having the hypervisor install like this thing qemu-kvm -no-kvm?

    1. QEMU can run guests without using the CPU's virtualization extensions via KVM. The -no-kvm option forces QEMU to use the Tiny Code Generator (TCG) instead of KVM. The guest will execute more slowly because TCG is a Just-in-Time compiler - it has more overhead than CPU virtualization extensions.

      I hope this answers your question. If not, please rephrase it because I'm not sure I understood it completely.

  5. git clone git://

    appears to be something unique to Linux. This information is obtainable via cpuid or dmesg on other systems.

    1. I think you meant "grep 'svm\|vmx' /proc/cpuinfo" is Linux-specific.

      Thanks for sharing that cpuid or dmesg may have the information on other operating systems. It could be useful to check a machine running, say, Windows before reinstalling with Linux in order to run KVM.

  6. I am sorry but i am still confused between QEMU and KVM?

    1. "UPDATE: The qemu-kvm.git fork has been merged back into qemu.git as of QEMU 1.3.0. Always use qemu.git for the latest code. See my full post here."

      Always use QEMU.

  7. Thanks Stefanha for this useful information
    One doubt related to the statement you made in the post

    "If you want to run x86 virtual machines on x86 physical machines, install qemu-kvm. It has the fastest and most thoroughly tested support for the common x86 virtualization use case."

    Is it also applicable in the case where we want to run ppc virtual machine on ppc physical machine ?

  8. Thanks for sharing.I found a lot of interesting information here. A really good post, very thankful and hopeful that you will write many more posts like this one.

  9. This is a blog you can get useful information and better stuff right here stream twitch on PS4