virtualization using qemu
Introduction
Since macos has arm64 cpu architecture we can run arm64 virtual machines on qemu without emulation. The following command can be used to create a virtual machine in mac.
sudo qemu-system-aarch64 \
-m 1G \
-machine virt,accel=hvf \
-cpu host \
-smp 2 \
-bios /opt/homebrew/Cellar/qemu/10.1.0/share/qemu/edk2-aarch64-code.fd \
-drive if=virtio,file=ubuntu-24.04-server-cloudimg-arm64.img,format=qcow2 \
-drive file=seed.iso,media=cdrom \
-device virtio-net,netdev=net00 \
-netdev vmnet-bridged,id=net00,ifname=en0 \
-fsdev local,id=localfs,path=/Users/roshankhatri/Downloads/ubuntu-arm64-server/qemu-share,security_model=none \
-device virtio-9p-pci,fsdev=localfs,mount_tag=hostshare \
-display none \
-serial mon:stdio
Almost all options are referred on the setup guide besides few ones
bios- since uefi firmware is not supplied by the board machine type itself. So/opt/homebrew/Cellar/qemu/10.1.0/share/qemu/edk2-aarch64-code.fdis provided asUEFIfirmware. The file gets populated on installation of qemu in macos.fsdev- file system device used to share the local folder on to the guest operating system.device- local device used to share the local folder on to the guest operating system.
This setup will take the cloud init from the seed.iso file used in the earlier setup guide