I’ve had not recently tried to compile QEMU. Compiling it on macOS is also new to me. So here are some helpful tips. I’m using QEMU 10.2.1 and macOS Tahoe 26.3.1.

Update Homebrew

Firstly, if (like most people), you moved your homebrew installation at some stage from your old intel mac, then you will need to move it over to native ARM64. Why? Because the version of python you run will be the homebrew one, and if you have the old version of macOS it runs under Rosetta. As Python detects the processor running, your configuration for QEMU will then have x86_64 in, yet an ARM binary will be built. This will prevent you from running HVF (acceleration). This took me a little to work out. It seems updating homebrew to use ARM requires wiping it and reinstalling it. To do that, refer to someone who actually knows what they are doing with Homebrew, or failing that, here’s what I did:

Check which version of Homebrew you have installed (adapt to run any executable brew has installed)

That should say arm64 like the above. If it does, great – skip the rest of this section. If it’s showing an intel installation, then carry on.

Dump the current installation to a file called Brewfile:

Remove your current homebrew installation:

Remove any of the directories it complains about that are solely brew‘s reponsibility.

Install a new version of brew:

Check this now says arm64:

That should now say arm64 like the above. If not, something has gone wrong!

Install all the brew goodness you previously had (look through Brewfile).

Quit and restart any other terminal windows you have open.

Install Homebrew pre-requisites

You’ll need the following:

Get the QEMU source

Build with an appropriate configuration

Why the explicity make -j12 qemu-system-aarch64? Because make alone builds an unsigned binary, and an unsigned binary won’t run HVF.

You should now have a build/qemu-system-aarch64.

Test you can display something useful with the Cocoa UI (it will be a blank screen):

The main difficulties I found were the magic incantations to get HVF to work. That command will error if HVF isn’t built in right.

Get an Ubuntu cloud image to run

I’m going to assume you are going to put the cloud image in the directory above.

I’ve made the image read-only, in case you forget -snapshot on the CLI to QEMU and thereby corrupt it.

Now we need to make a tiny ISO containing cloudinit parameters so we can set up ssh keys etc. (insert your keys as appropriate), and a password for the ubuntu user set to an imaginative password.

Launch your cloud image

This runs the hypervisor attaching the cloud image but using -snapshot so changes are written to a temporary file and deleted when Qemu exits.

You should see it booting. To log in via ssh, you want something like:

In the above, note:

which make Qemu use the Cocoa UI, a RAM frame-buffer, and keybord and mouse drivers. Once you have it working, you don’t need this, and can instead use:

if you like.

 

 

 

 

 

 

 

 

Leave a Reply

Discover more from Alex Bligh's blog

Subscribe now to keep reading and get access to the full archive.

Continue reading