Libvirt¶
Check Libvirt is Running¶
sudo systemctl status libvirtd
Start Libvirt¶
sudo systemctl start libvirtd
sudo systemctl enable libvirtd
Connection Errors¶
If you get connection errors, verify the libvirt socket is accessible.
virsh -c qemu:///system list
If this fails with a permission error, ensure your user is in the libvirt group.
sudo usermod -aG libvirt $USER
Log out and back in for the group change to take effect.
Domain Commands¶
List Domains (VMs)¶
virsh list --all
Show Domain XML¶
virsh dumpxml <domain_name>
Force Stop a Domain¶
virsh destroy <domain_name>
Remove a Domain¶
virsh undefine <domain_name>
Networking¶
List Networks¶
virsh net-list --all
Show Network XML¶
virsh net-dumpxml <network_name>
Storage¶
List Storage Pools¶
virsh pool-list --all --detailed
Show Pool Info¶
virsh pool-info <pool_name>
Show Pool XML¶
virsh pool-dumpxml <pool_name>
Nested Virtualization¶
If VMs are slow or fail to start, check that nested virtualization is enabled.
cat /sys/module/kvm_intel/parameters/nested
If it returns N, enable it:
sudo modprobe -r kvm_intel
sudo modprobe kvm_intel nested=1
To make it persistent, create /etc/modprobe.d/kvm.conf:
options kvm_intel nested=1
For AMD processors, replace kvm_intel with kvm_amd.