Pcornel
Linux · Virtualization

libvirt

Cheat sheet · https://pcornel.dk/topic.php?topic=2900

Back to the Topic

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.

Remember

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.

First 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

Commands

virsh
virsh list --all
virsh start web01
virsh shutdown web01
virsh destroy web01
virsh autostart web01
virsh dumpxml web01
virsh edit web01
virsh domblklist web01
virsh domifaddr web01
virsh console web01
virsh snapshot-create-as web01 pre-upgrade
virsh snapshot-list web01
virsh net-list --all
virsh pool-list --all
virsh vol-list default

Verify in this order

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

Where it usually breaks

First mismatch in hardware/kernel capability → scheduler/mm/device → cgroup/namespace → process/thread → service/runtime → workload behavior/counters; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2900

Confirmation

Confirm action

Continue?