xref: /kvm-unit-tests/x86/run (revision 3c7d322e87043aaad022e1999844c82d7b373aa9)
1#!/bin/bash
2
3[ -z "$STANDALONE" ] && source scripts/arch-run.bash
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 2
23elif    [ -z "${qemu}" ]
24then
25	echo "No Qemu test device support found"
26	exit 2
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} -nodefaults -enable-kvm $pc_testdev -vnc none -serial stdio $pci_testdev $hyperv_testdev"
46[ -f "$ENV" ] && command+=" -initrd $ENV"
47command+=" -kernel"
48command="$(timeout_cmd) $command"
49echo ${command} "$@"
50
51run_qemu ${command} "$@"
52