PRJN=qemu-lp #Project Name
INS_VAR=0
INS_DIR=/data/${PRJN} 
PWD_DIR=`pwd`  # current directory
PV=`echo $PATH | busybox grep '\/system\/bin'`
if [ "$PV" == "" ]; then
	export PATH=$PATH:/system/xbin
fi
export DISPLAY=:0

if [ ! -e "$INS_DIR/bin/qemu-system-i386" ]; then
  INS_VAR=1
  IMG=./${PRJN}.img
  mkdir $INS_DIR
  busybox mount $IMG $INS_DIR
fi

PARS=""
while read line
do
a=`echo $line | busybox sed 's/^[ ]*\t*$//;s/^[ \t]*\#.*$//' ` # ignore lines consist with spaces or tabs and comment out lines
if [ "$a" != "" ]; then
  b=`echo $a |busybox grep '\-hd'` # for -hdx image argument
  if [ "$b" != "" ]; then
    c=`echo $b | busybox awk '{print $1}'`  # -hdx
    d=`echo $b | busybox awk '{print $2}'`  # image filename
    if  [ "${d:0:1}" != "/" ];then  #relative path
       a="$c $PWD_DIR/$d"
    fi
  fi
  PARS="$a ${PARS}"
fi
done <$1
echo "cd ${INS_DIR}/bin; ./qemu-system-i386 ${PARS}"
cd $INS_DIR/bin
./qemu-system-i386 ${PARS}
#if [ $INS_VAR -eq 1 ]; then
#  umount $INS_DIR
#fi
