KVM vs QEMU vs libvirt: How the Linux Virtualization Stack Fits Together
KVM, QEMU and libvirt are not competing hypervisors. See exactly what each layer does, how they call each other and which tool to use for which job.
Published November 27, 2026
If you are new to Linux virtualization, the names KVM, QEMU, libvirt, virsh, virt-install and virt-manager can feel like six products that do the same thing. In reality they form one layered stack, and once you see which layer does what, every tutorial and error message becomes much easier to read.
The concept
QEMU (Quick Emulator) started as a full machine emulator. On its own it can emulate an ARM board on an x86 laptop by translating every instruction in software with its Tiny Code Generator (TCG). It also emulates the rest of a computer: chipset, disk controllers, network cards, graphics, USB and firmware.
KVM is the accelerator. When QEMU runs on a host with the same CPU architecture as the guest, it can hand CPU execution to the kernel through /dev/kvm. Guest instructions then run directly on the processor, and QEMU only steps in for device emulation. This combination, sometimes written QEMU/KVM, is what people usually mean when they say "a KVM virtual machine".
libvirt is a management layer. Raw QEMU command lines get very long and are not persistent: when the process exits the VM definition is gone. libvirt stores each VM as an XML document, starts QEMU with the right arguments, manages virtual networks and storage pools, applies security labels, and exposes one API used by virsh, virt-install, virt-manager, Cockpit, OpenStack Nova and many others.
The call chain
Which tool lives where
| Tool | Layer | Use it for |
|---|---|---|
| qemu-system-x86_64 | Emulator | Quick tests, custom device setups, emulating other architectures |
| qemu-img | Emulator utility | Create, convert, resize and inspect disk images |
| libvirtd / virtqemud | Daemon | Persistent VM definitions, autostart, networks, pools |
| virsh | libvirt CLI | Start/stop/edit VMs, snapshots, migration, scripting |
| virt-install | libvirt CLI | Creating new VMs from an ISO, URL, or cloud image |
| virt-manager | libvirt GUI | Desktop management with a graphical console |
| virt-clone / virt-sysprep | libguestfs/libvirt | Cloning VMs and wiping machine-specific state |
When to skip libvirt
You do not need libvirt to use KVM. Developers often run QEMU directly for short-lived test machines, kernel debugging (with -s -S for gdb), or CI jobs that boot an image, run tests and throw it away. Projects like Firecracker and cloud-hypervisor skip QEMU too and talk to /dev/kvm with their own minimal device models.
For anything long-lived (servers, home labs, VMs that should autostart after reboot) libvirt is worth it. It gives you consistent naming, persistent configuration, cleanup on crash, and a single place to see every VM on the host.
Seeing the layers on a live host
Practical examples
Same VM, two ways: raw QEMU
Everything is on the command line and nothing persists after exit.
qemu-system-x86_64 -accel kvm -m 4096 -smp 2 -cpu host \
-drive file=web01.qcow2,if=virtio \
-nic user,model=virtio-net-pci,hostfwd=tcp::2222-:22Same VM through libvirt
virt-install writes the XML once. Afterwards you just use virsh start web01.
virt-install --name web01 --memory 4096 --vcpus 2 --cpu host-passthrough \
--disk path=/var/lib/libvirt/images/web01.qcow2 \
--network network=default,model=virtio --import --os-variant ubuntu24.04Look at the XML libvirt generated
Dump the definition to see how CLI flags became a domain XML.
virsh dumpxml web01 | head -30
virsh domxml-to-native qemu-argv --domain web01 # show the QEMU command lineCommon mistakes
- Editing VM settings by changing the QEMU process arguments. libvirt regenerates them from XML, so use virsh edit instead.
- Mixing qemu:///session (per-user) and qemu:///system (system-wide) connections, then being unable to find VMs created in the other one.
- Installing virt-manager on a headless server. Install libvirt there and connect virt-manager from your desktop over SSH (qemu+ssh://).
- Expecting qemu-img to work on a running VM disk. Use virsh snapshot or blockcommit commands for live disks.
Key takeaways
- QEMU emulates hardware, KVM accelerates the CPU, and libvirt manages VMs persistently.
- virsh, virt-install and virt-manager are all libvirt clients sharing the same API.
- Use raw QEMU for quick experiments and libvirt for anything long-lived.
- virsh domxml-to-native shows exactly what libvirt passes to QEMU.
FAQ
Can QEMU run without KVM?
Yes. Without KVM it uses TCG software translation. It works for any architecture, but it is much slower and is mainly used for cross-architecture emulation.
Is libvirt only for KVM?
No. libvirt has drivers for QEMU/KVM, Xen, LXC, VirtualBox, VMware ESXi, Hyper-V and others, though QEMU/KVM is by far the most common.
What replaced libvirtd?
Recent distributions use modular daemons such as virtqemud, virtnetworkd and virtstoraged instead of one monolithic libvirtd. The API and the virsh commands stay the same.