Skip to content

Commit d518c27

Browse files
committed
Add aarch64 QEMU support with UEFI firmware
Adds qemu-system-aarch64 configuration for ARM64 testing with VirtIO devices, Cortex-A72 CPU, and UEFI firmware support. Change-type: minor Signed-off-by: Kyle Harding <[email protected]>
1 parent 3d534cf commit d518c27

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# --- normalize image architectures
2+
# FIXME: migrate off of balenalib images and use custom udev scripts
23
FROM balenalib/aarch64-node:20-bookworm-build AS cli-build-arm64
34
FROM balenalib/aarch64-python:3-bookworm-build AS qemu-build-arm64
45
FROM balenalib/aarch64-python:3-bookworm-run AS run-arm64
@@ -46,10 +47,11 @@ COPY requirements.txt .
4647

4748
RUN pip install -r requirements.txt
4849

50+
# FIXME: QEMU build is very time-consuming; consider using debian qemu-system-x86_64 and qemu-system-aarch64 packages instead
4951
RUN wget -q https://download.qemu.org/qemu-${QEMU_VERSION}.tar.xz \
5052
&& echo "847346c1b82c1a54b2c38f6edbd85549edeb17430b7d4d3da12620e2962bc4f3 qemu-${QEMU_VERSION}.tar.xz" | sha256sum -c - \
5153
&& tar -xf qemu-${QEMU_VERSION}.tar.xz && cd qemu-${QEMU_VERSION} \
52-
&& ./configure --target-list=x86_64-softmmu --enable-slirp && make -j"$(nproc)" \
54+
&& ./configure --target-list=x86_64-softmmu,aarch64-softmmu --enable-slirp && make -j"$(nproc)" \
5355
&& make install
5456

5557

@@ -61,6 +63,7 @@ ENV VIRTUAL_ENV=/opt/venv
6163
ENV PATH="${VIRTUAL_ENV}/bin:/usr/local/bin:${PATH}"
6264

6365
RUN install_packages \
66+
binutils \
6467
fdisk \
6568
git \
6669
jq \
@@ -74,6 +77,7 @@ RUN install_packages \
7477
minicom \
7578
openssh-client \
7679
ovmf \
80+
qemu-efi-aarch64 \
7781
rsync \
7882
systemd \
7983
zlib1g

resources/qemu.robot

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ Run "${image}" with "${memory}" MB memory "${cpus}" cpus and "${serial_port_path
1616
Process ${result}
1717
Set Test Variable ${image_copy} /tmp/resin${random}.img
1818

19+
# detect image architecture by checking for ARM64 EFI bootloader
20+
${result} = Run Buffered Process strings ${image} | grep -Eo "BOOTAA64" shell=yes
21+
Run Keyword And Return If ${result.rc} == 0 Run aarch64 image
22+
1923
# firmware is 'dos' (legacy x86 DTs) or 'gpt' (generic-amd64 DT)
2024
${result} = Run Buffered Process fdisk -l "${image}" | sed -nE 's/^Disklabel type: (\\w+)$/\\1/p' shell=yes
2125
Process ${result}
@@ -27,6 +31,13 @@ Run "${image}" with "${memory}" MB memory "${cpus}" cpus and "${serial_port_path
2731
Run Keyword And Return If ${result.rc} == 0 Run "${firmware}" image with "kvm" acceleration
2832
Run Keyword And Return If ${result.rc} != 0 Run "${firmware}" image with "tcg" acceleration
2933

34+
Run aarch64 image
35+
# https://www.qemu.org/docs/master/system/qemu-manpage.html
36+
# .. depending on the target architecture: kvm, xen, hvf, nvmm, whpx (default: tcg)
37+
${result} = Run Buffered Process test -r /dev/kvm && test -w /dev/kvm shell=yes
38+
Run Keyword And Return If ${result.rc} == 0 Run "aarch64" image with "kvm" acceleration
39+
Run Keyword And Return If ${result.rc} != 0 Run "aarch64" image with "tcg" acceleration
40+
3041
Run "gpt" image with "${acceleration}" acceleration
3142
# qemu-system-x86_64 defunct process without shell
3243
${handle} = Start Process qemu-system-x86_64 -device ahci,id\=ahci -drive file\=${image_copy},media\=disk,cache\=none,format\=raw,if\=none,id\=disk -device ide-hd,drive\=disk,bus\=ahci.0 -device virtio-net-pci,netdev\=n1 -netdev \"user,id\=n1,dns\=127.0.0.1,guestfwd\=tcp:10.0.2.100:80-cmd:netcat haproxy 80,guestfwd\=tcp:10.0.2.100:443-cmd:netcat haproxy 443\" -m ${memory} -nographic -machine type\=q35 -accel ${acceleration} -smp ${cpus} -chardev socket,id\=serial0,path\=${serial_port_path},server\=on,wait\=off -serial chardev:serial0 -bios /usr/share/ovmf/OVMF.fd -nodefaults shell=yes
@@ -36,3 +47,11 @@ Run "dos" image with "${acceleration}" acceleration
3647
# qemu-system-x86_64 defunct process without shell
3748
${handle} = Start Process qemu-system-x86_64 -device ahci,id\=ahci -drive file\=${image_copy},media\=disk,cache\=none,format\=raw,if\=none,id\=disk -device ide-hd,drive\=disk,bus\=ahci.0 -device virtio-net-pci,netdev\=n1 -netdev \"user,id\=n1,dns\=127.0.0.1,guestfwd\=tcp:10.0.2.100:80-cmd:netcat haproxy 80,guestfwd\=tcp:10.0.2.100:443-cmd:netcat haproxy 443\" -m ${memory} -nographic -machine type\=pc -accel ${acceleration} -smp ${cpus} -chardev socket,id\=serial0,path\=${serial_port_path},server\=on,wait\=off -serial chardev:serial0 shell=yes
3849
Return From Keyword ${handle}
50+
51+
Run "aarch64" image with "${acceleration}" acceleration
52+
# qemu-system-aarch64 defunct process without shell
53+
# Resize image to 4G otherwise the data partition isn't big enough for user apps
54+
${result} = Run Buffered Process qemu-img resize ${image_copy} 4G shell=yes
55+
Process ${result}
56+
${handle} = Start Process qemu-system-aarch64 -drive file\=${image_copy},media\=disk,cache\=none,format\=raw -device virtio-net-device,netdev\=n1 -netdev \"user,id\=n1,dns\=127.0.0.1,guestfwd\=tcp:10.0.2.100:80-cmd:netcat haproxy 80,guestfwd\=tcp:10.0.2.100:443-cmd:netcat haproxy 443\" -m ${memory} -nographic -machine type\=virt -accel ${acceleration} -smp ${cpus} -chardev socket,id\=serial0,path\=${serial_port_path},server\=on,wait\=off -serial chardev:serial0 -cpu cortex-a72 -bios /usr/share/AAVMF/AAVMF_CODE.fd -nodefaults shell=yes
57+
Return From Keyword ${handle}

0 commit comments

Comments
 (0)