Cloud Parts

Hypervisors

The layer that splits one physical computer into several virtual ones, each with its own CPUs, memory, devices and kernel.

10 technologies on this page ↓
Live model
What you’re watchingMost guest instructions run straight on the CPU and never appear here. Each packet is a VM exit. The hypervisor in the host kernel handles timer and page-fault exits itself and resumes the guest quickly; network and disk exits go up to device models in the VMM process, so they take longer to come back.

How it works

A hypervisor, also called a virtual machine monitor (VMM), gives each guest virtual CPUs, a slice of memory and a set of devices. Ordinary guest instructions run directly on the real CPU. When a guest does something only the owner of the machine may do, such as touching a device or changing page tables, the CPU stops it and hands control to the hypervisor: a “VM exit”. The hypervisor emulates the operation, then resumes the guest. Modern CPUs build this in (Intel VT-x and AMD-V on x86, exception level EL2 on Arm), and a second layer of page tables (Intel EPT, AMD NPT) maps each guest’s memory onto real memory in hardware. Devices come in three flavors: fully emulated copies of real hardware, paravirtual devices such as virtio that the guest knows are virtual, and real devices passed straight through to one guest.

Think of it as

A stage manager during a play. The actors (guests) perform on their own, and the audience never sees the manager. But the moment an actor needs a prop, a light change or a door that’s locked, the play pauses for a beat, the manager sorts it out, and the scene carries on.

Reach for it when

  • Running several operating systems, or several kernel versions, on one physical server
  • Isolating tenants who don’t trust each other: each one gets its own kernel and a hardware-enforced boundary
  • Building your own private cloud or lab, e.g. Proxmox VE on KVM
  • Moving running workloads off a host for maintenance without restarting them (live migration)

Think twice when

  • You only need to separate processes you trust on one kernel: containers start faster and share memory more easily
  • Latency-critical, I/O-heavy work where every VM exit hurts: use bare metal, or pass the device straight through
  • Inside a cloud VM that doesn’t expose virtualization extensions: on AWS nested virtualization works only on some instance families, and Compute Engine allows only KVM as the nested hypervisor

A real example

A provider must patch the host kernel under 40 running VMs without rebooting customers. It live-migrates each VM to another host: memory is copied while the guest keeps running, pages the guest changes are sent again, and finally the guest pauses for a short “blackout” while the last state moves. Compute Engine does this during routine host maintenance, and its docs warn that the guest clock can appear to jump forward by up to 5 seconds during blackout. The original live-migration paper, built on Xen in 2005, measured downtimes as low as 60 ms.

Technologies

Specific products, and what each does differently.

Cloud HypervisorOpen sourceA Rust virtual machine monitor for modern cloud VMs on KVM or Microsoft’s hypervisor: virtio devices only, plus hotplug, VFIO passthrough, live migration, snapshots and Windows guests.KVM (Kernel-based Virtual Machine)Open sourceThe hypervisor built into the Linux kernel: it runs guest code directly on the CPU through `/dev/kvm`, and leaves device emulation to a user-space program such as QEMU or Firecracker.libvirtOpen sourceA stable API, daemon and `virsh` command line for managing virtual machines, storage and networks, with drivers for QEMU/KVM, Xen, LXC, Cloud Hypervisor, VMware ESX, Hyper-V and more.Microsoft Hyper-VCommercialMicrosoft’s type-1 hypervisor, built into Windows Server and Windows 10 and 11 Pro and Enterprise: a thin hypervisor under a Windows root partition, which also underpins Azure’s hypervisor and Windows features like VBS, WSL 2 and Windows Sandbox.Oracle VirtualBoxOpen sourceOracle’s free, open-source desktop hypervisor: a type-2 hypervisor that runs VMs as an application on Windows, macOS, Linux and Solaris, scriptable with `VBoxManage` and the default provider for Vagrant.Proxmox Virtual EnvironmentOpen sourceA Debian-based server platform from Vienna that runs KVM virtual machines and LXC containers, with clustering, high availability, Ceph and ZFS storage, backups and a web interface in one free ISO.QEMUOpen sourceThe open-source machine emulator and virtualizer: it emulates whole computers in software, or runs them at native speed on a hypervisor such as KVM, and supplies the virtual devices either way.VMware ESXiCommercialVMware’s bare-metal hypervisor (called ESX again since VCF 9), whose own kernel runs VMs directly on servers while vCenter adds vMotion, HA, DRS and vSAN; since Broadcom bought VMware in 2023 it is sold only as per-core subscriptions.Xen Project hypervisorOpen sourceThe open-source type-1 hypervisor from Cambridge that ran the first Amazon EC2 instances: a small microkernel-style core that boots first, with drivers and management in a privileged VM called dom0.FirecrackerOpen sourceThe open-source microVM monitor AWS built for Lambda: a full VM boundary that boots in under 125 ms.Mainly MicroVMs

