#! /bin/sh

fatal()
{
  echo "$*"
  exit 1
}
check_fatal()
{
  if [ ${1} -ne 0 ] ; then
    shift
    fatal $*
  fi
}

cpus=2
verbose="no"

while getopts "vc:" OPT
do
  case "$OPT" in
    v) verbose="yes";;
    c) cpus=${OPTARG} ;;
    *) fatal "unknown argument" ;;
  esac
done

shiftcount=`expr $OPTIND - 1`
shift $shiftcount

if [ ${#} -ne 1 ] ; then
  fatal "Usage: $0 EXENAME_WITHOUT_.exe"
fi

cp `find . -name ${1}.exe` ~/qemu/hd/test.exe 
check_fatal $? "Unable to locate executable ${1}"

/usr/bin/qemu -M pc -m 64 -cpu core2duo  -boot a \
    -fda /home/joel/qemu/pc386_fda \
    -hda fat:/home/joel/qemu/hd \
    --no-reboot -serial stdio  -smp ${cpus} 

