Skip to content

Commit

Permalink
tests/env.sh: Add aarch64 support
Browse files Browse the repository at this point in the history
Looks like we need Armv8.3-A CPUs for nested virt, and QEMU and kernel
support is also very recent.

Thankfully, Testing Farm is using AWS Graviton3, which is ARMv8.4-A, so
hopefully things work once the software stack catches up.

Signed-off-by: Alberto Faria <[email protected]>
  • Loading branch information
albertofaria committed May 1, 2024
1 parent 0b5b8fd commit 6dd26bf
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 7 deletions.
6 changes: 4 additions & 2 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ jobs:
skip_build: true
enable_net: true
targets:
# TODO: Replace these three with fedora-all-x86_64 once Fedora 38 is gone.
- fedora-rawhide-x86_64
# TODO: Replace these three with fedora-stable-x86_64 once Fedora 38 is gone.
- fedora-40-x86_64
- fedora-39-x86_64
# TODO: Replace these three with fedora-stable-aarch64 one Fedora 38 is gone.
- fedora-40-aarch64
- fedora-39-aarch64
identifier: docker
tmt_plan: /tests/docker

Expand Down
3 changes: 3 additions & 0 deletions plans/tests.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ prepare:
- cargo
- coreutils
- crun
- crun-krun
- docker
- genisoimage
- grep
Expand All @@ -35,6 +36,8 @@ execute:
set -ex
export PATH=$PATH:/root/.cargo/bin LIBGUESTFS_BACKEND=direct

lscpu

# set the test VM's Fedora version to the host's to run the tests under the
# requested environment
tag=$( awk -F= '/^VERSION_ID=/ {print tolower($2)}' /etc/os-release )
Expand Down
49 changes: 44 additions & 5 deletions tests/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ trap '__extra_cleanup; rm -fr "$temp_dir"' EXIT

export RUST_BACKTRACE=1 RUST_LIB_BACKTRACE=1

arch=$( uname -m )
case "$arch" in
x86_64|aarch64)
;;
*)
>&2 echo "Unsupported arch \"$arch\""
;;
esac

case "${1:-}" in
build)
if (( $# != 1 )); then
Expand All @@ -143,21 +152,37 @@ build)

# expand base image

__log_and_run qemu-img create -f qcow2 "$temp_dir/image.qcow2" 50G
root_part=$(
virt-filesystems --add "$temp_dir/image" --long |
awk '/^\/dev\// {if ($4 == "fedora") print $1}'
)

__log_and_run qemu-img create -f qcow2 "$temp_dir/image.qcow2" 20G
__log_and_run virt-resize \
--quiet \
--expand /dev/sda4 \
--expand "$root_part" \
"$temp_dir/image" \
"$temp_dir/image.qcow2"

rm "$temp_dir/image"

# enable nested virtualization

if [[ "$arch" == aarch64 ]]; then
__log_and_run virt-customize \
--quiet \
--no-network \
--add "$temp_dir/image.qcow2" \
--append-line '/etc/default/grub:GRUB_CMDLINE_LINUX_DEFAULT="kvm-arm.mode=nested"' \
--run-command 'grub2-mkconfig -o /boot/grub2/grub.cfg'
fi

# launch VM from base image file

__log_and_run podman run \
--name "$container_name-build" \
--runtime "$runtime" \
--memory 8g \
--memory 4g \
--rm -dit \
--rootfs "$temp_dir" \
--persistent
Expand All @@ -177,6 +202,15 @@ build)
# get a predictable keypair
__exec 'ssh-keygen -q -f .ssh/id_rsa -N "" && sudo cp -r .ssh /root/'

case "$arch" in
x86_64)
qemu_system_pkg=qemu-system-x86-core
;;
aarch64)
qemu_system_pkg=qemu-system-aarch64-core
;;
esac

__exec sudo dnf update -y
__exec sudo dnf install -y \
bash \
Expand All @@ -195,7 +229,7 @@ build)
openssh-clients \
podman \
qemu-img \
qemu-system-x86-core \
"$qemu_system_pkg" \
shadow-utils \
util-linux \
virtiofsd
Expand Down Expand Up @@ -251,15 +285,20 @@ start)

# shellcheck disable=SC2317
__extra_cleanup() {
__exec df -h
__log_and_run podman stop --time 0 "$container_name"
}

# load test images onto VM
# ensure nested hardware-accelerated virt is supported

__exec() {
__log_and_run podman exec "$container_name" --as fedora "$@"
}

__exec '[[ -e /dev/kvm ]] || { sudo dmesg; exit 1; }'

# load test images onto VM

chmod a+rx "$temp_dir" # so user "fedora" in guest can access it

for image in "${TEST_IMAGES[@]}"; do
Expand Down
2 changes: 2 additions & 0 deletions tests/t/bootc-disk-size.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-or-later

__skip

image="${TEST_IMAGES[fedora-bootc]}"
user="${TEST_IMAGES_DEFAULT_USER[fedora-bootc]}"

Expand Down
2 changes: 2 additions & 0 deletions tests/t/bootc-rootfs.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-or-later

__skip

"$UTIL_DIR/extract-vm-image.sh" "${TEST_IMAGES[fedora-bootc]}" "$TEMP_DIR/image"

__run() {
Expand Down

0 comments on commit 6dd26bf

Please sign in to comment.