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