1#!/bin/bash 2 3if [ ! -f config.mak ]; then 4 echo run ./configure first. See ./configure -h 5 exit 2 6fi 7source config.mak 8processor="$PROCESSOR" 9 10if [ -c /dev/kvm ]; then 11 if [ "$HOST" = "arm" ] && [ "$ARCH" = "arm" ]; then 12 kvm_available=yes 13 elif [ "$HOST" = "aarch64" ]; then 14 kvm_available=yes 15 fi 16fi 17 18if [ "$ACCEL" = "kvm" ] && [ "$kvm_available" != "yes" ] && 19 [ "$DRYRUN" != "yes" ]; then 20 printf "skip $TESTNAME (kvm only)\n\n" 21 exit 2 22fi 23 24if [ -z "$ACCEL" ]; then 25 if [ "$DRYRUN" = "yes" ]; then 26 # Output kvm with tcg fallback for dryrun (when both are 27 # allowed), since the command line we output may get used 28 # elsewhere. 29 ACCEL="kvm:tcg" 30 elif [ "$kvm_available" = "yes" ]; then 31 ACCEL="kvm" 32 else 33 ACCEL="tcg" 34 fi 35fi 36 37if [ "$ARCH" = "arm64" ]; then 38 if [[ $ACCEL =~ kvm ]]; then 39 # arm64 must use '-cpu host' with kvm, and we can't use 40 # '-cpu host' with tcg, so we force kvm-only (no fallback) 41 ACCEL="kvm" 42 processor="host" 43 fi 44fi 45 46qemu="${QEMU:-qemu-system-$ARCH_NAME}" 47qpath=$(which $qemu 2>/dev/null) 48 49if [ -z "$qpath" ]; then 50 echo $qemu not found. 51 exit 2 52fi 53 54if ! $qemu -machine '?' 2>&1 | grep 'ARM Virtual Machine' > /dev/null; then 55 echo "$qpath doesn't support mach-virt ('-machine virt'). Exiting." 56 exit 2 57fi 58 59M='-machine virt' 60 61if ! $qemu $M -device '?' 2>&1 | grep virtconsole > /dev/null; then 62 echo "$qpath doesn't support virtio-console for chr-testdev. Exiting." 63 exit 2 64fi 65 66if $qemu $M -chardev testdev,id=id -initrd . 2>&1 \ 67 | grep backend > /dev/null; then 68 echo "$qpath doesn't support chr-testdev. Exiting." 69 exit 2 70fi 71 72chr_testdev='-device virtio-serial-device' 73chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd' 74 75M+=",accel=$ACCEL" 76command="$qemu $M -cpu $processor $chr_testdev" 77command+=" -display none -serial stdio -kernel" 78echo $command "$@" 79 80if [ "$DRYRUN" != "yes" ]; then 81 $command "$@" 82 ret=$? 83 echo Return value from qemu: $ret 84 exit $ret 85fi 86