lima
lima copied to clipboard
Use Rosetta2 as a binfmt_misc handler on macOS Ventura
I just learned that on macOS Ventura you can register Rosetta2 as a binfmt_misc handler inside a VM running in arm64 mode. That should mean that instead of using qemu-static emulation we should be able to run amd64 containers "compiled" into arm64, which should provide a big speed boost for code that is not available natively for arm64 (like mssql):
https://developer.apple.com/documentation/virtualization/running_intel_binaries_in_linux_vms_with_rosetta
Originally posted by @jandubois in https://github.com/lima-vm/lima/issues/889#issuecomment-1153010671
This needs implementing Virtualization.framework support (#889) right?
Or is it technically and legally possible to run Rosetta2 inside QEMU? What is the license of the Rosetta2 binfmt_misc?
This needs implementing Virtualization.framework support (#889) right?
I don't know; it depends on if we can get VirtioFS support without it.
Or if it will be possible to somehow bridge between the VirtioFS volume and qemu in some other way. I suspect not, as event notification will be a challenge, but it doesn't hurt to try...
I suspect that the binfmt_misc handler is just copying stuff to the Rosetta volume; Rosetta will perform the translation on the host and put the results back into the volume, so binfmt_misc can execute it from there.
What is the license of the Rosetta2 binfmt_misc?
I didn't think about it, but we would not distribute the software; it would come directly from Apple. So how would calling this from inside qemu be any different from running any other part of the OS from inside any kind of application. Since we don't link it to qemu, but just call it from a kernel hook, I don't see any problems there either.
Just a side note, Rosetta works great in UTM, when I launch VMs using Virtualization.framework.
I think theoretically, Rosetta should work in QEMU, but it's intended to be used with Virtualization.framework. The Rosetta binary is provided in a VirtioFS volume.