Skip to content

Commit 7ba9be2

Browse files
committed
tests/env.sh: Add aarch64 support
Signed-off-by: Alberto Faria <[email protected]>
1 parent 153408e commit 7ba9be2

File tree

2 files changed

+41
-9
lines changed

2 files changed

+41
-9
lines changed

.packit.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ jobs:
99
skip_build: true
1010
enable_net: true
1111
targets:
12-
# TODO: Replace these three with fedora-all-x86_64 once Fedora 38 is gone.
13-
- fedora-rawhide-x86_64
14-
- fedora-40-x86_64
15-
- fedora-39-x86_64
12+
- fedora-stable-x86_64
13+
# TODO: Looks like we need Armv8.3-A CPUs for nested virt, and QEMU and
14+
# kernel support is also very recent. Testing Farm is using AWS Graviton3,
15+
# which is ARMv8.4-A, so hopefully things work once the software stack
16+
# catches up and we can enable this.
17+
# - fedora-stable-aarch64
1618
identifier: docker
1719
tmt_plan: /tests/docker
1820

tests/env.sh

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ trap '__extra_cleanup; rm -fr "$temp_dir"' EXIT
124124

125125
export RUST_BACKTRACE=1 RUST_LIB_BACKTRACE=1
126126

127+
arch=$( uname -m )
128+
case "$arch" in
129+
x86_64|aarch64)
130+
;;
131+
*)
132+
>&2 echo "Unsupported arch \"$arch\""
133+
;;
134+
esac
135+
127136
case "${1:-}" in
128137
build)
129138
if (( $# != 1 )); then
@@ -136,6 +145,15 @@ build)
136145

137146
# build disk image
138147

148+
case "$arch" in
149+
x86_64)
150+
qemu_system_pkg=qemu-system-x86-core
151+
;;
152+
aarch64)
153+
qemu_system_pkg=qemu-system-aarch64-core
154+
;;
155+
esac
156+
139157
packages=(
140158
bash
141159
cloud-init
@@ -154,7 +172,7 @@ build)
154172
openssh-clients
155173
podman
156174
qemu-img
157-
qemu-system-x86-core
175+
"$qemu_system_pkg"
158176
shadow-utils
159177
util-linux
160178
virtiofsd
@@ -165,14 +183,22 @@ build)
165183

166184
daemon_json='{ "runtimes": { "crun-vm": { "path": "/home/fedora/bin/crun-vm" } } }'
167185

168-
commands=(
186+
virt_builder_args=(
169187
# generate an ssh keypair for users fedora and root so crun-vm
170188
# containers get a predictable keypair
171-
'ssh-keygen -q -f /root/.ssh/id_rsa -N ""'
189+
--run-command='ssh-keygen -q -f /root/.ssh/id_rsa -N ""'
172190

173-
"mkdir -p /etc/docker && echo ${daemon_json@Q} > /etc/docker/daemon.json"
191+
--run-command="mkdir -p /etc/docker && echo ${daemon_json@Q} > /etc/docker/daemon.json"
174192
)
175193

194+
if [[ "$arch" == aarch64 ]]; then
195+
# enable nested virtualization
196+
virt_builder_args+=(
197+
--append-line '/etc/default/grub:GRUB_CMDLINE_LINUX_DEFAULT="kvm-arm.mode=nested"'
198+
--run-command 'grub2-mkconfig -o /boot/grub2/grub.cfg'
199+
)
200+
fi
201+
176202
__log_and_run virt-builder \
177203
"fedora-${CRUN_VM_TEST_ENV_FEDORA_VERSION:-40}" \
178204
--smp "$( nproc )" \
@@ -182,7 +208,7 @@ build)
182208
--size 50G \
183209
--root-password password:root \
184210
--install "$packages_joined" \
185-
"${commands[@]/#/--run-command=}"
211+
"${virt_builder_args[@]}"
186212

187213
# reduce image file size
188214

@@ -232,6 +258,10 @@ start)
232258
__log_and_run podman exec "$container_name" --as fedora "$@"
233259
}
234260

261+
# ensure nested hardware-accelerated virt is supported
262+
263+
__exec '[[ -e /dev/kvm ]] || { sudo dmesg; exit 1; }'
264+
235265
chmod a+rx "$temp_dir" # so user "fedora" in guest can access it
236266

237267
__exec sudo cp /root/.ssh/id_rsa /root/.ssh/id_rsa.pub .ssh/

0 commit comments

Comments
 (0)