3. Running VM as deamon with VNC

To run Qemu with a bridged network and VNC, run:

#!/usr/bin/ksh

root=/wakes/vm

image=$root/devlab.img

pidfile=$root/devlab.pid

memory=128

tap=tap1

vnc=1

mac=52:54:00:12:34:58

case $1 in
  start)
    # with tun/tap network
    /usr/local/bin/qemu -daemonize -M pc -m $memory -hda $image \
      -pidfile $pidfile -net nic,vlan=0,macaddr=$mac \
      -net tap,vlan=0,ifname=$tap,script=/etc/qemu-ifup \
      -boot c -vnc :$vnc -localtime -k fr
  ;;
  stop)
    kill $(cat $pidfile)
    rm $pidfile
  ;;
  console)
    vncviewer :$vnc
  ;;
  install)
    /usr/local/bin/qemu -M pc -m $memory -hda $image -localtime \
      -net nic,vlan=0,macaddr=$mac \
      -net tap,vlan=0,ifname=$tap,script=/etc/qemu-ifup \
      -boot d -cdrom /wakes/iso/wakes.iso -vnc :$vnc -k fr
  ;;
esac

exit 0