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