What is the difference between kvm and qemu

What is the Difference between KVM and QEMU

There are several choices in the server market that aren’t always explained in detail. Therefore, making decisions for your project can be difficult. One of those tidbits of information is what type of hypervisor the machine is running. Our goal today isn’t to become a master of what everything means and how to use it. Instead, the goal is to narrow the scope and understand the difference between KVM and QEMU. Alongside those differences, we’ll be exploring the benefits of KVM and QEMU as well as reasons that you might use either or.

Type-1 and Type-2 Hypervisors

To understand what KVM and QEMU mean, we need to consider what a hypervisor is and what it does. A hypervisor is a process that separates a computer’s operating system from the host’s physical hardware. There are two types of hypervisors: 

  • Type-1 is a native or bare metal hypervisor that’s running directly on the host’s hardware
  • Type-2 is a hosted hypervisor, which means that it runs on a conventional operating system just as other computer programs would

Guest operating systems on type-2 hypervisors run as a process on the host machine. A host is a computer that a hypervisor runs one or more virtual machines (server, VPS). In this type of setup, the hypervisor is what allows the guest operating systems to utilize the physical hardware on the host without having direct access.

Benefits of KVM and QEMU

What does KVM and QEMU mean?

KVM and QEMU are two different hypervisors that have their own uses. KVM, or Kernel-based Virtual Machine, is a Linux Kernel Module.

It is considered a type-1 hypervisor, meaning it is a full virtualization solution for Linux on x86 hardware containing virtualization extensions such as Intel-VT or AMD-V. Paired with these extensions, KVM provides the ability for a portion of the physical CPU to be directly mapped to the virtual CPU. This means that information can be passed and executed directly on the physical CPU mapping.

KVM was implemented to gain advantages of hardware assisted virtualization present in modern generations of Intel and AMD CPUs. Prior to KVM, CPUs were fully emulated by software, which resulted in much weaker performance. This was due to the lack of access to physical hardware. Where KVM uses a piece of the CPU, QEMU emulates the CPU.

KVM is licensed under various GNU licenses.

QEMU, short for Quick Emulator – is a type-2 hypervisor that emulates a machine’s processor through dynamic binary translation. Despite QEMU having the ability to run on its own and emulate all virtual machine resources, all emulation is performed in-software. This makes it very slow.

QEMU was written by Fabrice Bellard and is considered as free software, primarily licensed under the GNU GPL license.

Benefits of KVM and QEMU

KVM 

KVM has several benefits that make it stand out from QEMU.

  • Firstly, KVM is a Type 1 Hypervisor
  • Merged into Linux Kernel mainline in v2.6.20 in Feb 2007
  • Requires a processor with hardware virtualization extensions such as Intel VT or AMD-V
  • KVM also provides hardware-assisted virtualization for many guest OS
    • Linux, BSD, Solaris, Windows, Haiku, ReactOS, Plan 9, AROS Research OS, macOS, Android 2.2, GNU/Hurd, Minix 3.1.2a, Solaris 10 U3, and Darwin 8.0.1. This includes newer versions
  • Requires a processor with hardware virtualization extensions such as Intel VT or AMD-V
  • KVM provides hardware-assisted virtualization for many guest OS
  • It supports hot plug vCPUs
  • KVM also supports dynamic memory management
  • It supports live migration
  • KVM can emulate Video Cards, PCI devices, Input Devices, Sound Cards, Ethernet Network Cards, Watchdog timer, RAM (50 MB to 32 TB) CPUs (1-160 CPUs)
  • KVM has Graphical Management Tools
    • Kimchi, web-based Virtualization Management tool
    • Virtual Machine Manager
    • Proxmox Virtual Environment
    • OpenQRM
    • GNOME Boxes
    • oVirt
benefits of KVM and QEMU

The combination of these features and benefits will result in the ability to run a powerful machine. As a result, KVM can then run programs that QEMU would not be able to do so. For example, in most cases you would be unable to run Docker instances on a QEMU instance. With KVM, however, this would not be an issue. A specific use case, for example, is when one might need to deploy an installation of Pterodactyl hosting panel to manage and set-up game servers. Without access to KVM and it’s feature-set, you’d be unable to make use of or install this particular panel.

