Module 11 · Lesson 2 of 107

Hypervisor types and the QEMU/KVM split

Classify hypervisors as Type 1 or Type 2, explain why KVM blurs the line, and describe how QEMU and KVM split the work.

  • Beginner to advanced
  • 5 min read
  • 8 min lab
What you will need

A Linux machine (Ubuntu 24.04 in WSL2, a VM, or a container) with QEMU and Docker installed; a Raspberry Pi is useful but not required

Your place in the module
By the end you can 3 objectives
  • Classify Xen, ESXi, Hyper-V, KVM, VirtualBox, and QEMU-TCG as Type 1 or Type 2 and justify each.
  • Explain why KVM is called Type 1 despite running inside the Linux kernel.
  • Describe how QEMU in userspace and KVM in the kernel divide the work of running a guest.
Video coming soonHypervisor types and the QEMU/KVM split
The video for this lesson is being recorded. Read the lesson below in the meantime.
Recall first from Emulation, virtualization and containers
  • Emulation interprets or translates every guest instruction in software; virtualization runs most guest instructions natively on the same ISA.
  • A container shares the single host kernel, which is the root of its weaker isolation.
  • Emulation wins cross-architecture work, virtual machines win cloud tenancy, and containers win fast, dense application delivery.
01

Type 1 and Type 2 hypervisors

2 min read

The previous lesson separated the three techniques and named the hypervisor's parts. This lesson answers how hypervisors are classified into two types and how the two Linux tools, QEMU and KVM, split the work.

Hypervisors are traditionally split into two classes by where they sit.

A is the base layer of the software stack. It boots first, takes ownership of the CPU, memory, and devices, and then starts its guests. Because nothing sits between it and the hardware, it has the smallest possible trusted base and the most direct control. The classic examples are VMware ESXi, Microsoft Hyper-V, the Xen hypervisor, the ACRN hypervisor built for automotive and industrial use, and the Jailhouse partitioning hypervisor.

A is an application you install. The host OS boots normally, owns all the hardware, and schedules the hypervisor like any other process. The hypervisor then runs its guests using whatever the host OS gives it. The classic examples are Oracle VirtualBox, VMware Workstation, and QEMU running without any hardware acceleration. Type 2 is convenient, because you install it into an OS you already have, but every guest operation that touches hardware has to make a trip through the host OS first, which is one reason Type 2 has historically been slower.

The distinction is about the layer below the hypervisor, not about how sophisticated the hypervisor is.

Type 1 versus Type 2 hypervisorsType 1(bare-metal)Type 2(hosted)Sits onbare hardwarea hostoperatingsystemBootsfirst, beforeany OSas an appafter the OSExamplesXen, ESXi,Hyper-V,ACRN,JailhouseVirtualBox,VMwareWorkstation,QEMU-TCGTrusted basesmallhost OS plushypervisorI/O pathdirect tohardwarethrough thehost OS
Type 1 hypervisors run on bare metal; Type 2 run inside a host OS
02

KVM and the blurring of the two types

2 min read

KVM, the , is the example that breaks the clean two-class story, and it is the most important virtualization technology in the Linux world.

Here is the apparent contradiction. KVM is a module inside the Linux kernel. The Linux kernel is an operating system. So by the literal definition of Type 2, "a hypervisor inside a host operating system", KVM is Type 2. Yet KVM is almost always described as a Type 1 hypervisor. The resolution is that the classification is about control, not about location.

When the kvm module is loaded, the Linux kernel itself gains the authority that a Type 1 hypervisor has: it can enter a special hardware mode, at ARM exception level EL2 or the equivalent x86 root mode, where it controls the CPU's virtualization machinery directly. From that mode, the kernel can launch guests whose instructions run directly on the real CPU. The Linux kernel becomes the hypervisor, and the rest of Linux, the scheduler, the memory manager, the drivers, is just one more guest alongside the VMs, a privileged guest that happens to also run the hypervisor. This is the same relationship Xen has with its dom0, and nobody calls Xen Type 2.

The practical meaning is simpler. In a KVM system, the guests run at full hardware-virtualization speed, not through the slow Type 2 path of an application-level hypervisor. The Linux kernel's own process scheduling and memory management are reused rather than duplicated, which is a huge engineering win. And the kernel is the thing that has already been hardened and audited for years. The cost is that the trusted base, the Linux kernel plus its modules, is much larger than Xen's minimal hypervisor, a trade-off you will examine in a later lesson.

