If you’re running macOS with QEMU, you’ll notice that the UI might be slow. This is because, by default, QEMU will use a basic display adapter with low display memory (VRAM).

There’s two ways to fix this problem:

  • Pass-through your GPU with vfio
  • Use another display adapter, such as VMsvga2

This post will focus on VMsvga2, which is a macOS kext that enables you to use the vmvga video model with libvirt.

Unfortunately VMsvga2 is an old project that is no longer maintained, same goes for the vmvga QEMU driver. Currently there’s no QXL driver available for macOS so this is the only choice we have.

Simply replace your existing video XML with this:

  <model type='vmvga' vram='16384' heads='1'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/> 

You can increase the vram to the amount you desire.
If you are using the Clover bootloader, you might have to add wmv_option_fb=0x06 to the arguments section in your config.plist

You will also need to make sure you have the VMsvga2 kext installed on your system.

Once you reboot, you’ll notice a more responsive UI.


Resizing an OSX VM with apfs and QEMU

Looking to resize an existing qcow2 or raw data volume with QEMU?

I had to do the same thing and went through some trouble in trying to do this. My first idea was to use GParted and boot from the live-cd iso to extend the apfs partition. However, it turns out that GParted does not support apfs (yet?).

First, you’ll need to expand the disk space available to the VM. Depending on the disk format, you can use:

  • qcow2: qemu-img resize image.qcow2 +20G
  • lvm: lvextend -L /dev/lvmpool/vm +20G

Now you can expand the apfs container from inside the OSX VM. Simply find out the identifier of your partition:

/usr/sbin/diskutil info / | awk '/Part of Whole/ {print $4}'

And use that identifier together with this command:

/usr/sbin/diskutil apfs resizeContainer /dev/{identifier} 0

This will expand to use up all available free disk space.


Content Caching on OSX VMs

Apple’s Content Caching is not available when running OSX in a VM.

It seems Apple is detecting if it’s running inside a VM:

$ sudo /usr/bin/AssetCacheManagerUtil activate
AssetCacheManagerUtil[] Failed to activate content caching: Error Domain=ACSMErrorDomain Code=5 "virtual machine"...

To get around this, you can patch the kernel to remove the cpuid features check:

  • First disable SIP
  • Next: sudo mount -uw /
  • /System/Library/Kernels/kernel
  • sudo kextcache -i /