xref: /kvm-unit-tests/arm/run (revision bb4c17e3783ce4578065f8ea55b6227dc0f53ad8)
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
11processor="$PROCESSOR"
12
13accel=$(get_qemu_accelerator) ||
14	exit $?
15
16if [ "$accel" = "kvm" ]; then
17	QEMU_ARCH=$HOST
18fi
19
20qemu=$(search_qemu_binary) ||
21	exit $?
22
23if [ "$QEMU" ] && [ -z "$ACCEL" ] &&
24   [ "$HOST" = "aarch64" ] && [ "$ARCH" = "arm" ] &&
25   [ "$(basename $QEMU)" = "qemu-system-arm" ]; then
26	accel=tcg
27fi
28
29ACCEL=$accel
30
31if ! $qemu -machine '?' | grep -q 'ARM Virtual Machine'; then
32	echo "$qemu doesn't support mach-virt ('-machine virt'). Exiting."
33	exit 2
34fi
35
36M='-machine virt'
37
38if [ "$ACCEL" = "kvm" ]; then
39	if $qemu $M,\? | grep -q gic-version; then
40		M+=',gic-version=host'
41	fi
42fi
43
44if [ "$ACCEL" = "kvm" ] || [ "$ACCEL" = "hvf" ]; then
45	if [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ]; then
46		processor="host"
47		if [ "$ARCH" = "arm" ] && [ "$HOST" = "aarch64" ]; then
48			processor+=",aarch64=off"
49		fi
50	fi
51fi
52
53if [ "$ARCH" = "arm" ]; then
54	M+=",highmem=off"
55fi
56
57if ! $qemu $M -device '?' | grep -q virtconsole; then
58	echo "$qemu doesn't support virtio-console for chr-testdev. Exiting."
59	exit 2
60fi
61
62if ! $qemu $M -chardev '?' | grep -q testdev; then
63	echo "$qemu doesn't support chr-testdev. Exiting."
64	exit 2
65fi
66
67chr_testdev='-device virtio-serial-device'
68chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd'
69
70pci_testdev=
71if $qemu $M -device '?' | grep -q pci-testdev; then
72	pci_testdev="-device pci-testdev"
73fi
74
75A="-accel $ACCEL"
76command="$qemu -nodefaults $M $A -cpu $processor $chr_testdev $pci_testdev"
77command+=" -display none -serial stdio -kernel"
78command="$(migration_cmd) $(timeout_cmd) $command"
79
80run_qemu $command "$@"
81