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 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 34qemu=$(search_qemu_binary) 35 36if ! $qemu -machine '?' 2>&1 | grep 'ARM Virtual Machine' > /dev/null; then 37 echo "$qemu doesn't support mach-virt ('-machine virt'). Exiting." 38 exit 2 39fi 40 41M='-machine virt' 42 43if [ "$ACCEL" = "kvm" ]; then 44 if $qemu $M,\? 2>&1 | grep gic-version > /dev/null; then 45 M+=',gic-version=host' 46 fi 47 if [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ]; then 48 processor="host" 49 if [ "$ARCH" = "arm" ] && [ "$HOST" = "aarch64" ]; then 50 processor+=",aarch64=off" 51 fi 52 fi 53fi 54 55if ! $qemu $M -device '?' 2>&1 | grep virtconsole > /dev/null; then 56 echo "$qemu doesn't support virtio-console for chr-testdev. Exiting." 57 exit 2 58fi 59 60if $qemu $M -chardev testdev,id=id -initrd . 2>&1 \ 61 | grep backend > /dev/null; then 62 echo "$qemu doesn't support chr-testdev. Exiting." 63 exit 2 64fi 65 66chr_testdev='-device virtio-serial-device' 67chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd' 68 69pci_testdev= 70if $qemu $M -device '?' 2>&1 | grep pci-testdev > /dev/null; then 71 pci_testdev="-device pci-testdev" 72fi 73 74M+=",accel=$ACCEL" 75command="$qemu -nodefaults $M -cpu $processor $chr_testdev $pci_testdev" 76command+=" -display none -serial stdio -kernel" 77command="$(timeout_cmd) $command" 78 79run_qemu $command "$@" 80