moby / hyperkit

A toolkit for embedding hypervisor capabilities in your application
BSD 2-Clause "Simplified" License
3.61k stars 327 forks source link

macOS guest support #148

Open copumpkin opened 7 years ago

copumpkin commented 7 years ago

The macOS license actually allows running macOS in a VM on Apple host hardware, which hyperkit would satisfy. I'm wondering what work would be required to enable that. Since quite a few people have figured out how to run it under qemu (with questionable licensing implications), it seems like there's probably enough FOSS code out there that HyperKit could take inspiration from to support macOS guests too.

I imagine the two biggest missing pieces are EFI emulation and the magic "don't steal macOS" blurb.

copumpkin commented 7 years ago

Oh, I guess this is sort of duplicating the follow-up discussion to https://github.com/moby/hyperkit/issues/19. I'll let maintainers decide if this is worth closing due to that ticket, but my inclination would be to track individual missing features rather than a big batch like in #19, since it's hard to decide when that ticket is "fixed".

avsm commented 7 years ago

A separate issue like this specifically for macos support seems wise.

copumpkin commented 7 years ago

Cool! Here's how to run it on qemu, which will give a sense (possibly via command-line args) of what hardware emulation is needed to get it working: https://www.contrib.andrew.cmu.edu/~somlo/OSXKVM/

   bin/qemu-system-x86_64 -machine q35,accel=kvm -bios ~/OVMF.fd -m 4096 \
      -cpu Penryn -smp 4,cores=2 \
      -usb -device usb-kbd -device usb-tablet \
      -device isa-applesmc,osk="insert-real-64-char-OSK-here" \
      -netdev user,id=usr0 -device e1000-82545em,netdev=usr0,id=vnet0 \
      -device ide-drive,bus=ide.2,drive=MacHDD \
      -drive id=MacHDD,if=none,file=~/mac_hdd.img \
      -monitor stdio

That insert-real-64-char-OSK-here thing is the magic blurb I mentioned. The other stuff is probably all work that needs doing. It does look like they got it working without EFI unless I'm missing something that implies EFI in that command line.

rn commented 7 years ago

On a quick scan:

copumpkin commented 7 years ago

Yeah, sounding like lots and lots of work 😄

Here's AppleSMC, FWIW: https://github.com/qemu/qemu/blob/master/hw/misc/applesmc.c. I think it stands for System Management Controller and controls various cooling and lighting options on Apple hardware, as well as containing the magic string that macOS checks for original Apple hardware.

grehan-freebsd commented 7 years ago

For available permissively-licensed code, bhyve has an e1000 (aka 82545em) emulation, an XHCI USB controller emulation plus tablet device, and there is an out-of-tree IDE driver from a GSoC project.

emilwojtaszek commented 6 years ago

did anything change in this scope? can I virtualized macOS guest using hyperkit?

rn commented 6 years ago

AFAIK, no one has been working on this. But you could try a recent version of qemu on macOS. In January or so, Hypervisor framework based acceleration was added.