aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2022-11-18 18:28:00 -0500
committerTheodore Ts'o <tytso@mit.edu>2022-11-18 23:40:24 -0500
commit0bda630edd4b54f33a8a15d5032cbd4b3e2c0341 (patch)
treedac25a953071b942acb63382bff988dc14e3a29e
parent1efbdfd8c837494b50cdc163fdf0b1b2c6c1e52b (diff)
downloadxfstests-bld-0bda630edd4b54f33a8a15d5032cbd4b3e2c0341.tar.gz
Add multi-architecture support to kvm-xfstests
Teach kvm-xfstests to support --arch arm64 and --arch i386, as well as the syntatic shortcuts --arm64 and --i386. This will start qemu with the correct parameters, as well as fetching the correct kernel if the kernel was built using kbuild with multiple build directories for the different architectures. Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--kernel-build/kernel-configs/arm64-config1
-rw-r--r--run-fstests/config.kvm1
-rwxr-xr-xrun-fstests/kvm-xfstests37
-rw-r--r--run-fstests/util/parse_cli14
-rw-r--r--run-fstests/util/parse_opt_funcs25
5 files changed, 69 insertions, 9 deletions
diff --git a/kernel-build/kernel-configs/arm64-config b/kernel-build/kernel-configs/arm64-config
index f363adf3..d0052398 100644
--- a/kernel-build/kernel-configs/arm64-config
+++ b/kernel-build/kernel-configs/arm64-config
@@ -6,3 +6,4 @@ CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
CONFIG_SERIAL_AMBA_PL011=y
CONFIG_SETEND_EMULATION=y
CONFIG_SWP_EMULATION=y
+CONFIG_PCI_HOST_GENERIC=y
diff --git a/run-fstests/config.kvm b/run-fstests/config.kvm
index f55ed8d7..f15f46fa 100644
--- a/run-fstests/config.kvm
+++ b/run-fstests/config.kvm
@@ -6,7 +6,6 @@
NR_CPU=2
MEM=2048
-CPU_TYPE=host
#QEMU=/usr/local/bin/qemu-system-x86_64
QEMU=/usr/bin/kvm
diff --git a/run-fstests/kvm-xfstests b/run-fstests/kvm-xfstests
index 39126855..8fe3fbab 100755
--- a/run-fstests/kvm-xfstests
+++ b/run-fstests/kvm-xfstests
@@ -50,6 +50,18 @@ QUIET="quiet loglevel=0"
. $DIR/util/parse_cli
+if test -z "$EXPLICIT_ROOT_FS" ; then
+ ROOT_FS="$(dirname $DIR)/test-appliance/root_fs.img.$ARCH"
+ if ! test -f "$ROOT_FS" ; then
+ ROOT_FS="$(dirname $DIR)/test-appliance/root_fs.img"
+ fi
+fi
+
+if ! test -f "$ROOT_FS" ; then
+ echo "Can't find root_fs image: $ROOT_FS"
+ exit 1
+fi
+
if ! test -f "$KERNEL"; then
echo "$KERNEL: kernel not found"
exit 1
@@ -169,8 +181,29 @@ chmod 600 "$VDH"
mkdir -p /tmp/kvm-xfstests-$USER
+case "$ARCH" in
+ i386|amd64)
+ QEMU_ARCH=x86_64
+ ACCEL=kvm:tcg
+ CONSOLE_DEV=ttyS0
+ MACHINE_TYPE=q35
+ CPU_TYPE=max
+ ;;
+ arm64)
+ QEMU_ARCH=aarch64
+ ACCEL=tcg
+ CONSOLE_DEV=ttyAMA0
+ MACHINE_TYPE=virt
+ CPU_TYPE=max
+ ;;
+ *)
+ echo "Unsupported architecture: $ARCH"
+ exit 1;
+esac
+QEMU="qemu-system-$QEMU_ARCH"
+
$NO_ACTION $IONICE $QEMU -boot order=c $NET \
- -machine type=pc,accel=kvm:tcg $CPU_TYPE \
+ -machine $MACHINE_TYPE,accel=$ACCEL -cpu $CPU_TYPE \
-drive file=$ROOT_FS,if=virtio$SNAPSHOT \
-drive file=$VDB,cache=$CACHE,if=virtio,format=raw$AIO \
-drive file=$VDC,cache=$CACHE,if=virtio,format=raw$AIO \
@@ -191,7 +224,7 @@ $NO_ACTION $IONICE $QEMU -boot order=c $NET \
$NUMA \
--kernel $KERNEL \
$INITRD \
- --append "$QUIET root=$ROOT_DEV console=ttyS0,115200 nokaslr $ARG $EXTRA_ARG" |\
+ --append "$QUIET root=$ROOT_DEV console=$CONSOLE_DEV,115200 nokaslr $ARG $EXTRA_ARG" |\
tee $LOGFILE
if test -n "$DO_ARCHIVE"; then
diff --git a/run-fstests/util/parse_cli b/run-fstests/util/parse_cli
index 383ad05e..4631389d 100644
--- a/run-fstests/util/parse_cli
+++ b/run-fstests/util/parse_cli
@@ -233,6 +233,7 @@ shortopts="ac:C:g:hI:m:n:No:O:r:vx:X:"
longopts=(
aio:
arch:
+arm64
archive
bisect-bad:
bisect-good:
@@ -252,6 +253,7 @@ gce-zone:
gs-bucket:
help
hooks:
+i386
image-family:
image-project:
initrd:
@@ -359,6 +361,7 @@ while (( $# >= 1 )); do
if flavor_in gce ; then
IMAGE_FLAG="--image"
fi
+ EXPLICIT_ROOT_FS=yes
unset USING_DEFAULT_FAMILY
;;
-n) shift
@@ -395,9 +398,17 @@ while (( $# >= 1 )); do
fi
;;
--arch) shift
- supported_flavors gce
+ supported_flavors kvm gce
ARCH="$1"
;;
+ --arm64)
+ supported_flavors kvm gce
+ ARCH="arm64"
+ ;;
+ --i386)
+ supported_flavors kvm gce
+ ARCH="i386"
+ ;;
--blktests)
supported_flavors kvm gce
FSTESTOPT="$FSTESTOPT,blktests"
@@ -411,6 +422,7 @@ while (( $# >= 1 )); do
supported_flavors gce
ROOT_FS="$1"
IMAGE_FLAG="--image-family"
+ EXPLICIT_ROOT_FS=yes
unset USING_DEFAULT_FAMILY
;;
--fail-loop-count) shift
diff --git a/run-fstests/util/parse_opt_funcs b/run-fstests/util/parse_opt_funcs
index bd48e02d..54577604 100644
--- a/run-fstests/util/parse_opt_funcs
+++ b/run-fstests/util/parse_opt_funcs
@@ -16,12 +16,27 @@ flavor_in ()
find_kernel_to_use()
{
+ local kernel_in_build
+
+ case "$ARCH" in
+ i386|amd64)
+ kernel_in_build=arch/x86/boot/bzImage
+ ;;
+ arm64)
+ kernel_in_build=arch/arm64/boot/Image
+ ;;
+ *)
+ echo "Unknown architecture in find_kernel_to_use: $ARCH"
+ exit 1
+ ;;
+ esac
+
if test -z "$OVERRIDE_KERNEL" ; then
if test -f .git/kbuild/config ; then
- t=$(sed -ne 's/^BLD_DIR=//p' .git/kbuild/config);
+ t=$($KBUILD_DIR/kbuild --get-build-dir --arch $ARCH)
if test -n "$t" -a "$KERNEL" != "$t" -a \
"$KERNEL" != "$t/linux-image.deb" -a \
- "$KERNEL" != "$t/arch/x86/boot/bzImage" ; then
+ "$KERNEL" != "$t/$kernel_in_build" ; then
echo "Detected kbuild config; using $t for kernel"
KERNEL=$t
OVERRIDE_KERNEL=$t
@@ -29,9 +44,9 @@ find_kernel_to_use()
MODULES=
fi
fi
- elif test -f "./arch/x86/boot/bzImage" ; then
+ elif test -f "./$kernel_in_build" ; then
t=$(pwd)
- if test "$KERNEL" != "$t" -a "$KERNEL" != "$t/arch/x86/boot/bzImage"
+ if test "$KERNEL" != "$t" -a "$KERNEL" != "$t/$kernel_in_build"
then
echo "Current directory appears to be a kernel tree; using it"
KERNEL=$t
@@ -51,6 +66,6 @@ find_kernel_to_use()
if test -z "$OVERRIDE_MODULES" -a -f "$KERNEL/modules.tar.xz" ; then
MODULES="$KERNEL/modules.tar.xz"
fi
- KERNEL="$KERNEL/arch/x86/boot/bzImage"
+ KERNEL="$KERNEL/$kernel_in_build"
fi
}