What each provider calls it

AWS
Nitro Hypervisor (built on KVM) under EC2; Xen on older instance types; Firecracker under Lambda
Google Cloud
Compute Engine’s security-hardened, KVM-based hypervisor
Azure
The Azure hypervisor, based on Windows Hyper-V
Open source & others
KVM, Xen, QEMU, Cloud Hypervisor, Firecracker, Proxmox VE, VirtualBox, bhyve

Inside a VM exit#

The classic recipe is “trap and emulate”: run the guest’s kernel with reduced privileges, let every privileged instruction fault, and emulate it in the monitor. Popek and Goldberg showed in 1974 that this works on any CPU where every instruction that can reveal or change the machine’s state is also privileged. The original x86 broke that rule: some sensitive instructions silently behaved differently instead of trapping. VMware worked around it in 1999 by rewriting guest kernel code on the fly (binary translation), and Xen in 2003 by modifying the guest kernel to call the hypervisor directly (paravirtualization).

Intel VT-x and AMD-V fixed the hardware. They add a guest mode with all the usual privilege levels, plus a control structure where the hypervisor says which events should force an exit. On an exit the CPU saves the guest’s state, loads the hypervisor’s, and reports why it stopped, e.g. an I/O port access with its port number, width and direction. The hypervisor handles it and re-enters the guest. AMD’s SVM (AMD-V) and Intel’s VT-x work the same way. Exits are expensive: on a Pentium 4, VMware measured 2,030 cycles to trap and emulate one rdtsc instruction, against 216 cycles for its translated version. First-generation VT-x and AMD-V also left memory virtualization to software (“shadow” page tables), which is why second-level address translation followed: EPT and NPT let the CPU walk the guest’s page tables and the hypervisor’s guest-physical to host-physical map in hardware.

On Linux the loop is visible in KVM’s API. A user-space program opens /dev/kvm, creates a VM and its vCPUs, maps guest memory from its own address space, and calls KVM_RUN. The kernel enters guest mode and handles many exits itself, such as external interrupts and page faults. When the guest touches an I/O port or a memory-mapped device KVM can’t satisfy, KVM_RUN returns with KVM_EXIT_IO or KVM_EXIT_MMIO, and the user-space VMM emulates the device before calling KVM_RUN again. On 64-bit Arm the hypervisor runs at exception level EL2, and Linux asks to be booted there to use the virtualization extensions.

Three ways to give a guest a device#

ApproachHow it worksWhat the guest needsTrade-off
Full emulationThe VMM imitates a real piece of hardware, register by register, e.g. the Intel e1000 network card in QEMU’s default PCNothing special: the driver for the real cardRuns any OS, but each register access is a VM exit, and emulating I/O means leaving guest mode, which is costly
Paravirtual (virtio, Hyper-V VMBus)The device is designed for virtual machines: the guest driver puts requests on queues (virtqueues) that the host side processesA virtio driver, or Hyper-V’s integration servicesSkips imitating real hardware, which is more efficient, and gives one standard interface; the guest must have the driver
Passthrough (VFIO, SR-IOV)A real PCI device is handed to one guest, with the IOMMU (Intel VT-d, AMD-Vi) confining its DMA to that guest’s memory. SR-IOV splits one card into several virtual functionsThe normal bare-metal driver for that deviceThe lowest latency and highest bandwidth, but the device (or virtual function) belongs to one VM and needs IOMMU support

