Running Mac OS X as a QEMU/KVM Guest
Tl;dr Below is my virtual setup, but its running way too fast (probably due to a wrong busspeed). It is fixed now with newer Clover versions. Read the whole thread to know how its done. This is not a guide (yet) Hardware: - CPU: i7-4790K Board: Gigabyte Z97-UD5H GPU: nVidia GTX 770 S.
- On the QEMU side of things, everything should be included in QEMU 2.1. The last required piece was the kvm=off cpu option, which is necessary for Nvidia 340+ guest drivers. On the kernel side, this setup requires only the i915 patch since IGD is my host graphics.
- Dec 22, 2013 This is a driver for using the virtio ethernet device from OS X guests. In VirtualBox, this device is known as the 'Paravirtualised Network (virtio-net)'. Download the latest virtio-net driver installer to your VirtualBox or Qemu virtual machine running OS X 10.7 or newer. Run the installer.
Gabriel L. Somlo
See the old version of this page here.FINAL UPDATE (2018-10-21):I no longer have the cycles to work on this project. At this point QEMU and KVM are mostly capable of supporting OS X (up to Sierra), and the largest portion of the effort still required lies with edk2/ovmf (start with my fork on github as indicated below, and go from there).
Additionally, since Apple machines have become increasingly lockeddown and end-userunfriendly, I can't continue considering them for any upcoming hardware refresh (which is too bad, they used to make almost perfect Linux machines for the last 20 years!).
NOTE: Installer .iso images prepared based on Sierra 10.12.4 or later will hang during boot. However, guest images installed with 10.12.3 or earlier can successfully be upgraded, assuming the applesmc fix mentioned above is applied. The cause for this is as of yet unknown (to me, at least).
1. Prerequisites
You will need the following:- Tools: git, gcc[-c++], nasm, [auto]make, iasl, kernel-devel, etc.
- Linux kernel ≥ 4.7
- QEMU ≥ 2.6.0
- Patched OVMF firmware, built from source
2. Creating an OS X boot DVD iso image
SnowLeopard (10.6) was the last OS X version released in DVD format. Starting with Lion (10.7), an install DVD (.iso) image may be generated on an OS X machine by following the steps below (Thanks Dick Marinus for pointing out the Yosemite-specific updates!):First, create an empty hard drive image:Using the following command line, install OS X from the boot media created earlier (Thanks Jim Burns for the Penryn hint, which is needed instead of core2duo as of Sierra):In addition to the OVMF.fd firmware blob, the DVD image, and a blank hard drive image, you'll need to provide the value of OSK0 and OSK1, as a single concatenated 64-character string. If you own a Mac and run Linux on it natively (the license-compliant use case for the application of these instructions), you can retrieve them by compiling and running SmcDumpKey.c.Finally, to start your freshly installed guest, run:NOTE: If using qemu ≤ 2.8, substitute '-device usb-mouse' instead of '-device usb-tablet'. A patch to make the latter work with OS X (thanks to Phil Dennis-Jordan) only became available starting with version 2.9.0.4. Is This Legal?
Let me start with the obligatory disclaimer: I am not a lawyer, and this is not legal advice!We know that OS X is supported on commercial virtualization solutions such as VMWare Fusion and Parallels. Reading through Apple's EULA (which states that '[...] you are granted a [...] license to install, use and run one (1) copy of the Apple Software on a single Apple-Branded computer at any one time'), it appears everything is OK as long as the underlying hardware is made by Apple.What if the hypervisor OS is different than OS X? (both Fusion and Parallels both use OS X as the hypervisor OS). Well, it appears VMWare ESXi allows running OS X guests (presumably only if the hardware is, once again, manufactured by Apple). This is clearly an example of OS X running as guest on top of a non-OS X hypervisor, on top of Apple-manufactured hardware.So, it is my belief that, as long as I'm running a Linux/KVM hypervisor on a genuine Mac computer (which I've personally been doing exclusively since cca. 2006, btw), the license does not forbid me from running OS X as a VM guest on top of it.In terms of advice, all I can say is: Check with the legal and/or moral authorities in your local jurisdiction before trying this at home! :)Qemu Drivers Download
5. Future Work
A few things still need work:Free Download Vga Drivers Software
- OS X High Sierra (10.13) doesn't boot at this time. No idea yet if (and how) the new Apple filesystem (APFS) plays into this.
- None of QEMU's current audio devices appear to have native OS X driver support
- Screen resolution / resizing doesn't work
- Most importantly, the HFS+ EDK2 patches (and the OS X boot support ones which depend on HFS+) are rather far from being palatable to the upstream EDK2 project. A major refactoring of the HFS+ support is needed first; Then, cleaning up and upstreaming the OS X boot support work originally done by Reza Jelveh would be needed.
- Additional details on https://github.com/gsomlo/edk2 are needed for those interested. The repository contains three branches, stacked on top of each other: On top of the master branch (which tracks upstream, there's gls-hfsplus, containing the HFS+ driver in its current, fsw-based form. On top of that, there's gls-macboot containing Reza's hacks to get OS X to load, which will need to be cleaned up once we have a reliable upstream HFS+ filesystem. Finally, on top of everything, there's gls-miscopt, containing convenient hacks for everyday OSX use (e.g. forcing the default screen size to something a bit more useful). I (re)structured my clone of edk2 this way so that I can easily rebase things on top of upstream, while at the same time being able to bounce between filesystem driver development in gls-hfsplus and using OSX.