QEMU vs KVM hypervisor: What’s the difference?

Users have a lot of choices when it comes to virtualization on a Linux system. There are many use cases for virtualization, whether you want to have a test system that is isolated from your host system, test out a different Linux distribution, or even run a completely different operating system. Whatever the case may be, you will need to have a hypervisor. A hypervisor is what manages and allows you to interact with your virtual machines.

Two popular choices on Linux are KVM and QEMU. But if you are new to virtualization on Linux, you may not yet understand the difference, or know which one is better to use. In this tutorial, we will look at QEMU vs KVM, discuss their pros and cons, and help you decide which one is better for various virtualization needs on Linux. You will also learn how the two work together to make virtualization a breeze on Linux.

In this tutorial you will learn:

  • What is QEMU? What is KVM?
  • Pros and Cons of QEMU and KVM
  • The difference between QEMU and KVM
  • Which hypervisor should I use, QEMU or KVM?
QEMU vs KVM hypervisor: What's the difference?
QEMU vs KVM hypervisor: What’s the difference?
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software QEMU, KVM hypervisor
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

QEMU and KVM hypervisor

QEMU is short for Quick EMUlator. As its name implies, it can be used as an emulator, but also as a hypervisor. As an emulator, it allows you to run software that would normally not be possible to run on your current operating system because of compatibility. As a hypervisor, it allows you to create and manage virtual machines. It integrates quite seamlessly with KVM (Kernel-based Virtual Machine) which yields amazing performance results for your virtual machines.

It is important to understand the difference between a type 1 hypervisor and a type 2 hypervisor. KVM is a type 1 hypervisor, which essentially means it is able to run on bare metal. QEMU is a type 2 hypervisor, which means that it runs on top of the operating system. In this case, QEMU will utilize KVM in order to utilize the machine’s physical resources for the virtual machines.

KVM Kernel-based Virtual Machine) is the type 1 hypervisor built into every Linux kernel since version 2.6.20. QEMU and is one of example of a type 2 hypervisor that can utilize KVM to allow virtual machines direct access to your system’s hardware. It is possible to use KVM directly, without the need for a type 2 hypervisor, but doing so is much more complex and not very user friendly. In scenarios of critical production servers that are overseen by seasoned administrators, they will often utilize KVM without the type 2 hypervisor interface at all.

QEMU Pros and Cons

QEMU Pros:

  • Close integration with KVM; More performant than most hypervisors
  • More user friendly and easy to use than KVM
  • Can work as an emulator as well as a hypervisor

QEMU Cons:

  • Slight performance decrease from using KVM directly
  • Requires installation and configuration to setup
  • Less cross compatible and user friendly than some hypervisors, like VirtualBox

KVM Pros and Cons

KVM Pros:

  • Can give VMs direct access to hardware; No performance decrease
  • Can be automated and incorporated into scripts
  • Baked into the Linux kernel; it is always installed

KVM Cons:

  • Not user friendly to set up
  • Only available for Linux systems
  • Not as feature rich as a type 2 hypervisor like QEMU

The Difference Between QEMU and KVM hypervisor

Ease of use: You will undoubtedly get up and running with much less fuss on QEMU. KVM comes with a learning curve, but once you get the hang of it, it is not exceptionally difficult to use. For new users, we definitely recommend wetting your feet with QEMU before taking the dive into deep water with KVM.

Performance: You can’t beat the performance of KVM, since it is baked into the Linux kernel. It allows for direct access to the system hardware, and can run a guest operating system with the same performance that it would run directly on the hardware. The performance impact of QEMU, however, is quite neglible in the majority of cases, unless you need to squeeze every ounce of performance possible out of a server.

Features: QEMU is both an emulator and hypervisor, so it will have some obvious use cases that KVM can’t cover. QEMU also offers a GUI which makes managing your virtual machines much easier.

Closing Thoughts

In this tutorial, we learned about the difference between QEMU and KVM hypervisor. Most users of KVM will also utilize QEMU, as it is a great way to interface with KVM to manage and control your virtual machines. In most respects, you can think of QEMU as the frontend for KVM.

Comments and Discussions
Linux Forum