#!/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