#!/bin/bash if [ -z "$STANDALONE" ]; then if [ ! -f config.mak ]; then echo "run ./configure && make first. See ./configure -h" exit 2 fi source config.mak source scripts/arch-run.bash fi processor="$PROCESSOR" if [ -c /dev/kvm ]; then if [ "$HOST" = "arm" ] && [ "$ARCH" = "arm" ]; then kvm_available=yes elif [ "$HOST" = "aarch64" ]; then kvm_available=yes fi fi if [ "$ACCEL" = "kvm" ] && [ "$kvm_available" != "yes" ]; then echo "KVM is needed, but not available on this host" exit 2 fi if [ -z "$ACCEL" ]; then if [ "$kvm_available" = "yes" ]; then ACCEL="kvm" else ACCEL="tcg" fi fi if [ "$HOST" = "aarch64" ] && [ "$ACCEL" = "kvm" ]; then processor="host" if [ "$ARCH" = "arm" ]; then processor+=",aarch64=off" fi fi qemu="${QEMU:-qemu-system-$ARCH_NAME}" qpath=$(which $qemu 2>/dev/null) if [ -z "$qpath" ]; then echo $qemu not found. exit 2 fi if ! $qemu -machine '?' 2>&1 | grep 'ARM Virtual Machine' > /dev/null; then echo "$qpath doesn't support mach-virt ('-machine virt'). Exiting." exit 2 fi M='-machine virt' if ! $qemu $M -device '?' 2>&1 | grep virtconsole > /dev/null; then echo "$qpath doesn't support virtio-console for chr-testdev. Exiting." exit 2 fi if $qemu $M -chardev testdev,id=id -initrd . 2>&1 \ | grep backend > /dev/null; then echo "$qpath doesn't support chr-testdev. Exiting." exit 2 fi chr_testdev='-device virtio-serial-device' chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd' M+=",accel=$ACCEL" command="$qemu $M -cpu $processor $chr_testdev" command+=" -display none -serial stdio -kernel" command="$(timeout_cmd) $command" echo $command "$@" run_qemu $command "$@"