What Is KVM? Linux Kernel-Based Virtualization Explained
KVM turns the Linux kernel into a type-1 hypervisor. Learn how KVM, CPU virtualization extensions and QEMU work together to run fast virtual machines.
Published November 27, 2026
KVM (Kernel-based Virtual Machine) is the virtualization layer built into the Linux kernel. Load one kernel module and an ordinary Linux server becomes a hypervisor that can run Windows, BSD and other Linux systems at near-native speed. It powers most public clouds, OpenStack, Proxmox and countless home labs.
The concept
Before hardware support existed, hypervisors had to trap and rewrite privileged guest instructions in software, which was slow and complicated. Intel VT-x and AMD-V added a new CPU mode (guest mode) where a virtual machine can run its own kernel directly on the processor. When the guest does something that needs the host's attention, such as touching an I/O port, the CPU performs a "VM exit" back to the host.
KVM is the piece of Linux that drives those CPU features. It ships as kvm.ko plus a vendor module (kvm_intel.ko or kvm_amd.ko) and exposes a device file, /dev/kvm. A userspace program opens /dev/kvm, creates a VM, gives it memory and virtual CPUs, and calls an ioctl to run each vCPU. Every vCPU is just a normal Linux thread, so the regular scheduler, cgroups and tools like top all work on virtual machines.
KVM itself does not emulate disks, network cards, USB or a BIOS. That job belongs to a userspace emulator, almost always QEMU. The split is simple: KVM makes the CPU and memory fast, QEMU provides the virtual hardware, and libvirt sits on top to manage everything with a stable API and tools like virsh and virt-manager.
The KVM virtualization stack
When you type virsh start web01, the request travels down this stack. libvirt turns your XML definition into a QEMU command line, QEMU asks KVM to create the VM, and KVM programs the CPU.
Is KVM a type-1 or type-2 hypervisor?
Type-1 hypervisors run directly on the hardware (VMware ESXi, Xen); type-2 hypervisors run as an application on top of an operating system (VirtualBox, VMware Workstation). KVM blurs the line: it is part of the kernel, so the kernel itself becomes the hypervisor. Most people classify KVM as type-1 because guest code runs on the CPU with no extra OS layer in between, and scheduling and memory management happen inside the kernel.
The practical result is what matters: KVM guests get near bare-metal CPU performance, and you keep the full Linux toolbox for networking, storage, security (SELinux/AppArmor via sVirt) and monitoring.
What happens when a VM runs
Each vCPU loops: enter guest mode, run until a VM exit, let KVM or QEMU handle the exit, then re-enter. Fast paths such as virtio and in-kernel interrupt controllers keep exits rare.
Checking that KVM is available
Who does what
| Component | Runs in | Responsible for |
|---|---|---|
| KVM | Kernel | vCPU execution, memory virtualization (EPT/NPT), interrupt routing |
| QEMU | Userspace | Device emulation: disks, NICs, display, firmware (SeaBIOS/OVMF) |
| libvirt | Userspace daemon | Lifecycle, XML config, networks, storage pools, permissions |
| virsh / virt-manager | Client | CLI and GUI front-ends for libvirt |
Practical examples
Confirm hardware virtualization
vmx means Intel VT-x, svm means AMD-V. Zero means the feature is missing or disabled in firmware.
grep -Eoc '(vmx|svm)' /proc/cpuinfo
# Friendlier check on Ubuntu/Debian
sudo apt install cpu-checker && kvm-okLoad the KVM modules manually
They normally load automatically at boot, but you can load them by hand when testing.
sudo modprobe kvm_intel # or kvm_amd
lsmod | grep kvmStart a throwaway VM with plain QEMU + KVM
The -enable-kvm flag (or -accel kvm) is what switches QEMU from slow software emulation to hardware acceleration.
qemu-system-x86_64 -enable-kvm -m 2048 -smp 2 \
-cdrom ubuntu-24.04-live-server-amd64.iso -boot dCommon mistakes
- Forgetting to enable VT-x/AMD-V in BIOS/UEFI: the CPU supports it but the flag stays hidden until it is enabled in firmware.
- Running QEMU without -enable-kvm and wondering why the VM is 10-50x slower. That is pure software emulation (TCG).
- Assuming KVM works inside every cloud VM. Nested virtualization must be enabled by the provider or host (kvm_intel nested=1).
- Adding users to the wrong group. Access to /dev/kvm usually needs the kvm group, and libvirt management needs the libvirt group.
- Treating KVM and QEMU as competitors. They are two halves of the same system.
Key takeaways
- KVM is a kernel module that turns Linux into a hypervisor using VT-x or AMD-V.
- Each vCPU is a Linux thread, so standard scheduling, cgroups and monitoring apply.
- QEMU provides the virtual hardware and libvirt provides management. KVM only accelerates CPU and memory.
- Check /proc/cpuinfo for vmx/svm and make sure /dev/kvm exists before going further.
FAQ
Is KVM free?
Yes. KVM is part of the mainline Linux kernel (GPL) and QEMU and libvirt are open source too. Commercial platforms such as Proxmox or Red Hat Virtualization add support and management on top.
Can KVM run Windows guests?
Yes. Windows runs well on KVM, especially with virtio drivers (the virtio-win ISO) for disk and network, and OVMF firmware for UEFI and Secure Boot.
Does KVM work on ARM?
Yes. KVM supports x86, ARM64, POWER, s390x and RISC-V. On ARM it uses the virtualization extensions in ARMv8 (EL2).
What is the difference between KVM and Docker?
KVM runs full virtual machines with their own kernels. Docker containers share the host kernel and isolate processes with namespaces and cgroups. VMs offer stronger isolation; containers start faster and use less memory.