Booting AArch64 using UEFI in a QEMU/KVM VM
Setting up the host
Richard WM Jones has witten an excellent post on booting a Fedora 21 aarch64 UEFI guest on x86_64. This can be reproduced on an F21 x86_64 host using existing packages, but as Richard mentioned, newer versions of some packages are required. These can be pulled from the Fedora rawhide and Gerd Hoffmann's firmware repos, as described below.
First get virt-builder, in order to make an F21 image for QEMU (if not already installed):
sudo yum -y install libguestfs-tools-c
You will need to get the rawhide version of QEMU. Set up the rawhide repo (if not already done) and install QEMU:
sudo yum install fedora-repos-rawhide sudo yum --enablerepo=rawhide update qemu-system-aarch64
You will also need to install AAVMF for running an aarch64 image. AAVMF is not in an official Fedora package yet, but Gerd has provided an RPM package for installation convenience. Download his repo definition and install his latest build of edk2:
(cd /etc/yum.repos.d; sudo curl -O https://www.kraxel.org/repos/firmware.repo ) sudo yum -y install edk2.git-aarch64
curl -O http://libguestfs.org/download/builder/fedora-21-aarch64-nvram.xz unxz fedora-21-aarch64-nvram.xz
Making the Image
Use virt-builder to make an F21 image file:
virt-builder --arch aarch64 fedora-21
A script may be set up to start the VM:
cat >> run-qemu.sh << EOF #!/bin/bash sudo qemu-system-aarch64 \ -nodefconfig \ -nodefaults \ -display none \ -M virt -cpu cortex-a57 -machine accel=tcg \ -m 2048 \ -drive if=pflash,format=raw,file=/usr/share/edk2.git/aarch64/QEMU_EFI-pflash.raw,readonly \ -drive if=pflash,format=raw,file=fedora-21-aarch64-nvram \ -drive file=fedora-21.img,format=raw,if=none,id=hd0 \ -device virtio-blk-device,drive=hd0 \ -netdev user,id=usernet -device virtio-net-device,netdev=usernet \ -serial stdio EOF chmod +x run-qemu.sh
Booting the image
Run the script (or the command it contains) to boot the VM.
./run-qemu.sh
This should boot grub2 and automatically boot the Fedora 21 kernel.