Type 1, type 2, and why the line blurs#

Robert Goldberg’s 1973 Harvard thesis split monitors into two kinds. In Type I, “the VMM runs on a bare machine”. In Type II, “the VMM runs on an extended host, under the host operating system”. ESXi and Xen are the textbook type 1 examples: ESXi installs on the physical server as the platform for VMs, and Xen calls itself a type-1 or bare-metal hypervisor. VirtualBox’s manual calls it a hosted, type 2 hypervisor that needs an existing OS.

Real systems mix the two. Xen boots first, but a privileged first guest, Domain0, runs the management software. Hyper-V sits directly on the hardware, yet it needs a root partition running Windows, which owns the physical devices and serves the other partitions’ device requests over VMBus. KVM turns the Linux kernel itself into the hypervisor: each VM is an ordinary process and each vCPU a thread, so top and kill work on them. Apple’s Hypervisor framework does the same on macOS, from a sandboxed user-space app.

That is why people now separate the hypervisor (the privileged part that runs guests on the CPU and isolates memory) from the VMM (the user-space process that sets up the VM and emulates its devices). On Linux, KVM is the hypervisor and QEMU, Firecracker or Cloud Hypervisor is the VMM. QEMU can also run with no hypervisor at all, emulating the whole CPU in software with TCG, as in the snippet above. Cloud Hypervisor runs on either KVM or the Microsoft Hypervisor (MSHV).

The main hypervisors and VMMs#

NameWhat it isMade byLicenseWhere you meet it
KVMHypervisor built into the Linux kernel; needs a user-space VMMLinux kernel community (started at Qumranet)GPL-2.0, as part of LinuxAWS Nitro Hypervisor, Compute Engine, Proxmox VE, most Linux virtualization
XenType 1, with a privileged Domain0 guestXen Project (a Linux Foundation project)GPL-2.0EC2 from 2006 until Nitro; server and embedded virtualization
VMware ESXiType 1, installed on the physical serverVMware, now part of BroadcomProprietary; the free vSphere Hypervisor 8 is unsupported and for non-production use onlyvSphere data centers
Microsoft Hyper-VType 1 under a Windows root partitionMicrosoftProprietary, part of certain x64 editions of WindowsWindows Server, Windows, Azure
QEMUVMM and machine emulator: uses KVM, Xen or Apple’s Hypervisor framework, or emulates the CPU in softwareQEMU projectGPL-2.0Paired with KVM on Linux; running other CPU architectures
FirecrackerMinimal VMM on KVM, one microVM per processAmazon Web ServicesApache 2.0AWS Lambda
Cloud HypervisorVMM on KVM or MSHV for modern cloud guestsCloud Hypervisor projectApache 2.0 and BSD-3-ClauseCloud workloads on modern 64-bit guests with virtio devices
Oracle VirtualBoxType 2 (hosted) applicationOracleGPLv3 base package; the Extension Pack is under the PUEL, free only for personal and educational useDesktops and laptops, local test VMs
bhyveHypervisor in the FreeBSD base system since 10.0FreeBSD projectBSDFreeBSD hosts
Apple Hypervisor frameworkmacOS API for running VMs from user space, without kernel extensionsAppleProprietary, part of macOSVirtualization apps on Macs; QEMU’s macOS accelerator

Running many VMs: migration, snapshots, overcommit, nesting#

