1#!/bin/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 11processor="$PROCESSOR" 12 13if [ -c /dev/kvm ]; then 14 if [ "$HOST" = "arm" ] && [ "$ARCH" = "arm" ]; then 15 kvm_available=yes 16 elif [ "$HOST" = "aarch64" ]; then 17 kvm_available=yes 18 fi 19fi 20 21if [ "$ACCEL" = "kvm" ] && [ "$kvm_available" != "yes" ]; then 22 echo "KVM is needed, but not available on this host" 23 exit 2 24fi 25 26if [ -z "$ACCEL" ]; then 27 if [ "$kvm_available" = "yes" ]; then 28 ACCEL="kvm" 29 else 30 ACCEL="tcg" 31 fi 32fi 33 34if [ "$HOST" = "aarch64" ] && [ "$ACCEL" = "kvm" ]; then 35 processor="host" 36 if [ "$ARCH" = "arm" ]; then 37 processor+=",aarch64=off" 38 fi 39fi 40 41qemu="${QEMU:-qemu-system-$ARCH_NAME}" 42qpath=$(which $qemu 2>/dev/null) 43 44if [ -z "$qpath" ]; then 45 echo $qemu not found. 46 exit 2 47fi 48 49if ! $qemu -machine '?' 2>&1 | grep 'ARM Virtual Machine' > /dev/null; then 50 echo "$qpath doesn't support mach-virt ('-machine virt'). Exiting." 51 exit 2 52fi 53 54M='-machine virt' 55 56if ! $qemu $M -device '?' 2>&1 | grep virtconsole > /dev/null; then 57 echo "$qpath doesn't support virtio-console for chr-testdev. Exiting." 58 exit 2 59fi 60 61if $qemu $M -chardev testdev,id=id -initrd . 2>&1 \ 62 | grep backend > /dev/null; then 63 echo "$qpath doesn't support chr-testdev. Exiting." 64 exit 2 65fi 66 67chr_testdev='-device virtio-serial-device' 68chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd' 69 70M+=",accel=$ACCEL" 71command="$qemu $M -cpu $processor $chr_testdev" 72command+=" -display none -serial stdio -kernel" 73command="$(timeout_cmd) $command" 74echo $command "$@" 75 76run_qemu $command "$@" 77