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