summaryrefslogtreecommitdiff
path: root/qemu-support
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-06-04 22:19:39 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-06-04 22:19:39 +0000
commit786fa0d327c1d401df3f7ff049b073f113638572 (patch)
treeff1b5b5ea3d9f3e51e21eaeb14fd985d688c224f /qemu-support
parent1f2e06618c0ab9b6b41ed80caf79840736f3a4a9 (diff)
2009-06-04 Joel Sherrill <joel.sherrill@OARcorp.com>
* qemu-nic: Improve qemu-nic so you can provide the NIC type as an argument and force the network off when root.
Diffstat (limited to 'qemu-support')
-rw-r--r--qemu-support/ChangeLog5
-rwxr-xr-xqemu-support/qemu-nic56
2 files changed, 49 insertions, 12 deletions
diff --git a/qemu-support/ChangeLog b/qemu-support/ChangeLog
index 70224fc..00ad3cc 100644
--- a/qemu-support/ChangeLog
+++ b/qemu-support/ChangeLog
@@ -1,3 +1,8 @@
+2009-06-04 Joel Sherrill <joel.sherrill@OARcorp.com>
+
+ * qemu-nic: Improve qemu-nic so you can provide the NIC type as an
+ argument and force the network off when root.
+
2009-05-15 Joel Sherrill <joel.sherrill@oarcorp.com>
* qemu-nic: Do not invoke qemu from /usr/local/bin.
diff --git a/qemu-support/qemu-nic b/qemu-support/qemu-nic
index 4bdf571..1b2a53e 100755
--- a/qemu-support/qemu-nic
+++ b/qemu-support/qemu-nic
@@ -10,32 +10,64 @@
QEMUDIR=/home/joel
-# Model - isapc for ISA PC or pc for PCI
+fatal()
+{
+ echo $*
+ echo FATAL ERROR
+ exit 1
+}
-# PCI NIC model options that work with RTEMS:
-# i82558er, i82551, i82557b, rtl8139
-# ISA NIC model: ne2k_isa
+nic="none"
+verbose="no"
-MODEL="-M pc"
-#MODEL="-M isapc"
-NIC=i82557b
+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:
+ # i82558er, i82551, i82557b, rtl8139
+ i82558er|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 8 \
-boot a -fda ${QEMUDIR}/qemu/pc386_fda \
-hda fat:${QEMUDIR}/qemu/hd --no-reboot"
-if [ $EUID -eq 0 ] ; then
+if [ ${nic} != "none" -a $EUID -eq 0 ] ; then
+ NICARGS="\
+ -net nic,model=${NIC} \
+ -net nic,macaddr=00:80:7F:22:61:77 \
+ -net tap,script=/etc/qemu-ifup"
if [ ! -r /etc/qemu-ifup ] ; then
echo /etc/qemu-ifup not found
exit 1
fi
- qemu ${ARGS} ${GRAPHICS} \
- -net nic,model=${NIC} \
- -net nic,macaddr=00:80:7F:22:61:77 \
- -net tap,script=/etc/qemu-ifup
+ qemu ${ARGS} ${GRAPHICS} ${NICARGS}
else
qemu ${ARGS} ${GRAPHICS}
fi
+
+exit 0