Because a VM’s whole state is memory plus device state held by the hypervisor, it can be moved or saved. Live migration (Clark et al., 2005) copies all memory to the new host while the guest runs, then repeatedly re-sends only the pages dirtied since the last round, and finally pauses the guest to send the remainder and CPU state; the source keeps a consistent copy until the target confirms. A snapshot serializes the same state to files: Firecracker writes a guest memory file and a microVM state file covering KVM and emulated device state, and leaves disks to the user. Restoring a snapshot in a new process resumes the guest where it was, without booting.

Overcommit means the memory configured for all VMs exceeds the machine’s real memory. VMware ESX Server’s 2002 paper introduced two techniques for it. A balloon driver inside the guest allocates and pins pages on the hypervisor’s request, so the guest’s own memory manager decides what to give up. Content-based page sharing merges identical pages across VMs; in one experiment with identical Linux VMs, sharing reclaimed nearly 60% of all VM memory. Linux has the same idea as KSM (Kernel Samepage Merging), originally written for KVM: a daemon scans registered memory and replaces identical pages with one write-protected copy.

Nested virtualization runs a hypervisor inside a VM. Google describes it as levels: the physical host and its hypervisor are L0, the VMs on it L1, and VMs inside an L1 hypervisor L2. Each cloud limits it: Compute Engine supports only KVM at L1, and EC2 offers it on C8i, M8i and R8i instances. Every extra level adds address translations, which KVM has to fold into hardware that supports at most two.

Security: escapes and side channels#

The hypervisor is the wall between tenants, and its biggest attack surface is the device models. In 2015 the VENOM bug (CVE-2015-3456) let a guest user write out of bounds in QEMU’s emulated floppy disk controller, used by Xen and KVM, and possibly run code on the host. That is why newer VMMs emulate very few devices, why Firecracker and Cloud Hypervisor are written in Rust, a memory-safe language, and why AWS’s Nitro Hypervisor leaves out general-purpose operating system components and moves networking and storage to separate Nitro cards.

CPU side channels cross the wall without a bug in the hypervisor. With L1 Terminal Fault (L1TF), a malicious guest on one hyperthread could read data that the sibling hyperthread (the host, or another guest) had brought into the shared L1 cache. The mitigations are costly: flushing the L1 cache on VM entry (the Linux docs report slowdowns from 1% to 50% depending on the workload), pinning each guest to whole cores so tenants never share siblings, or turning SMT off.

See it in a real stack

Architectures that use hypervisors

In code · bash

# Run in a Debian 12 container on an Arm Mac: no /dev/kvm, so no hardware acceleration
apt-get install -y qemu-system-x86 qemu-system-arm

# Which accelerators can each QEMU binary use?
qemu-system-aarch64 -accel help
# Accelerators supported in QEMU binary:
# kvm
# tcg
qemu-system-x86_64 -accel help        # an x86 guest on an Arm host can only be emulated
# Accelerators supported in QEMU binary:
# tcg

# KVM needs the kernel’s /dev/kvm device, which this container doesn’t have
qemu-system-aarch64 -M virt -accel kvm -nographic
# Could not access KVM kernel module: No such file or directory
# qemu-system-aarch64: -accel kvm: failed to initialize kvm: No such file or directory

# So boot an x86 Linux guest (Alpine’s netboot kernel) with TCG, QEMU’s software CPU
qemu-system-x86_64 -accel tcg -m 512 -nographic -no-reboot \
  -kernel vmlinuz-virt -initrd initramfs-virt -append "console=ttyS0 panic=-1"
# [    0.000000] DMI: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
# [    0.072501] Booting paravirtualized kernel on bare hardware
# [    3.005845] e1000 0000:00:03.0 eth0: Intel(R) PRO/1000 Network Connection
# The guest sees an emulated 1996 chipset and an emulated Intel network card.
# Under KVM, the same kernel line reads “on KVM” instead of “on bare hardware”.

