Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running macOS guests #139

Closed
williamtheaker opened this issue May 8, 2024 · 8 comments · Fixed by #148
Closed

Running macOS guests #139

williamtheaker opened this issue May 8, 2024 · 8 comments · Fixed by #148

Comments

@williamtheaker
Copy link
Contributor

It looks like the most common use of vfkit is running GNU/Linux guests, but of course the Virtualization framework also supports running macOS guests and vz can download and run macOS guests from .ipsw files. Is it possible to run a macOS guest using vfkit (ideally from a .ipsw)?

@gbraad
Copy link

gbraad commented May 9, 2024

It is not a use case we (dependent applications; Podman Machine, CRC) have, but nothing that prevents this.

@williamtheaker
Copy link
Contributor Author

I found this project via Podman actually!
Have you been able to run macOS guests with vfkit? I've tried using .img files built by UTM and the last AGPLv3 build of Tart (0.38.0), but neither seem to actually boot despite vz not throwing an error. It's the same behavior as using an empty disk image.

vfkit \
    --cpus 2 --memory 2048 \
    --bootloader efi,variable-store=efi-variable-store,create \
    --device virtio-blk,path=/Users/foo/.tart/vms/sonoma001/disk.img --device virtio-input,keyboard --device virtio-input,pointing --device virtio-gpu,width=1920,height=1080 --gui
INFO[0000] &{2 2048    {[efi variable-store=efi-variable-store create] true}  [virtio-blk,path=/Users/foo/.tart/vms/sonoma001/disk.img virtio-input,keyboard virtio-input,pointing virtio-gpu,width=1920,height=1080] none://  true}
INFO[0000] boot parameters: &{EFIVariableStorePath:efi-variable-store CreateVariableStore:true}
INFO[0000]
INFO[0000] virtual machine parameters:
INFO[0000] 	vCPUs: 2
INFO[0000] 	memory: 2048 MiB
INFO[0000]
INFO[0000] Adding virtio-blk device (imagePath: /Users/foo/.tart/vms/sonoma001/disk.img)
INFO[0000] Adding virtio-input keyboard device
INFO[0000] Adding virtio-input pointing device
INFO[0000] Adding virtio-gpu device
INFO[0000] virtual machine is running
INFO[0000] waiting for VM to stop
INFO[0000] VM is stopped

^ running vfkit version: 0.5.1

I can get a code signing cert to compile vz with the required entitlements and test building an image with it, but wanted to make sure I'm not doing something obviously wrong first.

@williamtheaker
Copy link
Contributor Author

It looks like this might not work even when supplying an image that works with other tools because vfkit hasn't implemented VZMacPlatformConfiguration or VZMacOSBootLoader.

If you compare the vz examples for macOS and Linux, you can see the Linux VM uses slightly different calls, like VZGenericPlatformConfiguration.

I could be wrong about all this though 😅

@cfergeau
Copy link
Collaborator

It looks like this might not work even when supplying an image that works with other tools because vfkit hasn't implemented VZMacPlatformConfiguration or VZMacOSBootLoader.

If you compare the vz examples for macOS and Linux, you can see the Linux VM uses slightly different calls, like VZGenericPlatformConfiguration.

I could be wrong about all this though 😅

Yes, a few things are missing in vfkit to run macOS guests, including the ones you mention (haven't checked if there are more :) This would be a nice addition to vfkit, but not something I'm planning to work on soon.

If you want to try to implement this, I'd be happy to help with guidance/suggestions/... if needed.

@cfergeau
Copy link
Collaborator

A few thoughts about this (which might be wrong ;)

  • I'd tie "macos" vm to a --bootloader macos config option
  • if this option is set, then we can create a *vz.MacPlatformConfiguration automatically and pass it to the VM
  • however, this requires the path to several files, so maybe a --runtime-dir option is needed, which I've wanted to have for a while
  • the graphical device for macos VMs is different from the one for linux VMs
  • I don't know how to handle installation (haven't looked closely enough to this code)

@cfergeau
Copy link
Collaborator

you can see the Linux VM uses slightly different calls, like VZGenericPlatformConfiguration.

vfkit does not make use of this, I don't know if it should..

@williamtheaker
Copy link
Contributor Author

Thank you for the suggestions on how to get started. I'll open up a draft pull request when I have something worth sharing.

@williamtheaker
Copy link
Contributor Author

you can see the Linux VM uses slightly different calls, like VZGenericPlatformConfiguration.

vfkit does not make use of this, I don't know if it should..

Implementing VZGenericPlatformConfiguration would require dropping macOS 11 support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants