Enabling vPMU on Guest VMs (KVM)

When running a VM using KVM by means of the qemu-system-x86_64 command, your VMs may not have access to the performance monitoring unit.

To check if you have access to PMU drivers, run the following command in your VMs:

$ dmesg | grep PMU
[ 0.307792] Performance Events: PMU not available due to virtualization, using software events only.

PMU not available!

What you need to do when invoking qemu-system-x86_64 is to add the following argument: -cpu host

$ dmesg | grep PMU
[ 0.314750] Performance Events: Skylake events, full-width counters, Intel PMU driver.

Yes! Now we get access to PMUs on the guest VM, meaning we can use the performance counters offered through perf stat and more tools!

Leave a comment