QEMU

Next, we’re going to move forward with QEMU.

  • Firstly, QEMU is a Type 2 Hypervisor
  • QEMU can be paired with KVM to run VMs at near native speed. This is accomplished by using hardware extensions such as: Intel VT-x or AMD-V.
  • It can then emulate for user-level processes that allow applications compiled for one architecture to run on a different one.
  • Multiple operating modes: User-mode emu, System emu, KVM hosting, and Xen Hosting,
  • QEMU can save and restore the state of VMs with all programs running.
  • QEMU VMs can interface with many types of physical host hardware such as CD-ROM Drives, USB Devices, Audio Interfaces, Hard Disks, Network Cards
  • Virtual Disk Images can be stored as qcow or qcow2 format which only uses as much disk space as the Guest OS is actually using. Therefore, allowing for a large emulated disk to only use a small portion of the host’s disk space. In turn, it also allows for the ability to revert the emulated disk’s contents to a previous state. (Snapshots)
  • It does not depend on graphical output methods on the host system, instead making use of an integrated VNC server to access the screen of the guest OS.
  • QEMU is able to execute multiple virtual CPUs in parallel.

QEMU also does not require administrative rights to run unless additional modules for performance improvements, or certain modes of it’s network connectivity model are utilized.

Formats that QEMU supports

QEMU supports multiple disk image formats such as:

  • .dmg (read only)
  • Bochs (read only)
  • Linux Cloop (read only)
  • Parallels .hdd, .hds (read only)
  • QEMU copy-on-write .cow, .qcow, .qcow2, .qed, 
  • VirtualBox .vdi
  • Virtual PC .vhd
  • Virtual VFAT
  • VMWare .vmdk
  • Raw images .img (sector-by-sector contents of a disk*)
  • CD/DVD images .iso (sector-by-sector contents of an optical disk)

Guest Operating Systems Available

QEMU includes a wide variety of guest operating systems available such as:

  • IA-32 (x86) architecture
  • X86-64
  • MiPS64
  • Sun’s SPARC sun4m
  • Sun’s SPARC sun4u
  • ARM development boards
  • SH4 SHIX board
  • PowerPC (PReP and Power Macintosh)
  • ETRAX CRIS
  • MicroBlaze
  • RISC-V

QEMU Integration with Different VM Solutions

QEMU is integrated into many different VM solutions.

  • VirtualBox uses some of QEMU’s virtual hardware devices, and has a built in dynamic recompiled based on QEMU as a fallback device.
  • Xen-HVM uses device emulation that is based on QEMU to provide I/O virtualization to it’s VMs. Hardware is emulated via a QEMU “device model” daemon running as a backend in dom0.
  • Win4Lin Pro Desktop was based on a ‘tuned’ version of QEMU and KQEMU to host NT-versions of Windows. Win4Lin Virtual Desktop Server was based on the same code, serving Microsoft Windows sessions to thin clients from a Linux server.
  • SerialICE is a QEMU-based firmware debugging tool that runs system firmware inside of QEMU, accessing real hardware through a serial connection to the host.
Difference between KVM and QEMU

QEMU has a large number of features and a wide range of use, as you can see. It can integrate into several major projects such as VirtualBox, Win4Lin Pro Desktop and more. In fact, it’s normally paired with KVM. QEMU can make use of KVM features like acceleration when the target architecture is the same as the host architecture. With QEMU’s ease of use and simplicity to install, it’s understandable why one might make use of QEMU for fast and easy virtual machines.

KVM vs QEMU, which one is right for you?

In conclusion, the difference between KVM and QEMU are the two different hypervisors. Performance and the ability to run certain projects set aside each hypervisors. Therefore, the benefits of KVM and QEMU can vary. QEMU while slower, can be more versatile and general use friendly. The uses cases differ, though they retain one similarity; they need more power. More power will give that small bit of juice to a project, or host instances of game servers through a simple to use control panel software. At the end of the day, both QEMU and KVM have benefits that shine for each user. That said, consider your project’s needs before purchasing a server. Thus, if you predict the want or need to use Docker, that automatically rules out QEMU. 


Share this post with your friends

Share on facebook
Share on twitter
Share on linkedin