macosvirtualizationqemukvmmacos-mojave

How to enable KVM on a Mac for Qemu?


I'm virtualizing a machine for the first time on my Mac with Qemu (for an university assignment, so it's not possible to change the tool).
We have to compare some measurements between a VM running on KVM and one without KVM.
I tried to start the KVM machine by calling qemu-system-x86_64 my.qcow2 -enable-kvm but I'm getting this error:
qemu-system-x86_64: -machine accel=kvm: No accelerator found

I checked sysctl -a | grep machdep.cpu.features and that`s my output:

machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC MOVBE POPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C

As there is VMX listed I assume my Macbook supports KVM and by default it should be enabled as far as I understood.
So why am I getting this error and does anybody have a solution to that?
Btw. my Macbook Pro is a Retina, 13' Mid 2014 version running 10.14.1 (18B75).


Solution

  • kvm is the linux hypervisor implementation, that isn't going to work. Recent qemu version have support for the macos hypervisor framework, use accel=hvf for that.

    For example:

    qemu-system-x86_64 -m 2G -hda ubuntu.20.qcow2 -accel hvf