Virtualization: KVM
Hardware-accelerated virtual machines in the Linux kernel
KVM architecture overview
KVM (Kernel-based Virtual Machine) is a hypervisor built into the Linux kernel. It uses hardware virtualization extensions (Intel VT-x / AMD-V) to run virtual machines at near-native speed.
Host (Linux + KVM)
┌─────────────────────────────────────────────────────────┐
│ QEMU (userspace) │
│ ┌──────────────────────────────────────────────────┐ │
│ │ VM process: manages devices, memory layout, VNC │ │
│ │ │ │ │
│ │ │ ioctl(/dev/kvm, KVM_RUN) │ │
│ └──│──────────────────────────────────────────────┘ │
│ ▼ │
│ KVM kernel module │
│ ┌──────────────────────────────────────────────────┐ │
│ │ vCPU thread: runs in VMX non-root mode │ │
│ │ ├── VM Entry: switch to guest (vmlaunch/vmresume)│ │
│ │ ├── Guest runs (near-native speed) │ │
│ │ └── VM Exit: return to host on sensitive ops │ │
│ └──────────────────────────────────────────────────┘ │
│ │
│ Hardware: Intel VT-x / AMD-V │
└─────────────────────────────────────────────────────────┘
Pages in this section
| Page | What it covers |
|---|---|
| KVM Architecture | /dev/kvm API, vCPU, VM exits, VMCS |
| Memory Virtualization | EPT/NPT, shadow paging, balloon, huge pages |
| virtio | Paravirtualized I/O, virtqueue, vhost acceleration |
| VFIO Device Passthrough | IOMMU groups, DMA remapping, VFIO container hierarchy |
| KVM Exit Handling | Exit reasons, I/O emulation, MMIO, interrupt injection |
| KVM Live Migration | Dirty logging, pre-copy, CPU state transfer, post-copy |
| Nested Virtualization | L0/L1/L2, vmcs12, vmcs02 merge, two-level EPT |