Use it to create, change and manage VMs, networks and storage.
libvirt
libvirt is the management layer for KVM/QEMU: domains (VMs) defined in XML, storage pools and volumes, virtual networks, controlled with virsh, virt-install, virt-manager or Cockpit.
1. virsh list --all; virsh dominfo <vm>.
2. Definition: virsh dumpxml <vm>.
3. Networks: virsh net-list --all — default active?
4. Storage: virsh pool-list --all.
5. Autostart: virsh autostart <vm>.
XML definition → libvirt validates → starts QEMU with devices → networks and pools attached
For Virtualization → libvirt, continue with the first unproven Topic check: Pin exact host, runtime/hypervisor, object identity, source revision/image/definition and failing workload. If that boundary is healthy, advance to the adjacent check: Read back effective runtime state including process, namespace/resource or virtual-hardware boundaries. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
virsh list --allVerification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
libvirt connection → domain XML → storage/network references → define/start operation → QEMU/KVM live state → guest
Healthy evidence: persistent definition, live domain state and referenced storage/network objects agree and the guest reaches expected readiness
Step 2 Verification and output interpretation Verify boundary
Verification chain. libvirt connection → domain XML → storage/network references → define/start operation → QEMU/KVM live state → guest
Step 3 Commands Verify boundary
virsh list --all
virsh dominfo vm01
virsh net-list --all
Step 4 Failure modes and next checks Narrow the fault
Suspicious evidence: persistent/live drift, wrong URI, stale domain definition, missing network/storage object or accepted job leaves guest unusable
It does not show unobserved clients, names, identities, routes, sessions, backends or time periods. libvirt operation success or persistent XML does not by itself show live effective state or guest application health.
Step 5 Common mistakes Narrow the fault
- Editing XML files directly instead of
virsh edit.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Edit VM definitions with virsh edit, not by hand. Mark VMs to start at boot with virsh autostart. The default NAT network (virbr0) needs ip_forward and libvirt's firewall rules.
virsh list --all— VMs and statevirsh dominfo <vm>— CPU, memory, autostartvirsh domiflist <vm> / domblklist <vm>— NICs and diskslscpu | grep -i virtualization— hardware virtualization support
ReferenceImportant terms & boundaries5 sections · depth on demand
What this shows and what it does not
libvirt operation success or persistent XML does not by itself show live effective state or guest application health.
libvirt owns host-side VM definition and lifecycle abstraction; virsh is one client and guest OS behavior remains separate.
In depth
libvirt and virsh: managing virtual machines
libvirt manages virtual machines (domains), networks and storage through one API, and virsh is its command-line client. The virsh manual page describes the connection URIs:
qemu:///systemconnects to the system-wide daemon that supervises QEMU/KVM domains, as root.qemu:///sessionconnects as a normal user to that user's own domains.
It also documents the domain commands:
listshows running domains, with--allfor inactive ones too.defineregisters a domain from XML without starting it.destroykills a domain immediately (the manual recommendsshutdownin most cases), without deleting its storage.autostartstarts a domain at host boot.dominfo,domblklistanddomifaddrshow details, disks, and IP and MAC addresses.consoleconnects to the serial console.
Everyday virsh commands
| Task | Command |
|---|---|
| List all VMs | virsh list --all |
| Start / clean shutdown / force off | virsh start web01, virsh shutdown web01, virsh destroy web01 |
| Start at host boot | virsh autostart web01 |
| Show and edit the definition | virsh dumpxml web01, virsh edit web01 |
| Disks and addresses | virsh domblklist web01, virsh domifaddr web01 |
| Serial console | virsh console web01 (leave with Ctrl-]) |
| Snapshots | virsh snapshot-create-as web01 pre-upgrade, virsh snapshot-list web01 |
| Networks and storage | virsh net-list --all, virsh pool-list --all, virsh vol-list default |
| Remove a VM (keep or delete storage) | virsh undefine web01 [--remove-all-storage] |
Creating a VM
virt-install creates the definition and starts the installation in one command. Without it, write the XML yourself and use virsh define.
host$ sudo virt-install --name web02 --memory 4096 --vcpus 2 --cpu host-passthrough \
--disk size=40,bus=virtio,format=qcow2 --network bridge=br0,model=virtio \
--os-variant ubuntu24.04 --cdrom /srv/iso/ubuntu-24.04-live-server-amd64.iso --graphics none --console pty,target_type=serial
host$ sudo virsh list --all
Id Name State
-----------------------
3 web01 running
4 web02 running
- lab01 shut off
host$ sudo virsh domifaddr web01
Name MAC address Protocol Address
vnet3 52:54:00:4a:1b:02 ipv4 192.168.122.41/24
host$ sudo virsh snapshot-create-as web01 pre-upgrade --disk-only --atomic
host$ sudo virsh autostart web01 && sudo virsh dominfo web01 | grep -E "State|Autostart|Max memory"
shutdown versus destroy
shutdown asks the guest to shut down through ACPI, or the guest agent, so file systems close cleanly. destroy is like pulling the power cord. Use it only when a guest no longer responds. domifaddr reads addresses from the DHCP leases on libvirt networks. For bridged VMs, use the guest agent source (--source agent).
Documented example, not captured output.
How it works at runtime
libvirt is part of Virtualization → libvirt. libvirt provides a management API and persistent domain definition layer over hypervisors such as QEMU/KVM, with separate persistent and live state.
Docker/libvirt add lifecycle, image/disk, network and volume abstractions above those primitives.
Topic-specific state model. libvirt provides a management API and persistent domain definition layer over hypervisors such as QEMU/KVM, with separate persistent and live state.
Quick reference
libvirt management basics:
virt-install --name web01 --memory 4096 --vcpus 2 --cpu host-model --os-variant rocky9 --disk size=40,bus=virtio --network bridge=br0,model=virtio --location https://download.rockylinux.org/pub/rocky/9/BaseOS/x86_64/os/ --extra-args 'console=ttyS0' --graphics none
virsh list --all; virsh dominfo web01
virsh console web01
virsh snapshot-create-as web01 pre-upgrade --disk-only --atomic
virsh autostart web01
virsh dumpxml web01 > web01.xml
Domain XML in /etc/libvirt/qemu/ should be changed with virsh edit, not directly.
Limits and how it fails
Primary failure point. libvirt operation success or persistent XML does not by itself show live effective state or guest application health.
Snapshot/image existence is not a verified backup.
ReferenceConfiguration & state1 section · depth on demand
Configuration, persistence and lifecycle
Configuration intent and lifecycle. Treat image/compose/libvirt definitions as desired state and runtime inspect output as actual state.
Distribution/platform context. libvirt owns host-side VM definition and lifecycle abstraction; virsh is one client and guest OS behavior remains separate.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Virtualization → libvirt. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.kernel.org/virt/kvm/index.html · confidence 94%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
libvirt operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for libvirt.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | libvirt provides a management API and persistent domain definition layer over hypervisors such as QEMU/KVM, with separate persistent and live state. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin host + object identity + source image/definition → verify host/runtime capability → read back effective process/namespace/cgroup or virtual-hardware state → verify storage/network attachments → verify guest/container readiness → repeat original workload + regression check. | Use the shortest evidence path first; a fast check is a boundary test, not blanket proof. |
| Verification chain | libvirt connection → domain XML → storage/network references → define/start operation → QEMU/KVM live state → guest | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | libvirt operation success or persistent XML does not by itself prove live effective state or guest application health. | Stop broad troubleshooting at the first boundary that is not supported by evidence. |
| Positive evidence | Correlated Linux container/virtualization evidence can establish this proof path: libvirt connection → domain XML → storage/network references → define/start operation → QEMU/KVM live state → guest | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It does not independently prove unobserved clients, names, identities, routes, sessions, backends or time periods. libvirt operation success or persistent XML does not by itself prove live effective state or guest application health. | Do not promote a local success signal into end-to-end or adjacent-dependency proof. |
| Next troubleshooting check | Continue from the first unproven runtime boundary, capture adjacent host/object/resource/attachment evidence, make only the demonstrated persistent change, then repeat the original workload plus a regression check. | Continue to the next unresolved boundary while preserving the original test condition. |
libvirt · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | libvirt |
|---|---|
| Topic path | Virtualization → libvirt |
| Runtime state | libvirt provides a management API and persistent domain definition layer over hypervisors such as QEMU/KVM, with separate persistent and live state. |
| Fast checks | - Pin exact host, runtime/hypervisor, object identity, source revision/image/definition and failing workload. - Read back effective runtime state including process, namespace/resource or virtual-hardware boundaries. - Trace storage and network attachments plus readiness from the real client or dependent workload path. - Apply the smallest persistent change, then repeat the original workload and an adjacent regression check. |
| Verification chain | libvirt connection → domain XML → storage/network references → define/start operation → QEMU/KVM live state → guest Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. |
| Failure boundary | libvirt operation success or persistent XML does not by itself prove live effective state or guest application health. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |