From Fedora Project Wiki
(Created page with "= Booting AArch64 using UEFI in a QEMU/KVM VM = == Setting up the host == Richard WM Jones has witten an excellent post on booting a [https://rwmj.wordpress.com/2015/02/27/h...")
 
Line 26: Line 26:




{{admon/note | There's a bug regarding fallback.efi
== Making the Image ==
    https://bugzilla.redhat.com/show_bug.cgi?id=1190191
 
so use a pre-built NVRAM file to work around it.}}
{{admon/note | Note | There is a bug regarding fallback.efi [[https://bugzilla.redhat.com/show_bug.cgi?id=1190191 BZ#1190191]], so use a pre-built NVRAM file to work around it.}}


<pre>
<pre>
Line 35: Line 35:
</pre>
</pre>


== Making the Image ==
 
{{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.  It should be the only entry in a single line text file.}}
 
<pre>
vi fedora
<Enter one line with the desired root password>
</pre>
 


Use virt-builder to make an F21 image file:
Use virt-builder to make an F21 image file:


<pre>
<pre>
virt-builder --arch aarch64 fedora-21
virt-builder --arch aarch64 --root-password file:./fedora fedora-21
</pre>
</pre>
{{admon/note | Make note of the root password, so you can log in later.}}




Line 49: Line 54:


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


sudo qemu-system-aarch64 \
VERSION=21
     -nodefconfig \
 
     -nodefaults \
qemu-system-aarch64 \\
     -display none \
     -nodefconfig \\
     -M virt -cpu cortex-a57 -machine accel=tcg \
     -nodefaults \\
     -m 2048 \
     -display none \\
     -drive if=pflash,format=raw,file=/usr/share/edk2.git/aarch64/QEMU_EFI-pflash.raw,readonly \
     -M virt -cpu cortex-a57 -machine accel=tcg \\
     -drive if=pflash,format=raw,file=fedora-21-aarch64-nvram \
     -m 2048 \\
     -drive file=fedora-21.img,format=raw,if=none,id=hd0 \
     -drive if=pflash,format=raw,file=/usr/share/edk2.git/aarch64/QEMU_EFI-pflash.raw,readonly \\
     -device virtio-blk-device,drive=hd0 \
     -drive if=pflash,format=raw,file=fedora-\${VERSION}-aarch64-nvram \\
     -netdev user,id=usernet -device virtio-net-device,netdev=usernet \
     -drive file=fedora-\${VERSION}.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
     -serial stdio
EOF
EOF
Line 78: Line 85:


This should boot grub2 and automatically boot the Fedora 21 kernel.
This should boot grub2 and automatically boot the Fedora 21 kernel.
= Making an F22 Test Image =
Richard WM Jones provides image templates for Fedora releases, but not for candidates.  For testing purposes, there is an F22 Beta TC1 template available. 
== Setting up the host ==
The same tools versions must be set up for building an F22 test image as used for F21 above.  In addition, a local libguestfs.conf must be set up in order to access the test template.
<pre>
vi ~/.config/virt-builder/repos.d/libguestfs.conf
----------------------
[libguestfs.org]
uri=https://dmarlin.fedorapeople.org/fedora-arm/aarch64/builder/index
----------------------
</pre>
{{admon/note | This config file will override the defaults.  You may need to remove it to use the default config.}}
== Making the image ==
Make a test directory for the image and switch to it.
<pre>
mkdir test
cd test
</pre>
Get the pre-configured UEFI NVRAM file:
<pre>
curl -O https://dmarlin.fedorapeople.org/fedora-arm/aarch64/builder/fedora-22-aarch64-nvram.xz
unxz fedora-22-aarch64-nvram.xz
</pre>
Create a root password file.
<pre>
vi fedora
[Enter one line with the desired root password]
</pre>
Use virt-builder to make an F22 test image file:
<pre>
virt-builder  \
  --arch aarch64 \
  --no-check-signature \
  --root-password file:./fedora \
    fedora-22
</pre>
== Booting the Image ==
A convenience script may also be created to run the image, for example:
<pre>
cat > run-qemu.sh << EOF
#!/bin/bash
VERSION=22
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-\${VERSION}-aarch64-nvram \\
    -drive file=fedora-\${VERSION}.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
</pre>
Run the script to boot the image.
<pre>
./run-qemu.sh
</pre>
This should boot grub2 and automatically boot the Fedora 22 AArch64 Beta TC1 kernel.

Revision as of 21:40, 2 April 2015

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


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-21-aarch64-nvram.xz
unxz fedora-21-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. It should be the only entry in a single line text file.
vi fedora
<Enter one line with the desired root password>


Use virt-builder to make an F21 image file:

virt-builder --arch aarch64 --root-password file:./fedora fedora-21


A script may be set up to start the VM:

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

VERSION=21

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-\${VERSION}-aarch64-nvram \\
    -drive file=fedora-\${VERSION}.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.


Making an F22 Test Image

Richard WM Jones provides image templates for Fedora releases, but not for candidates. For testing purposes, there is an F22 Beta TC1 template available.

Setting up the host

The same tools versions must be set up for building an F22 test image as used for F21 above. In addition, a local libguestfs.conf must be set up in order to access the test template.

vi ~/.config/virt-builder/repos.d/libguestfs.conf
----------------------
[libguestfs.org]
uri=https://dmarlin.fedorapeople.org/fedora-arm/aarch64/builder/index
----------------------
This config file will override the defaults. You may need to remove it to use the default config.


Making the image

Make a test directory for the image and switch to it.

mkdir test
cd test


Get the pre-configured UEFI NVRAM file:

curl -O https://dmarlin.fedorapeople.org/fedora-arm/aarch64/builder/fedora-22-aarch64-nvram.xz
unxz fedora-22-aarch64-nvram.xz


Create a root password file.

vi fedora
[Enter one line with the desired root password]


Use virt-builder to make an F22 test image file:

virt-builder  \
  --arch aarch64 \
  --no-check-signature \
  --root-password file:./fedora \
    fedora-22


Booting the Image

A convenience script may also be created to run the image, for example:

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

VERSION=22

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-\${VERSION}-aarch64-nvram \\
    -drive file=fedora-\${VERSION}.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


Run the script to boot the image.

./run-qemu.sh

This should boot grub2 and automatically boot the Fedora 22 AArch64 Beta TC1 kernel.