blob: 662a8564674a3bd19c1cd9e20f4bc410a6be375a [file] [log] [blame]
#!/bin/bash
if [ ! -f config.mak ]; then
echo run ./configure first. See ./configure -h
exit 2
fi
source config.mak
processor="$PROCESSOR"
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
M='-machine virt,accel=kvm:tcg'
chr_testdev='-device virtio-serial-device'
chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd'
# arm64 must use '-cpu host' with kvm
if [ "$(arch)" = "aarch64" ] && [ "$ARCH" = "arm64" ] && [ -c /dev/kvm ]; then
processor="host"
fi
command="$qemu $M -cpu $processor $chr_testdev"
command+=" -display none -serial stdio -kernel"
echo $command "$@"
$command "$@"
ret=$?
echo Return value from qemu: $ret
exit $ret