QEMU aarch64 on ARM Mac never boots and only shows (qemu) prompt

I'm trying to emulate aarch64 and/or arm using qemu on ARM/M1 macOS. However, after multiple installer isos (ubuntu aarch64, standard alpine aarch64, etc) I can't seem to get anything but a blank prompt in ARM macOS.

I've tried everything from:

qemu-system-aarch64 -machine virt -m 512M -cpu max -smp 1 \                          
-netdev user,id=vnet,hostfwd=:127.0.0.1:0-:22 -device virtio-net-pci,netdev=vnet \                
-drive file=ubuntu-image.img,if=none,id=drive0,cache=writeback -device virtio-blk,drive=drive0,bootindex=0 \
-drive file=mini.iso,if=none,id=drive1,cache=writeback -device virtio-blk,drive=drive1,bootindex=1

to:

qemu-system-aarch64 -machine virt -m 512M -cpu max -smp 1 -boot d -cdrom mini.iso

And here's what I'm seeing as a result:

enter image description here

When I try the x86 virt machine everything works given the same params. Is qemu-system-aarch64 -machine virt expected to work at all on ARM macOS? Are there any commands that work for aarch64 on M1/ARM macOS?


Solution 1:

Figured this out. Looks like you need to define both a UEFI (e.g edk2) and a CPU for aarch64 machines.

UEFI: -bios "/opt/homebrew/Cellar/qemu/6.1.0_1/share/qemu/edk2-aarch64-code.fd"

CPU: -cpu cortex-a72

(Only tried a couple but only the cortex-a72 worked for me.)

So, altogether: qemu-system-aarch64 -M virt,highmem=off -accel hvf -m 1G -cdrom myiso.qcow2 -boot d -bios "/opt/homebrew/Cellar/qemu/6.1.0_1/share/qemu/edk2-aarch64-code.fd" -serial stdio -boot menu=off -cpu cortex-a72 -nodefaults