本教程改编自https://gist.github.com/niw/e4313b9c14e968764a52375da41b4278#running-ubuntu-server-for-arm64
xcode-select --install
https://brew.sh/
brew install ninja pkgconfig glib pixman libusb libssh zstd usbredir
mkdir -p ~/src/
cd ~/src/
git clone https://github.com/patchew-project/qemu.git
cd qemu
git checkout patchew/20210120224444.71840-1-agraf@csgraf.de
有关详细信息,请参见https://patchew.org/QEMU/20210120224444.71840-1-agraf@csgraf.de/。
mkdir build/cd build/../configure --target-list=aarch64-softmmu --enable-cocoamake -j
此EFI图片是通过stable202011
带有其他分辨率的标签构建的QemuRamfb.c
。
https://gist.github.com/niw/4f1f9bb572f40d406866f23b3127919b/raw/f546faea68f4149c06cca88fa67ace07a3758268/QEMU_EFI-cb438b9-edk2-stable202011-with-extra-resolutions.tar.gz
要从源代码构建它以添加更多分辨率,请参阅以下部分。
mkdir ~/qemu-vm/cd ~/qemu-vm/tar xvf ~/Downloads/QEMU_EFI-cb438b9-edk2-stable202011-with-extra-resolutions.tar.gzdd if=/dev/zero of=pflash0.img bs=1m count=64dd if=/dev/zero of=pflash1.img bs=1m count=64dd if=QEMU_EFI.fd of=pflash0.img conv=notruncdd if=QEMU_VARS.fd of=pflash1.img conv=notrunc
-bios QEMU_EFI.fd
代替-drive ...if=pflash
行,但是在这种情况下,EFI中的任何更改都不会持久。https://download.freebsd.org/ftp/releases/VM-IMAGES/13.0-BETA1/aarch64/Latest/FreeBSD-13.0-BETA1-arm64-aarch64.raw.xz
保留原始文件的副本很方便,因为如果以后要创建其他VM,则可以使用它。如果要通过以下方法制作第二个虚拟机,请小心不要覆盖第一个虚拟机的映像:
mv ~/Downloads/FreeBSD-13.0-BETA1-arm64-aarch64.raw.xz .
unxz -k ~/Downloads/FreeBSD-13.0-BETA1-arm64-aarch64.raw.xz
~/src/qemu/build/qemu-system-aarch64 \\
-M virt,highmem=off \\
-accel hvf \\
-cpu cortex-a72 \\
-smp 4 \\
-m 4096 \\
-drive file=pflash0.img,format=raw,if=pflash,readonly=on \\
-drive file=pflash1.img,format=raw,if=pflash \\
-device virtio-gpu-pci \\
-display default,show-cursor=on \\
-device qemu-xhci \\
-device usb-kbd \\
-device usb-tablet \\
-device intel-hda \\
-device hda-duplex \\
-drive file=FreeBSD-13.0-BETA1-arm64-aarch64.raw,if=virtio,cache=writethrough \\
-nographic \\
-serial mon:stdio