top | item 20222492

Documentation to set up a simple macOS VM in QEMU, accelerated by KVM

298 points| paulcarroty | 6 years ago |github.com | reply

111 comments

order
[+] Wowfunhappy|6 years ago|reply
I know it's bad security, but I'd be more interested in this if it supported old releases, like Snow Leopard or at least Mavericks (the latter being the final release with the Acqua UI).

I have a fantasy that I'll go back to Snow Leopard some day and live the rest of my life there, but then I remember hardware support is basically nonexistent. A very lightweight VM with GPU passthrough could work around that problem.

[+] 120photo|6 years ago|reply
I have a Epson Perfection 4490 with no 64bit drivers. I will need to either run Windows or a older version of Mac OS / OS X. I'm sure there are other use cases where one will need a older system. I was actually going to go down the route or building a new Hackintosh but have opted o build a Linux desktop with Mac OS VM using GPU pass through. Using this I could have the latest Mac OS and a older version when needed.
[+] misnome|6 years ago|reply
It'd also be useful for testing software on old releases. I work on scientific software. We are currently.... considering... dropping snow leopard support, but partners keep insisting that they use ancient systems. (We had a fight to drop CentOS 5 this year).
[+] vintagedave|6 years ago|reply
> I have a fantasy that I'll go back to Snow Leopard some day and live the rest of my life there

