What Is KVM (Kernel-based Virtual Machine) and How Does It Work?

Updated

KVM (Kernel-based Virtual Machine) is a full virtualization solution for Linux on x86 hardware that includes virtualization extensions (Intel VT or AMD-V). It lets you run multiple virtual machines with unmodified Linux or Windows images, each with its own private virtualized hardware such as a network card, disk, and graphics adapter. The kernel component has been part of mainline Linux since 2.6.20, and the userspace component has been part of mainline QEMU since 1.3, so most modern Linux distributions already ship the pieces you need.

What KVM actually consists of

KVM is not a single program but a small set of kernel modules plus a userspace emulator:

Component Role
kvm.ko Loadable kernel module providing the core virtualization infrastructure
kvm-intel.ko Processor-specific module for Intel VT hosts
kvm-amd.ko Processor-specific module for AMD-V hosts
QEMU (userspace) Mainline since 1.3; creates and runs the virtual machine and its virtual hardware

The kernel modules turn Linux itself into a hypervisor; QEMU supplies the virtual devices (disk, NIC, display) and the machine model. KVM is open source software.

How it works, in plain terms

KVM relies on the CPU's hardware virtualization extensions. When a guest executes privileged instructions, the processor traps to the KVM kernel module instead of the host kernel, which handles the exit and returns control to the guest. The guest OS runs largely at native speed on the real CPU, while QEMU emulates only the devices and firmware around it.

A concrete example: you want a Windows test machine on a Linux workstation. You check that the CPU exposes VT-x or AMD-V, load kvm-intel or kvm-amd, then start QEMU with -enable-kvm and a Windows ISO. The guest sees a virtual NIC, disk, and graphics adapter; the host sees one more process. Because the guest image is unmodified, no special drivers or paravirtualized kernel are required to boot.

What you need before using it

  • Hardware: an x86 CPU with Intel VT or AMD-V, enabled in firmware. Without it, KVM cannot run; QEMU falls back to pure emulation, which is far slower.
  • Kernel: a Linux kernel with KVM built in or available as modules (mainline since 2.6.20).
  • Userspace: QEMU 1.3 or later for the mainline KVM userspace component, plus a management tool if you want one.

Where to go next

The linux-kvm.org wiki is the project's own reference. Its navigation covers Status and Features, Guest Support Status, Management Tools, KVM Features, Migration, Develop, Mailing Lists/IRC, Bugs, Code, TODO, and Conferences (including KVM Forum pages from 2020 through 2024). It also hosts a HOWTO, Documents, Downloads, the book "qemu-kvm & libvirt," and an FAQ — the natural starting points for installation instructions and for checking whether a specific guest OS or feature is supported. Development blogs from people active in KVM-related virtualization are syndicated at planet.virt-tools.org.