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

API callspawnsioctlvirshCLI clientlibvirtdXML → argsqemu-systemdevices/dev/kvmCPU accel
Request path from a management command down to hardware acceleration.

Which tool lives where

ToolLayerUse it for
qemu-system-x86_64EmulatorQuick tests, custom device setups, emulating other architectures
qemu-imgEmulator utilityCreate, convert, resize and inspect disk images
libvirtd / virtqemudDaemonPersistent VM definitions, autostart, networks, pools
virshlibvirt CLIStart/stop/edit VMs, snapshots, migration, scripting
virt-installlibvirt CLICreating new VMs from an ISO, URL, or cloud image
virt-managerlibvirt GUIDesktop management with a graphical console
virt-clone / virt-syspreplibguestfs/libvirtCloning 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

virsh list --all
Id Name State
----------------------------
1 web01 running
- db01 shut off
ps -eo pid,comm,args | grep qemu | head -1
2214 qemu-system-x86 /usr/bin/qemu-system-x86_64 -name guest=web01 -accel kvm ...
Every running libvirt VM is one QEMU process you can see in ps.

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-:22

Same 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.04

Look 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 line

Common 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.

More Linux articles