MacOS in QEMU – ARM edition [pdf]
kvm-forum.qemu.org
kvm-forum.qemu.org
It was only when I opened up all logging in a dev build did I discover there was some syscall from the mono side of things that wasn’t emulated properly enough. I thought it ironic recalling how many people had sold containers as lighter weight VMs that remove “works on my machine” hassles. Anyways, I just spun up an AWS EC2 instance to test this nothing part of the process.
I know podman uses qemu and maybe it could run this Unity based workload and maybe I could uninstall docker but eesh the boring image tech is starting to become a bit of a hassle. I’ll probably just keep using EC2 instances or write up a vagrant file to create a local VM. I’m sure eventually my workload will be fully supported eventually so I can optionally just wait.
I love and hate knowing so much.
The fix here would be to spin an amd64 VM and run the binary or install Docker there, instead of relying on the more convenient - but less compatible - user-space emulation of Docker. Not very related to this very interesting presentation on virtualizing ARM macOS guests on QEMU hosts..
Only on older setups and on the default config. Updated MacOS (13+) and updated docker provides an option to use Rosetta and the new virtualization system. That, I believe, replaces QEMU for x86 emulation with the Apple emulator.
I've had substantial success with that method; not only does it seem a bit faster, but some containerized apps that very frequently failed to start (e.g. Apache Pulsar) work consistently in that mode. I suspect this difference in experience speaks to bugs in QEMU that trigger in the presence of certain application behavior (in Pulsar's case, something weird happening with the JVM on startup).
QEMU's still an incredible feat of engineering and something I frequently use on Linux, though. It just seems that the Apple emulation on Macs is better (which makes sense, given that it's built by the people who made the semi-proprietary silicon it's emulating from).
1. To run a Linux container you need to be running Linux 2. This is why Docker for Max has always run a VM under the covers. It uses qemu. 3. This was true even before Apple Silicon when everything was x86_64 and nothing was emulated
Now you are bringing up Rosetta and x86 emulation. While I understand sometimes it’s necessary to run a container that hasn’t been compiled for aarch64 (or whatever they call Apple) so I can see why the actual cpu emulation capabilities of qemu or Rosetta would be necessary there, this seems to be beside the point.
if you have no Linux system involved because you have no VM, how would that work? What would the base system “under” the container be and what would respond to Linux’s OS-level calls?
> sometimes it’s necessary to run a container that hasn’t been compiled for aarch64
I have several containers in that boat, for which no ARM versions exist at all. Those containers were previously using QEMU to emulate x86 on ARM linux (in Docker's VM on an ARM Mac). That emulation encountered the failures I described, and was slow.
Switching to use Rosetta 2 in Docker solved the problems; the process for enabling it is described here: https://levelup.gitconnected.com/docker-on-apple-silicon-mac...
Something I don't know and am curious about is how Docker-for-Mac is actually using Rosetta 2. Is it running an additional Linux VM containing an x86 Linux OS, and running that VM through a Rosetta-2-enabled hypervisor? Or is Rosetta 2 distributed as a Linux program that is being invoked inside Docker's pre-existing aarch64 Linux VM instead of (or inside of?) QEMU?
Edit: as for your question:
> if you have no Linux system involved because you have no VM, how would that work?
That's not my situation, so I'm not sure.
It sounds to me like you're running a container on a massively different architecture and I think it's still pretty cool that it runs at all. Obviously when trying to run a game, which needs access to hardware and system calls beyond the use case of a simple CLI tool, running the container on a different architecture becomes more of a long shot.
I think given the circumstances it's actually kind of amazing you got this far, and if you're able to go all the way with your game with emulation, that'd be pretty cool.
Containers aren't VMs, they're Linux namespaces. If you want to run a container you need Linux. If you want to run Linux on MacOS you need virtualization. There's no "lightweight" VM about it - it's still a VM.
https://en.wikipedia.org/wiki/Docker_(software)
> Docker is a set of platform as a service products that use OS-level virtualization
https://www.netapp.com/devops-solutions/what-are-containers
> Containers are a form of operating system virtualization.
It also 'magically' exposes Docker socket to your own WSL2 instances/VMs.
But that's my point. It seems from this thread people don't understand what docker is except that they can kinda use it like a VM. But it's fundamentally different.
It might be that the RAM is reserved up-front on Windows and macOS but not on Linux? I’m not sure.
macOS is engineered for users and desktops, not servers and development. Apple's long history of blocking virtualizing macOS is a testament to this.
It also is engineered for development. Maybe not your particular type of development. Apple silicon isn't technically development-unfriendly, it's just apple silicon makes it less easy to do x86 development. But so does mips, sparc, ppc, and other architectures.
I didn't say it was technically impossible. I said apple has a history of blocking it.
this is in the EULA and is enforced by Virtualization.Framework.
cloud providers get no exception to this.
That's your problem there, containers are by design not VMs. Anyone who sold them as such aren't understanding the tech and you shouldn't have blindly trusted them.
That’s why I just said I’d spin up an EC2 instance that will 100% run on amd64 cpu arch.
I’ll be exploring vagrant but if it too fails I have workarounds.
That said I’m not really planning on hauling two computers with me just in case I want to test something on an intel processor.
Weirdly, virtualbox on linux was usually my go to for trying out other operating systems. It also felt like the most straightforward to use.
https://www.nicksherlock.com/2022/10/installing-macos-13-ven...
There may be ways to get around this but I don't of any.
Third-party app stores and outright website-based app distribution are coming next year anyway.
It'd be rather similar to the situation with Docker, where Xcode and the simulators would run markedly better on macOS than on other platforms due to fewer layers being necessary. Developing for iOS on Windows or Linux would technically be possible but it wouldn't be very pleasant.
I have Mac running on ESX signed into my Apple account. I haven’t used it too much but it’s on my list of devices on my account.
Even says “VMWare” for device type.
Mine got logged out when I used a publically shared id, and stopped being randomly logged out when I picked a random number.
The ancient random serial numbers are also in a standard format.
> Apple devices manufactured after 2010 generally have 12-character alphanumeric serial numbers, with the first three digits representing the manufacturing location, the following two indicating the year and week of manufacture, the next three digits providing a unique identifier, and the last four digits representing the model number.
Hackintosh users have to do something similar to be able to sign into iCloud.
The serial number doesn't have to be valid (as in existing on a physical machine) to work, though. It just needs to look valid (be generated using the same methodology as real serials). In fact in order to prevent accidentally using a serial tied to a machine owned by somebody else, the recommended procedure is to generate a serial and check its AppleCare status to verify that it's not tied to a real machine, and if it is to regenerate and check until you find one that isn't.
If you run macOS without the virtualization.framework, which is only possible on non-ARM mac's, then it will work.
HVF sounds like it has some unique features that make it nicer than KVM for some use cases.
My own bias is that I will be purchasing a Mac Studio around XMas as a flutter app build machine.
I know that VirtualBox has guest OS additions to pass through graphics acceleration from the Host OS to the Guest OS. Does QEMU have this for MS Windows and Linux *6 guest OSes?
I say kvm/qemu because the actual hypervisor is kvm, while qemu is used for control and device emulation. qemu can also emulate full machines, which is obviously much slower but can be extremely useful.
We used to use virtualbox at work to run our CI workload (spawning a fresh VM for every job). Long story short: It does not scale well at all. Its scripting API is terrible, we ran into endless network problems (for instance, its builtin dhcp server would sometimes fail to flush expired IPs, leading to running out of IPs to give), and it would sometimes just freeze up entirely, requiring us to restart the virtualbox services.
We switched over to kubevirt[0] (essentially qemu/kvm inside a kube cluster) to handle our CI, and it's been a much, much smoother sailing since then. And it even allowed us to run macos VMs on linux hosts, something that we never managed to get working in vbox.
> Does QEMU have this for MS Windows and Linux *6 guest OSes?
QEmu has virgl[1] for paravirtualized graphics, but its windows drivers are unsigned afaict, so you can't really use it there. Works fine on linux, so long as your mesa and kernel aren't super ancient.
Quickemu: Quickly create and run optimised Win-10,11/macOS/Linux on Linux
This is what allows it to simultaneously pretend to be a reference PREP platform, G3 machine, G4 machine, ARM9TDMI mobile device, ARM-Cortex EFI platform, SPARC server or even some hodge-podge machine of mixed emulated components. People treat it as equivalent to VBox or VMware; but it's not, it's a different tool that happens to offer a similar overlap of use cases (like using the butt of a screwdriver as a hammer).
I know, thats why I could run arm based OS on those twos on an x86 or x64 cpu.
Theres a lot of work thats gone into Qemu to emulate the different processors, question is have they found undocumented features of cpu's when trying to emulate them?
The emudev scene is pretty close-knit, there are shared contributors amongst MESS, MAME, Qemu, etc that spread research advances. In addition, a lot of the breakthrough work in undocumented/edge features is done by decappers, hardware researchers and computer engineers. This research then distills down into the more advanced emulator platforms before working its way into commodity documentation and hobby emulators.