Error opening a virtual machine using kvm and virtual machine manager
Problem:
Open the virtual machine manager (virt-manager), select a virtual machine, and click Open. Then, this error appears:
Error starting domain: unsupported configuration: Domain requires KVM, but it is not available. Check that virtualization is enabled in the host BIOS, and host configuration is setup to load the kvm modules.
This error appears in Ubuntu 24.04 with Kernel Linux 6.14.0-1019-oem.
Solution:
Solution 01. Load manually.
Load the kvm module; it’s different for AMD or Intel CPUs.
Step by step:
- Open a Terminal
for Intel cpu:sudo modprobe kvm_intelfor AMD cpu:
sudo modprobe kvm_amdNote: if you don’t know the CPU architecture of your computer, try:
lscpu | grep 'Model name:' - Verify it loaded:
lsmod | grep -E '(kvm_intel|kvm_amd)'The output should be a line with
kvm_intelorkvm_amd.
Solution 02. Load the kvm module automatically at startup.
Step by step:
- Create a .conf file.
for Intel cpu:cd /etc/modprobe.d/ sudo echo "options kvm_intel nested=1" > mykvm.conffor AMD cpu:
cd /etc/modprobe.d/ sudo echo "options kvm_amd nested=1" > mykvm.conf - Restart your computer using the GUI or type in a Terminal:
sudo reboot - (optional) If, after reboot, the error appears again try this last step:
sudo update-initramfs -uand reboot again.
NOTE⚠️: if you have installed Oracle VirtualBox, verify this!
Conflict with VirtualBox (Kernel 6.12+) If you are using a newer Ubuntu kernel (6.12+), KVM initializes immediately upon loading, locking the CPU and preventing VirtualBox from running.
- Solution: You can add
kvm.enable_virt_at_load=0to the kernel boot parameters.- If you’re using Grub on a Debian derivative (e.g. Ubuntu), edit
/etc/default/grub, add the parameterkvm.enable_virt_at_load=0toGRUB_CMDLINE_LINUX_DEFAULT, and runsudo update-grub.
- If you’re using Grub on a Debian derivative (e.g. Ubuntu), edit
NOTE⚠️: Verify the kvm module is not in a blacklist file.
If the error persists after completing all previous steps, try this.
grep -E -r "(kvm_intel|kvm_amd)" /etc/modprobe.d/
If you get output like this:
/etc/modprobe.d/blacklist-kvm.conf:blacklist kvm_intel
/etc/modprobe.d/blacklist-kvm.conf:blacklist kvm_amd
You can delete or rename this file:
sudo mv /etc/modprobe.d/blacklist-kvm.conf /etc/modprobe.d/blacklist-kvm.confBACKUP
Reboot again!
Sources:
https://www.ibm.com/docs/en/linux-on-systems?topic=kvsi-set-up-kvm-host-3
https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/sect-nested_virt_setup
https://askubuntu.com/a/232318/822132
https://unix.stackexchange.com/a/798135/289210