blob: aa5f8c73658ae186bcec9763770dc546dcdc9690 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#!/bin/sh
set -eu
disk() {
echo "-drive file=$1,format=raw,media=disk"
}
if [ -n "${QFLAGS:-}" ]; then
echo "QFLAGS in env"
fi
QFLAGS="-no-reboot -m 1g -gdb tcp::12366 $(disk out/boot.iso) $(disk out/fs.e2) ${QFLAGS:-}"
QEMU=qemu-system-x86_64
QDISPLAY="-display none"
QNET="-nic user,model=rtl8139,mac=52:54:00:ca:77:1a,net=192.168.0.0/24,hostfwd=tcp::12380-192.168.0.11:80,id=n1"
QKVM="-enable-kvm"
QTTY="-serial mon:stdio"
DRY_RUN=
TEST_RUN=
for opt; do
case "$opt" in
--display|-d)
QDISPLAY=
;;
--dry-run|-n)
DRY_RUN=1
;;
--help|-h)
echo $0 [opts]
sed -ne '/\t-.*)/ {s/)//; s/|/, /g; p}' $0
exit
;;
--pcap=*)
PCAP="${opt#*=}"
echo outputting pcap to $PCAP
QNET="$QNET -object filter-dump,id=f1,netdev=n1,file=$PCAP"
;;
--no-kvm)
QKVM=
;;
--test|-t)
rm -vf out/qemu.in out/qemu.out
mkfifo out/qemu.in out/qemu.out
TEST_RUN=1
QTTY="-serial pipe:out/qemu"
;;
--no-serial)
QTTY="-serial none"
;;
*)
echo "unknown option $opt"
exit 1
;;
esac
done
CMD="$QEMU $QDISPLAY $QNET $QKVM $QTTY $QFLAGS"
if [ -n "$DRY_RUN" ]; then
echo "$CMD"
elif [ -n "$TEST_RUN" ]; then
echo "$CMD &"
$CMD &
sleep 1 # dunno
# something eats the first character sent, so let's send a sacrificial newline
echo > out/qemu.in
# carry on with the tests
echo tests > out/qemu.in
echo halt > out/qemu.in
cat out/qemu.out
else
echo "$CMD"
$CMD
fi
|