xref: /kvm-unit-tests/powerpc/run (revision fcf4e0d9d06ff6c2b4b802d98d13390772e330bb)
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
11
12if [ -c /dev/kvm ]; then
13	if [ "$HOST" = "ppc64" ] && [ "$ARCH" = "ppc64" ]; then
14		kvm_available=yes
15	fi
16fi
17
18if [ "$ACCEL" = "kvm" ] && [ "$kvm_available" != "yes" ]; then
19	echo "KVM is needed, but not available on this host"
20	exit 2
21fi
22
23if [ -z "$ACCEL" ]; then
24	if [ "$kvm_available" = "yes" ]; then
25		ACCEL="kvm"
26	else
27		ACCEL="tcg"
28	fi
29fi
30
31qemu=$(search_qemu_binary) ||
32	exit $?
33
34if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then
35	echo "$qemu doesn't support pSeries ('-machine pseries'). Exiting."
36	exit 2
37fi
38
39M='-machine pseries'
40M+=",accel=$ACCEL"
41command="$qemu -nodefaults $M -bios $FIRMWARE"
42command+=" -display none -serial stdio -kernel"
43command="$(migration_cmd) $(timeout_cmd) $command"
44
45# powerpc tests currently exit with rtas-poweroff, which exits with 0.
46# run_qemu treats that as a failure exit and returns 1, so we need
47# to fixup the fixup below by parsing the true exit code from the output.
48# The second fixup is also a FIXME, because once we add chr-testdev
49# support for powerpc, we won't need the second fixup.
50run_qemu_status $command "$@"
51