Why is that? Do you prefer the older macOSes? (I'm sympathetic to that viewpoint, but would like to know what about Snow Leopard specifically is what you like.)

[+] pmjordan|6 years ago|reply
I don't know what boot environment this is emulating exactly, but it looks like a straightforward OVMF, presumably hacked up with HFS+ support and a bunch of Apple extensions to make macOS boot. In that case, running Mavericks should be no problem. I'd have thought Snow Leopard should also run, at least in K64 mode (64-bit kernel), but I've not tried it in a long time and don't recall if there were any gotchas.

Note also that software support is now pretty weak for these old releases - you struggle to find any modern web browsers that still run, for example.

[+] unixhero|6 years ago|reply
Is there a reason why this method would not support Snow Leopard?
[+] stevencorona|6 years ago|reply
I recently went the KVM MacOS/Hackintosh route (but not using this exact script) and while it functionally worked great— GPU Passthrough (Used RX580 and Vega 56), PCI Passthrough (USB Controller/Bluetooth/Wifi/Ethernet Card/SATA Controller/NVME Drive), iMessage, Handoff, AirDrop, etc. etc. I found it to be hassle on my consumer AMD motherboard with an AMD GPU.

With the AMD GPU, I had trouble resetting the GPU between VM starts/stops without restarting the whole computer. This appears to be a problem with a consumer AMD cards.

It could be specific to AMD Ryzen IOMMU Groups, but it was also pretty annoying to passthrough the PCI devices and still leave the appropriate hardware for the host machine. There aren't any native virtio drivers in OSX so you really need to pass through your sata controller/ethernet card for full performance. Might have been easier with a server motherboard with cleaner IOMMU groups, though.

I ended up just building a bare-metal Intel Hackintosh which was less of a hassle.

[+] tpoindex|6 years ago|reply
> I ended up just building a bare-metal Intel Hackintosh which was less of a hassle.

I think we need a new word to describe VM-hosted MacOS to distinguish from hardware hosted: QEMU + hack + Macintosh = Quackintosh ?

[+] derefr|6 years ago|reply
> There aren't any native virtio drivers in OSX

I could have sworn that macOS is supported as a guest under VMWare Fusion and/or ESXi hosts (when on Mac hardware), using some virtio drivers.

[+] holy_city|6 years ago|reply
This falls on deaf years but I say it every chance I get.

I would pay a significant premium to install MacOS on a machine without violating their ToS.

[+] TimTheTinker|6 years ago|reply
Since Apple isn't opposed to releasing new OS flavors, I think they should release "serverOS", a variant of macOS but licensed to run anywhere, even (or especially) on non-Apple hardware and in VMs.

It's very frustrating to a lot of people that macOS VMs aren't easy (licensing/ToS-wise) to spin up on non-Apple hardware, especially since Apple doesn't sell high-end servers any longer. Yes, that calculus will be different when the new Mac Pro begins to sell, but a lot of IT departments would rather add Apple VMs for testing/build/dev to their on existing on-premise compute clouds (vSphere/etc.) than spin up brand new ones on Apple hardware.

Additionally, there's a lot of demand for local Apple VMs on Windows machines. Microsoft makes a lot of money from software that's running on my Mac - especially Office and Windows (via Parallels Desktop or Boot Camp). Why shouldn't Apple make money from VMs running on Windows and Linux machines?

[+] JoshTriplett|6 years ago|reply
I would pay a premium to be able to install macOS on a cloud VM that I can scale arbitrarily large (and to arbitrarily many instances, presumably with premium for each). I'd like to do scalable CI and builds for macOS.

(Also, if someone can find a maintainable method for it, I'd love to support someone who maintains a cross-compiler toolchain that targets macOS, making it possible to build Rust and C apps for macOS without having macOS installed. But that's not a complete substitute for having an actual macOS cloud build server, on which the compiled applications can run as part of the build process.)

[+] deagle50|6 years ago|reply
No kidding. I would pay their entire iMac hardware margin for an OSX desktop license.
[+] mlevental|6 years ago|reply
it falls on deaf ears because there are only dozens of us.
[+] Aaronstotle|6 years ago|reply
It always baffled me that Apple refuses to sell MacOS, they could capture a significant part of the OS market.
[+] awalton|6 years ago|reply
But then how would Apple sell you a Mac Mini?
[+] ajconway|6 years ago|reply
I wonder if anyone had success in running macOS VM on macOS via hvf acceleration. Would be a great free alternative to VMWare Fusion and Parallels.
[+] pmjordan|6 years ago|reply
Very recent versions of Qemu have "experimental" support for HVF, so in theory it should work. I haven't had a chance to try it yet, however, and it's possible that there are some MSRs or similar that aren't sufficiently supported yet. If this is something you(r employer/company) care about, feel free to get in touch as I suspect it's not too difficult to fix if it doesn't currently work.
[+] Wowfunhappy|6 years ago|reply
Does anyone understand why this works on AMD processors without a custom Darwin kernel, as would be needed in a native AMD Hackintosh setup? The core x86 code is still getting executed natively, right? So, what magic does the VM perform?
[+] exabrial|6 years ago|reply
I've been interested in doing something like this so I can run an iMessage proxy. A lot of neat gateway apps for OSx have popped up (like https://www.wemessageapp.com) to get iMessage support on Android.
[+] camhenlin|6 years ago|reply
I've been doing this for years with some of my own personal projects like https://github.com/CamHenlin/imessageclient, https://github.com/CamHenlin/iMessageWebClient, and https://github.com/CamHenlin/imessagebot and some others - one thing that I'll note is that in my experience, Apple is pretty aggressive and somewhat arbitrary at banning accounts from accessing iMessages if they get on to the service from a VM - even if your usage is normal, personal iMessaging. I was trying out using VMWare and virtualbox specifically. In fact, I've been accidentally successful at getting my computer and home network banned from Apple services by accessing iMessages via VM. I strongly recommend running these types of services on bare metal Macs although ymmv.
[+] vishesh92|6 years ago|reply
Doesn't this violate Apple's licenses? AFAIR, MacOS is illegal to run on non-Apple hardware.
[+] eivarv|6 years ago|reply
You may violate Apple's EULA by running macOS on non-Apple hardware, but it's not illegal (it's not a criminal offence).
[+] bithavoc|6 years ago|reply
I believe the MacOS license requires to run on Mac hardware, so in order to be compliant with the license you'd need to launch a big VM Linux on top of a beefy Mac Server then inside the big Linux VM provision all the MacOS VM instances you want using the utility mentioned in the post.
[+] starman100|6 years ago|reply
You could also be running this on Linux that happens to be running on Apple hardware.
[+] Someone|6 years ago|reply
I don’t think informing people about ways to do things that go against software licenses violates the license.

Also, following these instructions doesn’t necessarily violate Apple’s license. You can run Linux on Apple hardware, and install Mac OS X on top of it, can’t you?

Finally, IANAL, but software licenses likely aren’t enforceable to consumers in large parts of the world (a shrink-wrap “take it or leave it” probably wouldn’t be considered an agreement between parties in many courts, and that’s what you need to call something a license)

[+] megous|6 years ago|reply
One more thing (not mentioned in the docs) post-install is to use QemuUSBTablet-1.2.pkg, for nicer mouse interation.
[+] rubyn00bie|6 years ago|reply
I just bought a used dual socket (E5 V2) server to play with KVM and to try do just this... I suspect, performance is probably pretty righteous even in the VM, and old xeon's like the 2667 V2 are dirt cheap these days. MacOS doesn't need much VRAM and old AMD cards are pretty cheap (GPU passthrough is easier with AMD cards [1]).

I'm really looking forward to running this later.

[1] I could be wrong on this, but from my previous research into gpu passthrough made it seem as though NVidias consumer cards aren't generally allowed to do it because they're driver locked.

[+] draugadrotten|6 years ago|reply
How is the performance compared to running macOS on the same hardware (ie Hackintosh style)?
[+] pulkitsh1234|6 years ago|reply
can this handle 'xcodebuild' ?
[+] terhechte|6 years ago|reply
Do the special network / bluetooth services (iCloud, iMessage, Handoff, AirDrop, AirPods) work with this setup?
[+] Operyl|6 years ago|reply
Handoff requires a very specific set of Bluetooth hardware iirc, and it would need to be entirely passed through. So most likely no. And I believe that some of the iCloud services (specifically those entangled with iMessage/FaceTime) will require a valid SN (you can “generate” one by brute force though). It’ll also require that you give it two interfaces, one Ethernet and one wireless (and it’ll sometimes need to start a small wireless network for things like Airdrop).
[+] LeicaLatte|6 years ago|reply
Very nice. If this works on ec2/droplets, I might have found a good solution for my iOS/macOS CI needs.
[+] dharma1|6 years ago|reply
How good is the passthrough perf?

I'd like to build a hackintosh box with amd 3900x and amd rx5700 xt GPU - for video editing etc.

KVM seems like the only choice for AMD cpus. Will the GPU work with KVM? What mobo should I get?

[+] StreamBright|6 years ago|reply
We should have a tool to create VMs on macOS as well. There is the new API but non of the FOSS tools using it. I am wondering why.