Build virsh commands for KVM and libvirt. Manage local or remote VMs, lifecycle, CPU, memory, console, XML, saved state, media, and deletion safely.
virsh is the primary command-line interface for libvirt. It manages virtual machine domains and related libvirt resources, most commonly QEMU/KVM guests on Linux.
qemu:///system connects to the system-wide libvirt daemon and is the normal choice for servers, shared storage, bridges, and administrator-managed VMs. qemu:///session manages VMs owned by the current user and has more limited access to system networking and storage.
No. virsh shutdown sends a clean shutdown request to the guest and returns before the shutdown necessarily finishes. Use virsh domstate to check progress. virsh destroy is the immediate power-off equivalent and risks data loss.
--live changes the currently running VM. --config changes the persistent definition used at the next boot. Supplying both requests the change now and after future starts, when the selected operation and hypervisor support both.
Use a libvirt SSH URI such as virsh --connect qemu+ssh://admin@kvm-host.example.com/system list --all. SSH key authentication is recommended, and the remote account must be authorized to access the system libvirt daemon.
The VM needs a serial device and the guest operating system must be configured to use a serial console. For many Linux guests that means enabling a ttyS0 console in the kernel command line and starting a serial getty. Press Ctrl+] to leave virsh console.
Not by default. virsh undefine removes the persistent domain definition while preserving storage. Adding --remove-all-storage tells libvirt to delete managed volumes too and should be treated as irreversible.