Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 813
patreu22 Avatar asked Dec 14 '18 10:12

patreu22


People also ask

How do I enable KVM on QEMU?

Enabling KVM To start QEMU in KVM mode, append -accel kvm to the additional start options. To check if KVM is enabled for a running VM, enter the #QEMU monitor and type info kvm .

Can I use KVM on Mac?

While most KVM Switch solutions are designed to be driver-free, and are compatible with all operating systems including Mac OS, some newer KVMs are designed to be compatible and optimize the experience with Mac computers, for example allowing customizable keyboard shortcuts, or Adders' "MagicEye" technology which ...


2 Answers

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
like image 137
Gerd Hoffmann Avatar answered Sep 22 '22 10:09

Gerd Hoffmann


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
like image 25
Javier Velador Avatar answered Sep 23 '22 10:09

Javier Velador