Chapter 05 — 2003 — 2010

Xen and paravirtualization

If you cannot trap every sensitive instruction, change the guest so it asks politely. Xen's bet on cooperation delivered near-native speed and became the foundation of the first public cloud.

In 2003, a team at the University of Cambridge Computer Laboratory released Xen 1.0. The pitch was almost heretical: instead of hiding the hypervisor from the guest, tell the guest the truth and ask it to cooperate. The result was a hypervisor fast enough to run production workloads on commodity x86 hardware — years before the CPU vendors added virtualization support.

Cooperation over interception

Xen's authors argued that the expensive part of virtualization was not running guest code, but intercepting it. Binary translation and trap-and-emulate both spend time detecting and emulating privileged operations. If the guest kernel is modified to issue an explicit call whenever it would otherwise execute a sensitive instruction, the hypervisor can avoid guessing entirely.

This is paravirtualization. The guest is no longer an unmodified operating system; it is a kernel compiled for Xen, using a small interface of hypercalls instead of privileged instructions. The guest still believes it owns the CPU and memory, but it asks permission through a defined ABI. In exchange, it runs close to native speed.

Paravirtualization in one sentence

Full virtualization hides the hypervisor and pays for interception; paravirtualization exposes the hypervisor and pays for guest modifications. Xen chose the second bill.

Domains, drivers and the control plane

Xen introduced a vocabulary that is still worth knowing. The hypervisor itself is a thin layer that schedules virtual CPUs and manages memory. The first domain to boot, domain 0 or dom0, is a privileged Linux instance that runs the real device drivers and the management tools. Other guests — domU — do not talk to hardware directly. They use a split device driver: a front-end driver in the guest sends requests over shared memory to a back-end driver in dom0, which performs the actual I/O.

Three mechanisms make this work:

  • Event channels — lightweight asynchronous notifications between domains, used instead of hardware interrupts.
  • Grant tables — a controlled way for one domain to share specific memory pages with another, without exposing its whole address space.
  • XenStore — a small hierarchical key-value store used to configure devices and pass information between domains at boot.
Xen architecture Domain 0 with real drivers and toolstack, plus unprivileged domU guests, above the Xen hypervisor and hardware. DOMAIN 0 — CONTROL toolstack · real device drivers BACK-END DRIVERS · XENSTORE PRIVILEGED · FIRST TO BOOT DOM U web guest FRONT-END DRIVERS DOM U db guest FRONT-END DRIVERS XEN HYPERVISOR vCPU scheduling · memory · event channels · grant tables NO DEVICE DRIVERS · SMALL TRUSTED COMPUTING BASE PHYSICAL HARDWARE SHARED MEMORY + EVENTS
FIG 5.1 — The split driver model: domU front-ends talk to dom0 back-ends through shared pages, never directly to hardware.

The design has a clear performance advantage and an equally clear operational consequence: dom0 is a single point of failure and a large attack surface. If dom0 is compromised, every guest on the host is at risk. The Xen community spent years reducing the driver domain's privilege and adding stub domains, but the architectural asymmetry remained.

HVM, PV-on-HVM, and the hardware transition

Xen's original guests had to be modified, which limited it mostly to Linux and other open-source kernels. When Intel VT-x and AMD-V arrived in 2005–2006, Xen 3.0 added HVM (hardware virtual machine) guests: fully unmodified operating systems running on the new CPU modes. A paravirtualized guest could then run on HVM hardware with PV drivers for I/O — often called PV-on-HVM — combining unmodified boot with fast devices.

Later, PVH mode combined a PV-style boot path with hardware virtualization for privileged operations, aiming for the best of both. The naming is a museum of compromises, but the trajectory is consistent: as hardware absorbed the hard parts, software moved from modifying the guest to using standard interfaces.

The hypervisor behind the first cloud

XenSource, the company formed to commercialize Xen in 2005, was acquired by Citrix in 2007. But Xen's biggest impact came through a customer rather than a product: Amazon Web Services launched EC2 in August 2006 on a Xen-based platform. For years, "the cloud" meant, at the hypervisor level, Xen plus paravirtualized Linux guests. Rackspace, Linode and many hosting providers followed.

The operational requirements of EC2 shaped Xen as much as the research did: fast provisioning, network isolation per tenant, API-driven lifecycle management, and enough density to make the economics work. Xen's small hypervisor and PV performance made it a natural fit. Later, AWS moved much of its fleet to KVM and its own Nitro architecture, a transition that Chapter 8 covers.

Running a Xen guest

A classic Xen PV guest is defined by a configuration file and started with the xl toolstack. The guest kernel must be Xen-aware.

xen — /etc/xen/web01.cfg
# paravirtualized Linux guest
name       = "web01"
kernel     = "/boot/vmlinuz-xen"
ramdisk    = "/boot/initrd-xen.img"
memory     = 2048
vcpus      = 2
disk       = [ "phy:/dev/vg0/web01,xvda,w" ]
vif        = [ "bridge=xenbr0,mac=00:16:3e:12:34:56" ]
on_poweroff = "destroy"
on_reboot   = "restart"
on_crash    = "restart"
bash — xl
$ sudo xl create /etc/xen/web01.cfg
$ sudo xl list
Name       ID   Mem VCPUs   State   Time(s)
Domain-0  0  4096     4   r-----    184.2
web01     3  2048     2   -b----     12.7

$ sudo xl console web01
$ sudo xl top       # per-domain CPU and memory

The trade-offs, honestly

Xen proved that paravirtualization could deliver near-native performance on x86, and it did so at a time when the alternative was complex binary translation. But the model carried costs that became harder to justify as hardware caught up:

  • Guest modifications. Every supported OS needs a Xen-aware kernel and drivers. Windows guests were impossible until HVM.
  • Driver domain complexity. dom0 becomes a critical, privileged component. Its failures affect every tenant.
  • Operational learning curve. XenStore, grant tables and split drivers are powerful but not simple.
  • Security advisory load. A small hypervisor still has a large interface: device emulation, virtual firmware and toolstack bugs produced a steady stream of CVEs.

KVM took a different route — no guest modifications, no separate hypervisor kernel, just Linux plus hardware virtualization — and eventually became the default for new open-source deployments. But Xen's influence is everywhere: the vocabulary of domains, the split driver model, and the operational patterns of early cloud all trace back to Cambridge.

Key takeaway

Xen is the clearest example of a design optimized for the hardware of its time. When the hardware changed, the optimization became a constraint — but the paravirtualized device model it pioneered lives on in virtio, vhost and SR-IOV.

Sources & further reading