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" = "s390x" ] && [ "$ARCH" = "s390x" ]; 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 33M='-machine s390-ccw-virtio' 34M+=",accel=$ACCEL" 35command="$qemu -nodefaults -nographic $M" 36command+=" -chardev stdio,id=con0 -device sclpconsole,chardev=con0" 37command+=" -kernel" 38command="$(timeout_cmd) $command" 39 40# We return the exit code via stdout, not via the QEMU return code 41lines=$(run_qemu $command "$@") 42ret=$? 43echo "$lines" 44if [ $ret -eq 1 ]; then 45 testret=$(grep '^EXIT: ' <<<"$lines" | sed 's/.*STATUS=\([0-9][0-9]*\).*/\1/') 46 if [ "$testret" ]; then 47 if [ $testret -eq 1 ]; then 48 ret=0 49 else 50 ret=$testret 51 fi 52 fi 53fi 54exit $ret 55