KVM vs QEMU vs libvirt: how Linux virtualization fits together
KVM is the Linux kernel part that uses CPU virtualization extensions, QEMU is the program that emulates a full machine around it, and libvirt is the management layer that virsh and virt-manager talk to.
People say “KVM” when they mean the whole Linux virtualization stack, but it is really three layers. Knowing which layer does what makes error messages and documentation much easier to follow.
KVM: the kernel part
KVM (Kernel-based Virtual Machine) is built into the Linux kernel. It uses the CPU’s hardware virtualization extensions (Intel VT or AMD-V on x86) so guest code can run directly on the real CPU at near-native speed. It is a core module, kvm, plus a CPU-specific module, kvm_intel or kvm_amd. When it is loaded you get the device /dev/kvm.
lsmod | grep kvm
ls -l /dev/kvm
grep -Ec '(vmx|svm)' /proc/cpuinfo # >0 means the CPU advertises VT-x/AMD-V
KVM alone does not give you a virtual machine: it has no disks, network cards or display. Something in user space has to build those.
QEMU: the machine emulator
QEMU describes itself as a generic, open-source machine emulator and virtualizer. In system emulation it provides a virtual model of an entire machine (CPU, memory and devices such as disks, NICs and graphics). It can emulate the CPU in software, which is slow but works for other architectures, or work with a hypervisor such as KVM, in which case the guest runs on the host CPU. Each running VM is one qemu process on the host.
You can start QEMU by hand, but its command lines get very long. That is where libvirt comes in.
libvirt: the management layer
libvirt is a daemon and API that manages VMs, virtual networks and storage pools. Each VM is described by an XML definition; libvirt turns it into the right QEMU command, starts the process, sets permissions and SELinux/AppArmor labels, and creates networks such as the default NAT bridge virbr0. Tools build on libvirt:
virsh: the command-line shell for libvirt.virt-install: creates new VMs from install media or disk images.virt-manager: a desktop GUI.- Other platforms, such as OpenStack’s compute service, can also use libvirt underneath.
System vs session connections
libvirt’s QEMU driver has two kinds of connection:
qemu:///system: a privileged instance for servers. VMs here can use host networking such as bridges and are usually what administrators want.qemu:///session: a per-user instance where QEMU runs with your own user’s privileges. It is aimed at desktop use and has limited networking.
A classic confusion is creating a VM as root (system) and then not seeing it as a normal user (session). Be explicit:
virsh -c qemu:///system list --all
export LIBVIRT_DEFAULT_URI=qemu:///system
Check that a host is ready
libvirt ships virt-host-validate, which checks whether the host is set up for its hypervisor drivers, including hardware virtualization and /dev/kvm:
virt-host-validate qemu
Putting it together
When you run virsh start web01, virsh asks libvirt, libvirt reads the XML for web01 and launches a qemu process with matching options, and QEMU uses /dev/kvm so the guest CPU runs on the hardware. Errors can come from any of these layers; the message usually tells you which one (for example, a QEMU error is often quoted inside a libvirt error).
Official documentation
See also
- 0098 What Proxmox VE is: KVM virtual machines, LXC containers and a web UI Proxmox VE is an open source virtualization platform based on Debian. It runs KVM virtual machines and LXC containers and is managed… Beginner · Concept · Linux Article Basics · Installation & first steps 15 Oct 2026
- 0100 Create a VM and a cloud-init template with qm Create KVM virtual machines from the command line with qm, then build a reusable cloud-init template from a cloud image and clone… Intermediate · How-to · Linux Article Basics · VMs & containers 15 Oct 2026
- 0124 virsh cheat sheet: everyday libvirt commands A quick reference for virsh: list, start, stop and inspect VMs, change CPUs and memory, manage networks, storage pools and snapshots, with… Intermediate · Reference · Linux Article Basics 15 Oct 2026
- 0125 Create a KVM virtual machine with virt-install Use virt-install to create libvirt/KVM guests: install from an ISO, run a text-only install over the serial console, or import a cloud… Intermediate · How-to · Linux Article Basics 15 Oct 2026
- 0126 KVM snapshots and cloning with virsh and virt-clone Take, list, revert and delete libvirt snapshots with virsh, understand internal vs external and disk-only snapshots, and clone a stopped VM with… Advanced · How-to · Linux Article Basics 15 Oct 2026
- 0127 Fix: “Requested operation is not valid: network ‘default’ is not active” A libvirt VM will not start because the virtual network it uses, usually the NAT network 'default', is stopped. Start the network… Intermediate · Fix · Linux Article Basics 15 Oct 2026
Repos in the wild
- proxmox/qemu-server: the Proxmox VE virtual machine manager proxmox/qemu-server Read-only GitHub mirror of qemu-server, the Proxmox VE package that manages QEMU/KVM virtual machines and provides the qm and qmrestore commands. GitHub
- libvirt: virtualization API and daemon (GitHub mirror) libvirt/libvirt libvirt is the toolkit that manages KVM/QEMU and other hypervisors through one API, plus the virsh client. The GitHub repository is a read-only mirror; development happens on GitLab. GitHub
History
Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.
- commitpedia-admin +3,233 chars