How I fixed libvirt error: unsupported configuration: Emulator '/usr/bin/qemu-system-x86_64' does not support virt type 'kvm'

Problem

When trying to define a domain in libvirt on a new server, I encountered the following error:

example.sh
$ virsh define domain.xml
error: Failed to define domain from domain.xml
error: unsupported configuration: Emulator '/usr/bin/qemu-system-x86_64' does not support virt type 'kvm'

while KVM was setup properly:

example.sh
$ kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used

Solution

The issue in my case was that the user virsh was running as, was not a member of the kvm group.

First, determine the user using

example.txt
$ grep "user =" /etc/libvirt/qemu.conf
#       user = "qemu"   # A user named "qemu"
#       user = "+0"     # Super user (uid=0)
#       user = "100"    # A user named "100" or a user with uid=100
#user = "libvirt-qemu"
swtpm_user = "swtpm"

The line you need to look for is user = "libvirt-qemu" - whether commented out or not.

In my case, the user was just the default libvirt-qemu. To fix the issue, I added this user to the kvm group:

example.sh
sudo usermod -aG kvm libvirt-qemu

After that, you need to restart the libvirt daemon:

example.sh
sudo systemctl restart libvirtd

then, you should be able to define the domain without any issues:

example.sh
virsh define domain.xml

Check out similar posts by category: Virtualization, Linux