24

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).

patreu22
  • 2,988
  • 4
  • 22
  • 31

2 Answers2

53

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
Digital Trauma
  • 15,475
  • 3
  • 51
  • 83
Gerd Hoffmann
  • 741
  • 6
  • 3
  • @patreu22 I too want to get KVM on my mac but don't know how to start. Can you please point me the correct direction. – Naxi Nov 21 '19 at 06:26
  • 2
    Hey @Naxi , as pointed out by Gerd KVM doesn't work for Mac, the solution is to go with Qemu and accelerate it via hvf. Here is a guide how to do this: https://graspingtech.com/ubuntu-desktop-18.04-virtual-machine-macos-qemu/ – patreu22 Nov 21 '19 at 10:04
  • 5
    @patreu22 following the guide it showed "The -accel and "-machine accel=" options are incompatible". Removing "-accel hvf" it showed "invalid accelerator kvm". It runs only when "-accel hvf" and no "-enable-kvm" – ロジャー Jul 02 '20 at 02:14
  • 2
    The answer lacks the detail how to apply the "`accel=hvf`". – Nakilon Feb 01 '21 at 08:37
  • 1
    @Nakilon Passing `-accel hvf` on the qemu-system-x86_64 command line worked for me. – Digital Trauma Feb 03 '21 at 21:30
3

Make sure your command doesn't include -enable-kvm or kvm=on in -cpu

This worked for me:

$ qemu-system-x86_64 -m 2048 -vga virtio -display cocoa,show-cursor=on -usb -device usb-tablet -cdrom ~/VMs/isos/ubuntu-18.10-live-server-amd64.iso -drive file=~/VMs/qemu/ubuntu-server-18.04.qcow2,if=virtio -accel hvf -cpu Penryn,vendor=GenuineIntel
svyat1s
  • 868
  • 9
  • 12
  • 21