xref: /kvm-unit-tests/riscv/run (revision abdc5d02a7796a55802509ac9bb704c721f2a5f6)
1#!/usr/bin/env bash
2
3if [ -z "$KUT_STANDALONE" ]; then
4	if [ ! -f config.mak ]; then
5		echo "run ./configure && make first. See ./configure -h"
6		exit 2
7	fi
8	source config.mak
9	source scripts/arch-run.bash
10fi
11
12# Allow user overrides of some config.mak variables
13mach=$MACHINE_OVERRIDE
14qemu_cpu=$TARGET_CPU_OVERRIDE
15firmware=$FIRMWARE_OVERRIDE
16
17: "${mach:=virt}"
18: "${qemu_cpu:=$TARGET_CPU}"
19: "${qemu_cpu:=$DEFAULT_QEMU_CPU}"
20: "${firmware:=$FIRMWARE}"
21[ "$firmware" ] && firmware="-bios $firmware"
22
23set_qemu_accelerator || exit $?
24[ "$ACCEL" = "kvm" ] && QEMU_ARCH=$HOST
25acc="-accel $ACCEL$ACCEL_PROPS"
26
27qemu=$(search_qemu_binary) || exit $?
28if [ "$mach" = 'virt' ] && ! $qemu -machine '?' | grep -q 'RISC-V VirtIO board'; then
29	echo "$qemu doesn't support mach-virt ('-machine virt'). Exiting."
30	exit 2
31fi
32mach="-machine $mach"
33
34command="$qemu -nodefaults -nographic -serial mon:stdio"
35command+=" $mach $acc $firmware -cpu $qemu_cpu "
36command="$(migration_cmd) $(timeout_cmd) $command"
37
38if [ "$UEFI_SHELL_RUN" = "y" ]; then
39	ENVIRON_DEFAULT=n run_qemu_status $command "$@"
40else
41	# We return the exit code via stdout, not via the QEMU return code
42	run_qemu_status $command -kernel "$@"
43fi
44