| #!/usr/bin/env 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=$(search_qemu_binary) |
| |
| if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then |
| echo "$qemu doesn't support pSeries ('-machine pseries'). Exiting." |
| exit 2 |
| fi |
| |
| M='-machine pseries' |
| M+=",accel=$ACCEL" |
| command="$qemu -nodefaults $M -bios $FIRMWARE" |
| [ -f "$ENV" ] && command+=" -initrd $ENV" |
| command+=" -display none -serial stdio -kernel" |
| command="$(migration_cmd) $(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 |