Common virsh workflows
This page groups the virsh commands that usually travel together during provisioning, incident handling, and cleanup. Inventory and inspect first Do this before changing anything. list all Use virsh list all when you nee
This page groups the virsh commands that usually travel together during provisioning, incident handling, and cleanup.
Inventory and inspect first
Do this before changing anything.
virsh -c qemu:///system list --all
virsh dominfo vm01
virsh dumpxml vm01 | less
virsh domblklist vm01
virsh domiflist vm01list --all
Use virsh list --all when you need the authoritative inventory for the current URI, including shut off guests.
dumpxml
Use virsh dumpxml before assuming anything about disks, interfaces, firmware, consoles, or security labels.
Start, stop, and console access
virsh start vm01
virsh reboot vm01
virsh shutdown vm01
virsh destroy vm01
virsh console vm01Use shutdown first. Reserve destroy for the same situations where you would force-stop a process.
start
virsh start asks libvirt to boot a defined guest without forcing a configuration change.
shutdown
virsh shutdown is the graceful stop path and should be your default before you escalate to destroy.
console
virsh console DOMAIN attaches your terminal to a text console exposed by the running guest. It is useful when guest networking or SSH is unavailable because the connection travels through libvirt rather than through the guest network.
virsh console vm01The domain must be running and its definition must expose a serial or console device. The guest operating system must also be configured to present a serial console or login prompt on that device.
If the command connects but you see no useful output, inspect both sides of that boundary before assuming libvirt is broken:
virsh domstate vm01
virsh ttyconsole vm01
virsh dumpxml vm01 | grep -A8 -E '<(serial|console)'virsh ttyconsole vm01 reports the host-side pseudo-terminal associated with the guest console when one is available. The XML shows whether libvirt has a serial/console device configured; the guest still needs its own kernel console and/or getty configuration to use it.
To leave an attached virsh console session, use the default escape sequence Ctrl+]. That disconnects your terminal from the console; it does not stop the virtual machine.
A domain name is the final argument, so the same operation against a guest named bridge-record follows the same shape:
virsh console DOMAINSubstitute the actual domain name only after you have identified the target you intend to attach to.
Snapshot and migration checks
virsh snapshot-list vm01
virsh domjobinfo vm01
virsh migrate --live vm01 qemu+ssh://hv-b/systemSafe cleanup
virsh undefine vm01 --nvram
virsh undefine oldvm --remove-all-storageRead the XML and storage mapping before using the storage removal flags. They are convenient and easy to misuse.
connect
Use virsh connect URI when you want to switch the interactive shell to a different libvirt endpoint without restarting the client.