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 10qemu="${QEMU:-qemu-system-$ARCH_NAME}" 11qpath=$(which $qemu 2>/dev/null) 12 13if [ -z "$qpath" ]; then 14 echo $qemu not found. 15 exit 2 16fi 17 18if ! $qemu -machine '?' 2>&1 | grep 'ARM Virtual Machine' > /dev/null; then 19 echo "$qpath doesn't support mach-virt ('-machine virt'). Exiting." 20 exit 2 21fi 22 23M='-machine virt' 24 25if ! $qemu $M -device '?' 2>&1 | grep virtconsole > /dev/null; then 26 echo "$qpath doesn't support virtio-console for chr-testdev. Exiting." 27 exit 2 28fi 29 30if $qemu $M -chardev testdev,id=id -initrd . 2>&1 \ 31 | grep backend > /dev/null; then 32 echo "$qpath doesn't support chr-testdev. Exiting." 33 exit 2 34fi 35 36M='-machine virt,accel=kvm:tcg' 37chr_testdev='-device virtio-serial-device' 38chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd' 39 40# arm64 must use '-cpu host' with kvm 41if [ "$(arch)" = "aarch64" ] && [ "$ARCH" = "arm64" ] && [ -c /dev/kvm ]; then 42 processor="host" 43fi 44 45command="$qemu $M -cpu $processor $chr_testdev" 46command+=" -display none -serial stdio -kernel" 47 48echo $command "$@" 49$command "$@" 50ret=$? 51echo Return value from qemu: $ret 52exit $ret 53