KVM turns the kernel into the hypervisorGuest VMruns natively under KVMQEMUuserspace VMM and device modelLinux kernel + KVMthe hypervisor, at EL2 or root modeHardwareCPU with virtualization extensionsQEMU asks the kernel to run the guest; the kerneldrives the hardwareGuest VMruns natively under KVMQEMUuserspace VMM and devicemodelLinux kernel + KVMthe hypervisor, at EL2 orroot modeHardwareCPU with virtualizationextensionsQEMU asks the kernel to run theguest; the kernel drives thehardware
Where KVM sits: the kernel becomes the hypervisor, with QEMU as the userspace VMM
03

The QEMU and KVM split

3 min read

QEMU is two tools in one, and separating its two halves is essential to understanding modern Linux virtualization.

QEMU was born as a pure emulator. In that role it uses a piece of software called TCG, the , to translate the guest's instructions into host instructions and run them. No hardware help is involved, which is why QEMU-TCG can run any guest architecture on any host architecture.

But QEMU has a second role: the . A guest operating system expects to find a disk controller, a network card, a serial port, and an interrupt controller. QEMU provides all of them in software, and when the guest writes to one of these devices, QEMU intercepts the write and updates its model of the device. This half of QEMU is needed no matter how the guest's CPU instructions are executed, because virtual devices do not exist in hardware.

When you run qemu-system-x86_64 -accel kvm, you are combining the two tools in the classic split. KVM, the kernel module, handles the CPU and memory: it makes the guest's instructions run directly on the real CPU, and it maintains the second-stage page tables that translate the guest's addresses to physical addresses. QEMU, running as an ordinary userspace process, handles everything else: it sets up the machine, emulates the devices, and calls into KVM through the /dev/kvm device file every time it needs the kernel to run the guest for a while. The userspace QEMU is the VMM, and the kernel KVM is the CPU and memory virtualization engine.

Step by stepThe QEMU and KVM execution loop
  1. QEMU sets up: QEMU creates the virtual machine, allocates its memory, and emulates the device model.

  2. QEMU calls KVM: QEMU issues an ioctl on /dev/kvm asking the kernel to run the guest's vCPU.

  3. KVM runs the guest: the kernel enters guest mode, and the guest's instructions execute natively on the CPU.

  4. The guest traps: a privileged instruction or device access causes a VM exit back into the kernel.

  5. KVM decides: the kernel either handles the exit itself or reports it back to QEMU.

  6. QEMU reacts: QEMU emulates the device the guest touched, then asks KVM to resume the guest.

The QEMU and KVM splitQEMUdevice model, VMM, setup, /dev/kvm callsKVMCPU execution and memory translationHardwareVT-x, AMD-V, or ARM EL2QEMU handles devices; KVM handles CPU and memoryQEMUdevice model, VMM, setup,/dev/kvm callsKVMCPU execution and memorytranslationHardwareVT-x, AMD-V, or ARM EL2QEMU handles devices; KVMhandles CPU and memory
The division of labour: QEMU as device model, KVM as the CPU and memory engine

Key takeaways

  • Type 1 hypervisors run on bare metal; Type 2 run on top of a host OS, but KVM blurs the line because the hypervisor is the kernel.
  • When the kvm module loads, the Linux kernel gains EL2 or root mode authority and becomes the hypervisor, with the rest of Linux as a privileged guest.
  • QEMU provides the device model in userspace while KVM runs guest CPU and memory in the kernel, and QEMU calls KVM through /dev/kvm.
Reflect
  1. Explain to a colleague, in two sentences: classify Xen, ESXi, Hyper-V, KVM, VirtualBox, and QEMU-TCG as Type 1 or Type 2 and justify each.
  2. Which objective are you least sure about? Re-read that section, then do its exercise in the practice pack.
  3. What surprised you when you ran the commands yourself?
On a real board

Repeat the key commands on your Raspberry Pi or lab board over SSH or the serial console. Note anything that behaves differently from your PC, such as missing tools, a BusyBox shell or a read-only filesystem.

References and further reading

Official documentation first. Links checked when the lesson was published.

Find your next step

↑ ↓ to move · Enter to open · Esc to close