KVM/QEMU: Hardware acceleration not working

8,248

I really searched the web quite some time for the answer but did not find a solution. As it is so often: once asked, you quickly have the solution:

When starting the machine, I had to explicitly tell QEMU to use KVM by adding the option

-machine type=pc,accel=kvm

now I get a much faster VM and

$lsmod | grep kvm            
kvm_intel             180224  3
kvm                   708608  1 kvm_intel
irqbypass              16384  1 kvm

However virtio is still 0

I am still confused why this is necessary, because everything I read so far implicates or sais explicitely that qemu tries using kvm by default (and throws an error when fails). So if anyone knows why this is not the case for me I would still be grateful.

Share:
8,248

Related videos on Youtube

Bloch
Author by

Bloch

Updated on September 18, 2022

Comments

  • Bloch
    Bloch over 1 year

    I was trying to install my first virtual machine with KVM and QEMU but it does seem to use hardware acceleration as intended. I came to that conclusion first because it is terribly slow and second because of the output of

    $lsmod | grep kvm
    kvm_intel        180224 0
    kvm              708698 1 kvm_intel
    irqbypass         13284 1 kvm
    

    when the machine is running, the value of kvm_intel should be 1, correct?

    My host machine is a Dell XPS 13 running Arch Linux (recently updated of course). The guest system is Arch as well. Both 64 bit.

    I checked everything I found on https://wiki.archlinux.org/index.php/KVM, concluding, that my hardware supports virtualization:

    $'LC_ALL=C lscpu | grep Virtualization
    Virtualization:      VT-x
    

    and that the kernel modules are included and loaded:

    $zgrep CONFIG_KVM /proc/config.gz
    CONFIG_KVM_GUEST=y               
    # CONFIG_KVM_DEBUG_FS is not set
    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=m
    CONFIG_KVM_INTEL=m
    CONFIG_KVM_AMD=m
    CONFIG_KVM_AMD_SEV=y
    CONFIG_KVM_MMU_AUDIT=y
    

    The same for virtio

    $zgrep VIRTIO /proc/config.gz
    CONFIG_BLK_MQ_VIRTIO=y
    CONFIG_VIRTIO_VSOCKETS=m
    CONFIG_VIRTIO_VSOCKETS_COMMON=m
    CONFIG_NET_9P_VIRTIO=m
    CONFIG_VIRTIO_BLK=m
    # CONFIG_VIRTIO_BLK_SCSI is not set
    CONFIG_SCSI_VIRTIO=m
    CONFIG_VIRTIO_NET=m
    CONFIG_CAIF_VIRTIO=m
    CONFIG_VIRTIO_CONSOLE=m
    CONFIG_HW_RANDOM_VIRTIO=m
    CONFIG_DRM_VIRTIO_GPU=m
    CONFIG_VIRTIO=m
    CONFIG_VIRTIO_MENU=y
    CONFIG_VIRTIO_PCI=m
    CONFIG_VIRTIO_PCI_LEGACY=y
    CONFIG_VIRTIO_BALLOON=m
    CONFIG_VIRTIO_INPUT=m
    CONFIG_VIRTIO_MMIO=m
    CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
    CONFIG_RPMSG_VIRTIO=m
    CONFIG_CRYPTO_DEV_VIRTIO=m
    

    check if loaded (see top for kvm):

    $lsmod | grep virtio
    virtio        16384  0
    

    Again, virtio seems not to be used. Am I interpreting this correctly?

    I also checked, that virtualization support is turned on in the BIOS (recent A15 version provided by Dell in February this year), which it was all the time.

    The user is in the group kvm (which it was not when installing the virtual machine, could that be the problem?)

    The page I found https://warpedtimes.wordpress.com/2010/01/06/hardware-accelerated-virtualization-with-qemu-and-kvm/ enouraged me in the idea that there is something wrong, but none of the proposed problems apply. I also do not get an error message from QEMU and do not see anything kvm or virtio related in dmesg.

    Network is working fine, resolution is VGA like but I did not yet investigate on that. So this could be a configuration thing.

    The disk file is raw and I start the VM with the -m 1024 option. Boot mode is legacy (I could not figure out how to make kvm boot in uefi mode).

    Does anyone have an idea what my problem is? Is there another way to check if hardware acceleration is actually working? But it is really extremely slow. Starting up as well as running. My Windows in Virtualbox runs a lot faster. Might there be a different problem?

    Does anyone have an idea what my problem is? I posted all the information I thought might be interesting. Do you need additional information?

    Thanks a lot in advance

    • Bloch
      Bloch about 6 years
      Pleased to hear that how I presented my question is well received. Ah, this is very helpful. I think will investigate more about the QEMU monitor as it seems to be there for a reason ;) Could you specifiy what you mean by "the emulator might ignore the availability of virtualization"?
  • Bloch
    Bloch about 6 years
    thanks for the comment. I figured that out, too. However, this does not really surprise compared to that it does not use kvm. I found several tutorials as the one linked in the initial question that uses this simple command to open the VM and claim that it does use kvm