#!/bin/bash if [ -z "$STANDALONE" ]; then if [ ! -f config.mak ]; then echo "run ./configure && make first. See ./configure -h" exit 2 fi source config.mak source scripts/arch-run.bash fi if [ -c /dev/kvm ]; then if [ "$HOST" = "ppc64" ] && [ "$ARCH" = "ppc64" ]; then kvm_available=yes fi fi if [ "$ACCEL" = "kvm" ] && [ "$kvm_available" != "yes" ]; then echo "KVM is needed, but not available on this host" exit 2 fi if [ -z "$ACCEL" ]; then if [ "$kvm_available" = "yes" ]; then ACCEL="kvm" else ACCEL="tcg" fi fi qemu="${QEMU:-qemu-system-$ARCH_NAME}" qpath=$(which $qemu 2>/dev/null) if [ -z "$qpath" ]; then echo $qemu not found. exit 2 fi if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then echo "$qpath doesn't support pSeries ('-machine pseries'). Exiting." exit 2 fi M='-machine pseries' M+=",accel=$ACCEL" command="$qemu $M -bios $FIRMWARE" command+=" -display none -serial stdio -kernel" command="$(timeout_cmd) $command" echo $command "$@" # powerpc tests currently exit with rtas-poweroff, which exits with 0. # run_qemu treats that as a failure exit and returns 1, so we need # to fixup the fixup below by parsing the true exit code from the output. # The second fixup is also a FIXME, because once we add chr-testdev # support for powerpc, we won't need the second fixup. lines=$(run_qemu $command "$@") ret=$? echo "$lines" if [ $ret -eq 1 ]; then testret=$(grep '^EXIT: ' <<<"$lines" | sed 's/.*STATUS=\([0-9][0-9]*\).*/\1/') if [ "$testret" ]; then if [ $testret -eq 1 ]; then ret=0 else ret=$testret fi fi fi exit $ret