1#!/usr/bin/env bash 2 3if [ -z "$KUT_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 13ACCEL=$(get_qemu_accelerator) || 14 exit $? 15 16if [ "$ACCEL" = "kvm" ]; then 17 QEMU_ARCH=$HOST 18fi 19 20qemu=$(search_qemu_binary) || 21 exit $? 22 23if ! $qemu -machine '?' 2>&1 | grep 'ARM Virtual Machine' > /dev/null; then 24 echo "$qemu doesn't support mach-virt ('-machine virt'). Exiting." 25 exit 2 26fi 27 28M='-machine virt' 29 30if [ "$ACCEL" = "kvm" ]; then 31 if $qemu $M,\? 2>&1 | grep gic-version > /dev/null; then 32 M+=',gic-version=host' 33 fi 34fi 35 36if [ "$ACCEL" = "kvm" ] || [ "$ACCEL" = "hvf" ]; then 37 if [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ]; then 38 processor="host" 39 if [ "$ARCH" = "arm" ] && [ "$HOST" = "aarch64" ]; then 40 processor+=",aarch64=off" 41 fi 42 fi 43fi 44 45if [ "$ARCH" = "arm" ]; then 46 M+=",highmem=off" 47fi 48 49if ! $qemu $M -device '?' 2>&1 | grep virtconsole > /dev/null; then 50 echo "$qemu doesn't support virtio-console for chr-testdev. Exiting." 51 exit 2 52fi 53 54if $qemu $M -chardev testdev,id=id -initrd . 2>&1 \ 55 | grep backend > /dev/null; then 56 echo "$qemu doesn't support chr-testdev. Exiting." 57 exit 2 58fi 59 60chr_testdev='-device virtio-serial-device' 61chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd' 62 63pci_testdev= 64if $qemu $M -device '?' 2>&1 | grep pci-testdev > /dev/null; then 65 pci_testdev="-device pci-testdev" 66fi 67 68A="-accel $ACCEL" 69command="$qemu -nodefaults $M $A -cpu $processor $chr_testdev $pci_testdev" 70command+=" -display none -serial stdio -kernel" 71command="$(migration_cmd) $(timeout_cmd) $command" 72 73run_qemu $command "$@" 74