Install and configure KVM

July 2, 2026

emerge -uav kvm app-emulation/qemu virt-manager dev-libs/libisoburn bridge-utils

Important notes from the emerge output:

For QEMU/KVM:

  • Load the appropriate kernel module: kvm-amd for AMD CPUs or kvm-intel for Intel CPUs
  • Add your user to the kvm group: gpasswd -a <USER> kvm
  • Reset permissions if needed: udevadm trigger -c add /dev/kvm

For libvirt:

  • Enable libvirt-guests for client handling during shutdown/restart
  • If using dnsmasq, configure bind-interfaces and interface or except-interface in /etc/dnsmasq.conf
  • Add users to the libvirt group for administrative access

Start the service

/etc/init.d/libvirtd start
rc-update add libvirtd default

Troubleshooting

If you get this error:

# virsh list
error: failed to connect to the hypervisor
error: Operation not supported: Cannot use direct socket mode if no URI is set

Edit /etc/libvirt/libvirt.conf:

#uri_default = "qemu:///system"
uri_default = "qemu:///session"