fir3net
PPS-Firenetbanner-780.5x190-30-03-17

What Is the Difference between QEMU and KVM?

Contents[Hide]

The differences between QEMU and KVM are not always clear. I mean, are they the same, or are they different? Aren't they both hypervisors?

Lets begin ...

QEMU

QEMU is a userland type 2 (i.e runs upon a host OS) hypervisor for performing hardware virtualization (not to be confused with hardware-assisted virtualization), such as disk, network, VGA, PCI, USB, serial/parallel ports, etc. It is flexible in that it can emulate CPUs via dynamic binary translation (DBT) allowing code written for a given processor to be executed on another (i.e ARM on x86, or PPC on ARM). Though QEMU can run on its own and emulate all of the virtual machines resources, as all the emulation is performed in software it is extremely slow.

KVM

KVM is a Linux kernel module. It is a type 1 hypervisor that is a full virtualization solution for Linux on x86 hardware containing virtualization extensions (Intel VT or AMD-V)[1]. But what is full virtualization, you may ask? When a CPU is emulated (vCPU) by the hypervisor, the hypervisor has to translate the instructions meant for the vCPU to the physical CPU. As you can imagine this has a massive performance impact. To overcome this, modern processors support virtualization extensions, such as Intel VT-x and AMD-V. These technologies provide the ability for a slice of the physical CPU to be directly mapped to the vCPU. Therefor the the instructions meant for the vCPU can be directly executed on the physical CPU slice[2].

Summary

As previously mentioned, QEMU can run independently, but due to the emulation being performed entirely in software it is extremely slow. To overcome this, QEMU allows you to use KVM as an accelerator so that the physical CPU virtualization extensions can be used. So to conclude QEMU is a type 2 hypervisor that runs within user space and performs virtual hardware emulation, where as KVM is a type 1 hypervisor that runs in kernel space, that allows a user space program access to the hardware virtualization features of various processors[3]

Figure 1 - High-level overview of the KVM/QEMU virtualization environment
Source : https://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine

Finally, It is also worth mentioning a little history, which in my opinion has led to some of the confusion around KVM/QEMU. Previously KVM was a fork of QEMU, named qemu-kvm. However this has now been merged into QEMU upstream and the fork has now been discontinued. Or in other words, as per Linux KVM,

The kernel component of KVM is included in mainline Linux, as of 2.6.20. The userspace component of KVM is included in mainline QEMU, as of 1.3[4].

Sources

[1] http://wiki.qemu.org/Features/KVM 
[2] http://www.innervoice.in/blogs/2014/03/10/kvm-and-qemu/  
[3] https://en.wikipedia.org/wiki/QEMU
[4] https://www.linux-kvm.org/page/Main_Page

Tags: Linux, KVM, QEMU, Kernel, Hypervisor

About the Author

RDonato

R Donato

Rick Donato is the Founder and Chief Editor of Fir3net.com. He currently works as a Principal Network Security Engineer and has a keen interest in automation and the cloud.

You can find Rick on Twitter @f3lix001