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 10 source scripts/vmm.bash 11fi 12 13set_qemu_accelerator || exit $? 14 15qemu=$(search_qemu_binary) || 16 exit $? 17 18if ! ${qemu} -device '?' 2>&1 | grep -F -e \"testdev\" -e \"pc-testdev\" > /dev/null; 19then 20 echo "No Qemu test device support found" 21 exit 2 22fi 23 24if 25 ${qemu} -device '?' 2>&1 | grep -F "pci-testdev" > /dev/null; 26then 27 pci_testdev="-device pci-testdev" 28else 29 pci_testdev="" 30fi 31 32if 33 ${qemu} -device '?' 2>&1 | grep -F "pc-testdev" > /dev/null; 34then 35 pc_testdev="-device pc-testdev -device isa-debug-exit,iobase=0xf4,iosize=0x4" 36else 37 pc_testdev="-device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out" 38fi 39 40if 41 ${qemu} -vnc '?' 2>&1 | grep -F "vnc options" > /dev/null; 42then 43 vnc_none="-vnc none" 44else 45 vnc_none="" 46fi 47 48# Discard lost ticks from the Programmable Interval Timer (PIT, a.k.a 8254), as 49# enabling KVM's re-injection mode inhibits (x2)AVIC, i.e. prevents validating 50# (x2)AVIC. Note, the realmode test relies on the PIT, but not re-injection. 51pit="-global kvm-pit.lost_tick_policy=discard" 52 53command="${qemu} --no-reboot -nodefaults $pit $pc_testdev $vnc_none -serial stdio $pci_testdev" 54command+=" -machine accel=$ACCEL$ACCEL_PROPS" 55if [ "${CONFIG_EFI}" != y ]; then 56 command+=" -kernel" 57fi 58command="$(timeout_cmd) $command" 59 60if [ "${CONFIG_EFI}" = y ]; then 61 # Set ENVIRON_DEFAULT=n to remove '-initrd' flag for QEMU (see 62 # 'scripts/arch-run.bash' for more details). This is because when using 63 # UEFI, the test case binaries are passed to QEMU through the disk 64 # image, not through the '-kernel' flag. And QEMU reports an error if it 65 # gets '-initrd' without a '-kernel' 66 ENVIRON_DEFAULT=n run_test ${command} "$@" 67else 68 run_test ${command} "$@" 69fi 70