From Fedora Project Wiki
 
(3 intermediate revisions by the same user not shown)
Line 8: Line 8:


<pre>
<pre>
$ sudo yum -y install libguestfs-tools-c
$ sudo dnf -y install libguestfs-tools-c libvirt
</pre>
 
Install the latest version of QEMU:
 
<pre>
$ sudo yum update qemu-system-aarch64
</pre>
</pre>


Line 21: Line 15:
<pre>
<pre>
(cd /etc/yum.repos.d; sudo curl -O https://www.kraxel.org/repos/firmware.repo )
(cd /etc/yum.repos.d; sudo curl -O https://www.kraxel.org/repos/firmware.repo )
sudo yum -y install edk2.git-aarch64
sudo dnf -y install edk2.git-aarch64
</pre>
</pre>


== Making the Image ==
== Making the Image ==
Line 36: Line 29:


{{admon/note | Note | By default, a randomly generated root password will be assigned.  Make note of the root password in the virt-builder output, so you can log in later.  Optionally, a root password may be set when building an image.  In this example a password will be set.}}
{{admon/note | Note | By default, a randomly generated root password will be assigned.  Make note of the root password in the virt-builder output, so you can log in later.  Optionally, a root password may be set when building an image.  In this example a password will be set.}}
{{admon/note | Note | In order to run virt-builder in F22, selinux must be set to Permissive or Disabled.}}


Use virt-builder to make an F22 image file:
Use virt-builder to make an F22 image file:
Line 59: Line 54:
     -nodefaults \\
     -nodefaults \\
     -display none \\
     -display none \\
    -M virt -cpu cortex-a57 -machine accel=tcg \\
     -m 2048 \\
     -m 2048 \\
     -drive if=pflash,format=raw,file=/usr/share/edk2.git/aarch64/QEMU_EFI-pflash.raw,readonly \\
    -cpu host -machine virt,accel=kvm \\
     -drive if=pflash,format=raw,file=/usr/share/edk2.git/aarch64/QEMU_EFI-pflash.raw,readonly=on \\
     -drive if=pflash,format=raw,file=fedora-\${VERSION}-aarch64-nvram \\
     -drive if=pflash,format=raw,file=fedora-\${VERSION}-aarch64-nvram \\
     -drive file=fedora-\${VERSION}.img,format=raw,if=none,id=hd0 \\
    -device virtio-scsi-device,id=scsi \\
    -device virtio-blk-device,drive=hd0 \\
     -drive file=fedora-\${VERSION}.img,format=raw,if=none,id=hd0 -device scsi-hd,drive=hd0 \\
     -netdev user,id=usernet -device virtio-net-device,netdev=usernet \\
     -netdev user,id=usernet -device virtio-net-device,netdev=usernet \\
     -serial stdio
     -serial stdio

Latest revision as of 19:39, 23 June 2015

Booting AArch64 using UEFI in a QEMU/KVM VM

Setting up the host

Richard WM Jones has written 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. Using an updated F22 host now provides all the necessary package versions.

First get virt-builder, in order to make an F22 AArch64 image for QEMU (if not already installed):

$ sudo dnf -y install libguestfs-tools-c libvirt

The latest version of AAVMF should be installed to run 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 dnf -y install edk2.git-aarch64

Making the Image

Note
There is a bug regarding fallback.efi [BZ#1190191], so use a pre-built NVRAM file to work around it.
curl -O http://libguestfs.org/download/builder/fedora-22-aarch64-nvram.xz
unxz fedora-22-aarch64-nvram.xz


Note
By default, a randomly generated root password will be assigned. Make note of the root password in the virt-builder output, so you can log in later. Optionally, a root password may be set when building an image. In this example a password will be set.
Note
In order to run virt-builder in F22, selinux must be set to Permissive or Disabled.

Use virt-builder to make an F22 image file:

virt-builder \
  --arch aarch64 \
  --root-password password:fedora \
    fedora-22


A script may be set up to start the VM:

cat > run-qemu.sh << EOF
#!/bin/bash

VERSION=22

qemu-system-aarch64 \\
    -nodefconfig \\
    -nodefaults \\
    -display none \\
    -m 2048 \\
    -cpu host -machine virt,accel=kvm \\
    -drive if=pflash,format=raw,file=/usr/share/edk2.git/aarch64/QEMU_EFI-pflash.raw,readonly=on \\
    -drive if=pflash,format=raw,file=fedora-\${VERSION}-aarch64-nvram \\
    -device virtio-scsi-device,id=scsi \\
    -drive file=fedora-\${VERSION}.img,format=raw,if=none,id=hd0 -device scsi-hd,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 22 kernel.