Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

libvirt

Direct answer

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.

When to use this

Use it to create, change and manage VMs, networks and storage.

First 30 seconds

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

Operational verification

XML definition → libvirt validates → starts QEMU with devices → networks and pools attached

Evidence · next step

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
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Key commandvirsh list --all
Scope / prerequisiteUse it to create, change and manage VMs, networks and storage.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

5 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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 references

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.

observation · 1
Key points

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.

Key checks
  • virsh list --all — VMs and state
  • virsh dominfo <vm> — CPU, memory, autostart
  • virsh domiflist <vm> / domblklist <vm> — NICs and disks
  • lscpu | 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:///system connects to the system-wide daemon that supervises QEMU/KVM domains, as root.
  • qemu:///session connects as a normal user to that user's own domains.

It also documents the domain commands:

  • list shows running domains, with --all for inactive ones too.
  • define registers a domain from XML without starting it.
  • destroy kills a domain immediately (the manual recommends shutdown in most cases), without deleting its storage.
  • autostart starts a domain at host boot.
  • dominfo, domblklist and domifaddr show details, disks, and IP and MAC addresses.
  • console connects to the serial console.

Everyday virsh commands

TaskCommand
List all VMsvirsh list --all
Start / clean shutdown / force offvirsh start web01, virsh shutdown web01, virsh destroy web01
Start at host bootvirsh autostart web01
Show and edit the definitionvirsh dumpxml web01, virsh edit web01
Disks and addressesvirsh domblklist web01, virsh domifaddr web01
Serial consolevirsh console web01 (leave with Ctrl-])
Snapshotsvirsh snapshot-create-as web01 pre-upgrade, virsh snapshot-list web01
Networks and storagevirsh 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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

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%
Technical changelog & impact

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.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

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.

Aliases that resolve here
libvirtlibvirt domain xmllinux vm management
Embedded reference data

Quick lookup tables

libvirt operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for libvirt.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective statelibvirt 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 verificationPin 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 chainlibvirt connection → domain XML → storage/network references → define/start operation → QEMU/KVM live state → guestTrace requested/configured state through effective state to the observed workload result.
Failure boundarylibvirt 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 evidenceCorrelated Linux container/virtualization evidence can establish this proof path: libvirt connection → domain XML → storage/network references → define/start operation → QEMU/KVM live state → guestUse this observation only for the specific claim it actually supports.
Evidence limitIt 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 checkContinue 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 boundarylibvirt
Topic pathVirtualization → libvirt
Runtime statelibvirt 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 chainlibvirt 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 boundarylibvirt 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 ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.
Confirmation

Confirm action

Continue?