Qemu on MacOSX with Hypervisor Framework

Running qemu on a linux platform means you have the ability to use hardware acceleration via KVM. This allows you to access the virtualization features of your processor. For MacOSX we aren’t as lucky since there currently is no port of KVM for MacOSX.

As of MacOSX 10.10 apple introduced hypervisor.framework which is their way of acccessing the virtualisation features of the processor. The downside to hypervisor.framework is it isn’t as readily supported in other applications such as Qemu. It also doesn’t have the ability to do nested virtualization which is important if you want to run something like EVE-NG.

Patched Qemu overview

There is currently work being performed to make a patch for Qemu here Patchew. The patch takes code from a modified version of a Qemu fork which is available here: Android Emulator. This code in turn was taken from a project called Veertu. Hopefully this project will be finished and make it upstream but for now, you can use the fork.

Installing patched Qemu

Download the code

The command below will download the code in to a locally directory called qemu.

1
git clone --branch patchew/20170905035457.3753-1-Sergio.G.DelReal@gmail.com --single-branch --depth 1 https://github.com/patchew-project/qemu.git

Build and install the patched Qemu code

Next we can build the code.

1
2
3
4
cd qemu
./configure --enable-cocoa --target-list=x86_64-softmmu --disable-vnc --enable-hvf
make
make install

Launch Qemu

The two switches are required to use the hypervisor.framework

1
/usr/local/bin/qemu-system-x86_64 -M accel=hvf --cpu host