# Add -nic user,model=virtio-net-pci and the card becomes a paravirtual virtio device
# (the virtio spec: PCI vendor 0x1af4 with a device ID from 0x1000 to 0x107f is a virtio device):
# [    0.953372] pci 0000:00:03.0: [1af4:1000] type 00 class 0x020000 conventional PCI endpoint

# On a Linux host, check for hardware support, then swap -accel tcg for -accel kvm
grep -cE 'vmx|svm' /proc/cpuinfo      # x86: more than 0 means VT-x or AMD-V
ls -l /dev/kvm

Often confused with

Where it came from1967–2017

The hypervisor began as a way to share one expensive mainframe. At IBM’s Cambridge Scientific Center, CP-40 went into production in January 1967 on a specially modified System/360 Model 40, giving each user a virtual machine, and was then rewritten as CP-67 for the Model 67. In a February 1973 Harvard thesis, Robert Goldberg named the two ways to build such a monitor: Type I runs on a bare machine, Type II under a host operating system. A year later Popek and Goldberg defined a monitor by three properties (an essentially identical machine, at worst minor slowdowns, complete control of resources) and proved when trap-and-emulate works.

The x86 PC failed their test, so the first PC hypervisors relied on software tricks. VMware Workstation (1999) was a hosted, type 2 design that combined direct execution with dynamic binary translation of kernel code. Xen (2003), from the University of Cambridge, asked guests to be ported to an idealized interface, targeting up to 100 VMs on one server. Intel shipped its first processors with Virtualization Technology in November 2005, and AMD introduced a similar design. Surprisingly, VMware’s 2006 study found the hardware-assisted monitor often slower than its software one, mainly because the CPU still didn’t virtualize the MMU; nested paging (AMD) and EPT (Intel) were the answer.

Hardware support made a small hypervisor possible. KVM, written at Qumranet, was merged into Linux 2.6.20 in February 2007: a driver exposing /dev/kvm, with each VM a Linux process and device emulation left to user space. Microsoft released Hyper-V in June 2008. In the cloud, EC2 ran on Xen from its 2006 launch, but emulating storage and network devices in software meant reserving several CPU cores per server. With C5 in November 2017, AWS introduced the Nitro Hypervisor, built on KVM, with I/O moved to dedicated cards. A year later AWS open-sourced Firecracker, a minimal KVM-based VMM for Lambda.

Why it’s built this way

Trap only what must be trapped
Emulating every instruction is too slow. Running guest code directly and stepping in only for privileged operations is what keeps VMs close to native speed, and it’s why the cost of each VM exit matters so much.
Paravirtualize when the hardware can’t help
Without hardware support, Xen made the guest call the hypervisor instead of touching hardware. The idea outlived its reason: virtio and Hyper-V’s VMBus devices are paravirtual because bypassing device emulation is more efficient than imitating real hardware.
Reuse an operating system kernel as the hypervisor
KVM let Linux schedule vCPUs as threads and manage guest memory as process memory, so swapping, page migration, page merging and huge pages work on VMs without new code. Hyper-V’s root partition does the same with Windows for drivers and management.
Move device emulation off the host CPU
As networks and disks got faster, emulating them in software took whole CPU cores. Nitro moved networking and storage onto dedicated hardware, leaving the hypervisor to isolate CPU and memory, which let AWS sell practically all of a server’s resources.

Timeline

  1. 1967

    IBM’s CP-40 goes into production, running virtual machines on a modified System/360

  2. 1973

    Goldberg’s Harvard thesis classifies monitors as Type I (bare machine) and Type II (hosted)

  3. 1999

    VMware Workstation virtualizes x86 with binary translation

  4. 2003

    Xen introduces paravirtualization on x86

  5. 2005

    Intel ships the first processors with hardware virtualization (VT-x)

  6. 2007

    KVM merged into Linux 2.6.20

  7. 2017

    AWS introduces the KVM-based Nitro Hypervisor with C5 instances

Sources44

Improve this page on GitHub