Cannot open /dev/kvm qemu/kvm error

hello, i have a problem adding an image in qemu

I have installed everything according to this instructions.
as soon as i want to add an image in qemu, i get the following error message

Warning. KVM is not available. The KVM package may not be installed or the KVM kernel modules may not be loaded.

it looks like this
kvm

systemctl status libvirtd.service
$ systemctl status libvirtd.service
● libvirtd.service - Virtualization daemon
     Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: disabled)
     Active: active (running) since Fri 2022-06-24 15:18:07 CEST; 58s ago
TriggeredBy: ● libvirtd-ro.socket
             ● libvirtd-admin.socket
             ● libvirtd.socket
       Docs: man:libvirtd(8)
             https://libvirt.org
   Main PID: 629 (libvirtd)
      Tasks: 21 (limit: 32768)
     Memory: 33.2M
        CPU: 194ms
     CGroup: /system.slice/libvirtd.service
             ├─629 /usr/bin/libvirtd --timeout 120
             ├─815 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-s>
             └─816 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-s>

Jun 24 15:18:08 ryzen dnsmasq[815]: reading /etc/resolv.conf
Jun 24 15:18:08 ryzen dnsmasq[815]: using nameserver 192.168.2.1#53
Jun 24 15:18:08 ryzen dnsmasq[815]: read /etc/hosts - 5 addresses
Jun 24 15:18:08 ryzen dnsmasq[815]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Jun 24 15:18:08 ryzen dnsmasq-dhcp[815]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Jun 24 15:18:08 ryzen libvirtd[629]: libvirt version: 8.4.0
Jun 24 15:18:08 ryzen libvirtd[629]: hostname: ryzen
Jun 24 15:18:08 ryzen libvirtd[629]: Kann /dev/kvm nicht öffnen: Datei oder Verzeichnis nicht gefunden
Jun 24 15:18:10 ryzen dnsmasq[815]: reading /etc/resolv.conf
Jun 24 15:18:10 ryzen dnsmasq[815]: using nameserver 192.168.2.1#53

i do not understand this error.
Cannot open /dev/kvm: File or directory not found
how can i solve this?

Thanks in advance!

Did you check if your CPU supports KVM (see the arch wiki)?

If yes, you may need to activate it inside the bios.

1 Like

yes it does

LC_ALL=C.UTF-8 lscpu | grep Virtualization
Virtualization:                  AMD-V

Is it activated inside the BIOS?

If yes, see the next chapter on the arch wiki and check if the modules are loaded. If not, load them yourself via modprobe.

edit:
should be

sudo modprobe kvm_amd

yes it is.

which module do i have to load? I’m sorry for stupid questions. I don’t do this every day. So to speak the first time that I handle qemu

uname -r 
5.18.6-zen1-1-zen

zgrep CONFIG_KVM /proc/config.gz
CONFIG_KVM_GUEST=y
CONFIG_KVM_MMIO=y
CONFIG_KVM_ASYNC_PF=y
CONFIG_KVM_VFIO=y
CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT=y
CONFIG_KVM_COMPAT=y
CONFIG_KVM_XFER_TO_GUEST_WORK=y
CONFIG_KVM=m
CONFIG_KVM_INTEL=m
CONFIG_KVM_AMD=m
CONFIG_KVM_AMD_SEV=y
CONFIG_KVM_XEN=y
CONFIG_KVM_EXTERNAL_WRITE_TRACKING=y

Use this command

lsmod | grep kvm

There should be some entry saying kvm_amd. If it returns nothing the module isn’t loaded. Then do this:

sudo modprobe kvm_amd

I’m not sure if it’s necessary, but also check if libvirt is installed. If not try installing it.

this command outputs nothing

sudo modprobe kvm_amd            
[sudo] Passwort für swh: 
modprobe: ERROR: could not insert 'kvm_amd': Operation not supported

hmm…

what happens if you just do

sudo modprobe kvm?

I’m not sure what other things to try. Maybe someone else has another idea.

this

$ lsmod | grep kvm     
kvm                  1200128  0
irqbypass              16384  1 kvm

thanks for your help anyway

silly me…checked again, it wasnt :laughing:

sudo modprobe kvm_amd

lsmod | grep kvm     
kvm_amd               176128  0
kvm                  1200128  1 kvm_amd
irqbypass              16384  1 kvm
ccp                   143360  1 kvm_amd

everything works fine… :+1: :enos:

3 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.