-
Notifications
You must be signed in to change notification settings - Fork 0
/
qemu-nic
executable file
·80 lines (67 loc) · 1.43 KB
/
qemu-nic
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
78
79
80
#!/bin/sh
#
# Run qemu with network interface if root.
#
# TODO:
# -s for gdb from command line
QEMUDIR=/home/joel
fatal()
{
echo $*
echo "Usage: [-v] [-n NIC]"
echo ""
echo "Supported NICs: e1000 i82559er i82551 i82557b rtl8139 ne2k_isa"
exit 1
}
nic="none"
verbose="no"
while getopts "vn:" OPT
do
case "$OPT" in
v) verbose="yes";;
n) nic="$OPTARG";;
*) fatal;;
esac
done
shiftcount=`expr $OPTIND - 1`
shift $shiftcount
args=$*
GRAPHICS="-serial stdio"
#GRAPHICS="${GRAPHICS} --nographic --monitor null"
# Model - isapc for ISA PC or pc for PCI
MODEL="-M pc"
NIC=
case ${nic} in
# PCI NIC model options that work with RTEMS:
# fxp: i82559er, i82551, i82557b
# rl: rtl8139
# em: e1000
e1000|i82559er|i82551|i82557b|rtl8139) NIC=${nic};;
# ISA NIC model: ne2k_isa
ne2k_isa) MODEL="-M isapc" ; NIC=${nic} ;;
none) ;;
*)
fatal Unknown NIC ${nic}
;;
esac
ARGS="${MODEL} -m 128 \
-boot a -fda ${QEMUDIR}/qemu/pc386_fda \
-hda fat:${QEMUDIR}/qemu/hd --no-reboot"
if [ ${nic} != "none" ] ; then
if [ $EUID -eq 0 ] ; then
NICARGS="\
-net nic,model=${NIC} \
-net nic,macaddr=00:80:7F:22:61:77 \
-net tap,script=/etc/qemu-ifup"
else
echo "*** You are not root -- ignoring request for NIC ***"
fi
if [ ! -r /etc/qemu-ifup ] ; then
echo /etc/qemu-ifup not found
exit 1
fi
qemu ${ARGS} ${GRAPHICS} ${NICARGS}
else
qemu ${ARGS} ${GRAPHICS}
fi
exit 0