When you launch a KVM virtual machine using -accel kvm, you are telling QEMU to attempt to use the KVM hypervisor. However, various factors can prevent it from actually using KVM, causing it to fall back to software emulation (TCG) without explicitly telling you.
Here's how you can check if your virtual machine is truly running with KVM acceleration:
Host-Side Checks (Most Reliable)
These checks are performed on the host machine where QEMU is running. They are the most definitive way to confirm KVM usage.
-
Check if QEMU is using /dev/kvm (Most Reliable Method):
QEMU needs to open the /dev/kvm device file to interact with the KVM kernel module. If it's not open, KVM is not being used.
sudo lsof /dev/kvm
Expected Output (example):
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
qemu-syst 123456 qemu 7uW CHR 10,23 0t0 1485 /dev/kvm
- Look for a
qemu-system-... command in the output. If you see it, KVM is being used by that QEMU process.
- If no output, or if you only see other processes (like
kvm-irqfd-clean if a VM just shut down), then no QEMU process is currently using /dev/kvm.
-
Check QEMU Process Arguments:
Confirm that the -accel kvm (or implied KVM acceleration by using a KVM-specific QEMU binary) is present in the running command.
ps aux | grep -i '[q]emu' | grep -i 'kvm'
(The [q]emu trick prevents grep from finding itself)
Expected Output (example):
user 123456 99.0 0.1 1234567 87654 ? Sl 10:00 00:01:23 /usr/bin/qemu-system-x86_64 -accel kvm ...
- Caveat: This only tells you that KVM was requested. It doesn't guarantee it's active. Use
lsof /dev/kvm for that.
-
Check KVM Kernel Modules:
Ensure the necessary KVM kernel modules are loaded. While this doesn't guarantee a VM is using KVM, it's a prerequisite.
lsmod | grep kvm
Expected Output (example):
kvm_intel 286720 1
kvm 872448 1 kvm_intel
- You should see
kvm and either kvm_intel (for Intel CPUs) or kvm_amd (for AMD CPUs).
-
Monitor CPU Usage (Indirect):
- If KVM is active, the guest VM's CPU usage will largely translate directly to the host CPU. Performance will be near-native.
- If KVM falls back to TCG (software emulation), a single guest CPU core can easily consume 100% of a host CPU core, even if the guest is idle, because all CPU instructions are being translated. Performance will be significantly worse.
- Use
top, htop, or glances on the host and observe the qemu-system-... process's CPU usage.
-
For Libvirt-managed VMs:
If you're using libvirt (e.g., with virt-manager), libvirt provides a way to check:
virsh domstats <your_vm_name> --vcpu
Expected Output (example):
...
util.vcpu.0.state=running
util.vcpu.0.time=68641544
util.kvm.present=1 <-- This indicates KVM is active
...
- Look for
util.kvm.present=1. If it's 0 or missing, KVM is not being used.
Guest-Side Checks (Less Reliable, but Informative)
These checks are performed inside the virtual machine. While useful, a sophisticated, non-KVM hypervisor could potentially spoof these indicators.
-
Check /proc/cpuinfo:
KVM passes through the CPU virtualization extensions (VMX for Intel, SVM for AMD) to the guest.
cat /proc/cpuinfo | grep -E 'vmx|svm'
Expected Output:
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb invpcid_single kaiser fsgsbase bmi1 hle rtm emi tm cqm rdt_a rdseed adx smap clflushopt intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves dtherm arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req
- You should see
vmx (Intel) or svm (AMD) in the flags line.
- Caveat: QEMU can emulate these flags even when running in TCG mode, especially if the host CPU has them. So, while necessary for KVM, their presence alone doesn't guarantee KVM usage.
-
virt-what (Linux Guest):
A utility specifically designed to detect if the system is running in a virtual machine and what type.
sudo apt install virt-what # Debian/Ubuntu
sudo yum install virt-what # CentOS/RHEL/Fedora
virt-what
Expected Output:
kvm
or
qemu
kvm is ideal, qemu is also good as QEMU is the frontend for KVM.
-
systemd-detect-virt (Linux Guest with systemd):
Similar to virt-what, part of systemd utilities.
systemd-detect-virt
Expected Output:
kvm
or
qemu
-
Windows Guest - Task Manager:
- Open Task Manager (Ctrl+Shift+Esc).
- Go to the "Performance" tab.
- Select "CPU".
- Look for "Virtualization" under the graphs. It should say "Enabled".
- While this shows that hardware virtualization extensions are presented to the guest, it doesn't explicitly state KVM, but rather that the guest use hardware virtualization.
Why KVM Might Not Be Used Even With -accel kvm
- No Hardware Virtualization: Your host CPU doesn't support Intel VT-x or AMD-V, or it's disabled in the BIOS/UEFI.
- KVM Kernel Modules Not Loaded:
kvm_intel or kvm_amd (and kvm) are not loaded on the host. This can happen if KVM is not installed, or if there's a problem with the kernel.
- Permissions Issues: The user running QEMU doesn't have read/write access to
/dev/kvm. Add the user to the kvm group: sudo usermod -aG kvm $USER and then log out and back in.
- Conflicting Hypervisor: Another hypervisor (like VMware Workstation or VirtualBox) is running and has exclusive access to the hardware virtualization features.
- Old QEMU Version: Very old versions of QEMU might have issues or different default behaviors.
In summary, the most reliable way to check is on the host system:
sudo lsof /dev/kvm: This is the golden standard. If you see your qemu-system-... process here, KVM is active.
virsh domstats <vm_name> --vcpu: If using libvirt, this provides a clear util.kvm.present=1 indicator.
Combine these with the guest-side checks for a complete picture.