1#!/bin/bash 2NOTFOUND=1 3TESTDEVNOTSUPP=2 4 5qemubinarysearch="${QEMU:-qemu-kvm qemu-system-x86_64}" 6 7for qemucmd in ${qemubinarysearch} 8do 9 unset QEMUFOUND 10 unset qemu 11 if ! [ -z "${QEMUFOUND=$(${qemucmd} --help 2>/dev/null | grep "QEMU")}" ] && 12 ${qemucmd} -device '?' 2>&1 | grep -F -e \"testdev\" -e \"pc-testdev\" > /dev/null; 13 then 14 qemu="${qemucmd}" 15 break 16 fi 17done 18 19if [ -z "${QEMUFOUND}" ] 20then 21 echo "A QEMU binary was not found, You can set a custom location by using the QEMU=<path> environment variable " 22 exit ${NOTFOUND} 23elif [ -z "${qemu}" ] 24then 25 echo "No Qemu test device support found" 26 exit ${TESTDEVNOTSUPP} 27fi 28 29if 30 ${qemu} -device '?' 2>&1 | grep -F "pci-testdev" > /dev/null; 31then 32 pci_testdev="-device pci-testdev" 33else 34 pci_testdev="" 35fi 36 37if 38 ${qemu} -device '?' 2>&1 | grep -F "pc-testdev" > /dev/null; 39then 40 pc_testdev="-device pc-testdev -device isa-debug-exit,iobase=0xf4,iosize=0x4" 41else 42 pc_testdev="-device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out" 43fi 44 45command="${qemu} -enable-kvm $pc_testdev -vnc none -serial stdio $pci_testdev $hyperv_testdev -kernel" 46echo ${command} "$@" 47 48${command} "$@" 49ret=$? 50echo Return value from qemu: $ret 51exit $ret 52