MARGA by EknathaLabs

"Virtualization" cheat sheet

"virsh, qemu-img, bridges and migration commands, with the checks that explain a guest that will not start or a host that is slow."

Guests

virsh list --all
virsh start web-1
virsh shutdown web-1        # clean, asks the guest OS
virsh destroy web-1         # power off, like pulling the plug
virsh dominfo web-1
virsh console web-1
virsh domstate web-1 --reason

Memory and CPU

virsh nodememstats
virsh setmem web-1 4G --live
virsh setvcpus web-1 4 --live
virsh vcpuinfo web-1
free -m
grep -E "steal|st" <(top -bn1 | head -4)

Steal time above a few percent means the host CPU is oversubscribed.

Disks and snapshots

qemu-img info disk.qcow2
qemu-img create -f qcow2 -b base.qcow2 -F qcow2 overlay.qcow2
virsh pool-list
virsh pool-info default
virsh snapshot-list web-1
virsh snapshot-create-as web-1 before-upgrade
virsh snapshot-delete web-1 before-upgrade

Network

virsh domiflist web-1
virsh net-list --all
ip link show type bridge
bridge link
bridge vlan show

Migration

virsh migrate --live web-1 qemu+ssh://host2/system
virsh domjobinfo web-1
virsh domjobabort web-1

If dirty rate is above bandwidth, the migration will not converge.

Quick diagnosis

Symptom First look
Guest will not start error text, free host memory, pool space
Guest paused (ioerror) pool full or storage fault
Everything slow host swap, steal time, disk latency
No network domiflist, bridge exists, VLAN allowed on the switch

Quick host checks

virsh list --all
virsh nodememstats
virsh domstats --cpu-total web-1
virsh pool-list --details
virsh domblklist web-1

Cautions

Official references

Read the vendor and project documentation for the full, current detail.