xref: /kvm-unit-tests/arm/run (revision 33a6576c6e1bfd98fd35402c9f64dfd7537dd2ff)
1#!/usr/bin/env bash
2
3if [ -z "$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
16qemu=$(search_qemu_binary) ||
17	exit $?
18
19if ! $qemu -machine '?' 2>&1 | grep 'ARM Virtual Machine' > /dev/null; then
20	echo "$qemu doesn't support mach-virt ('-machine virt'). Exiting."
21	exit 2
22fi
23
24M='-machine virt'
25
26if [ "$ACCEL" = "kvm" ]; then
27	if $qemu $M,\? 2>&1 | grep gic-version > /dev/null; then
28		M+=',gic-version=host'
29	fi
30	if [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ]; then
31		processor="host"
32		if [ "$ARCH" = "arm" ] && [ "$HOST" = "aarch64" ]; then
33			processor+=",aarch64=off"
34		fi
35	fi
36fi
37
38if [ "$ARCH" = "arm" ]; then
39	M+=",highmem=off"
40fi
41
42if ! $qemu $M -device '?' 2>&1 | grep virtconsole > /dev/null; then
43	echo "$qemu doesn't support virtio-console for chr-testdev. Exiting."
44	exit 2
45fi
46
47if $qemu $M -chardev testdev,id=id -initrd . 2>&1 \
48		| grep backend > /dev/null; then
49	echo "$qemu doesn't support chr-testdev. Exiting."
50	exit 2
51fi
52
53chr_testdev='-device virtio-serial-device'
54chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd'
55
56pci_testdev=
57if $qemu $M -device '?' 2>&1 | grep pci-testdev > /dev/null; then
58	pci_testdev="-device pci-testdev"
59fi
60
61M+=",accel=$ACCEL"
62command="$qemu -nodefaults $M -cpu $processor $chr_testdev $pci_testdev"
63command+=" -display none -serial stdio -kernel"
64command="$(migration_cmd) $(timeout_cmd) $command"
65
66run_qemu $command "$@"
67