#! /bin/sh

HERE=`dirname $0`
case "$HERE" in
/*)
    ;;
*)
    HERE=$PWD/$HERE
    ;;
esac

export SDL_VIDEODRIVER=x11

# SDL_AUDIODRIVER=oss or alsa. Only meaningful if QEMU_AUDIO_DRV=sdl.
export SDL_AUDIODRIVER=alsa

# QEMU_AUDIO_DRV=oss, sdl, wav, spice or none. See qemu -audio-help.
export QEMU_AUDIO_DRV=none

CORE_PARAMS="-machine type=pc,accel=kvm -m 512 -vga none -daemonize -name \
	squeeze-x64 -balloon virtio -smp 2 -soundhw ac97 -serial none \
	-parallel none -chardev \
	socket,id=monsock,host=127.0.0.1,port=2934,ipv4,server,telnet,nowait \
	-mon chardev=monsock,mode=readline -uuid \
	da6640ce-0dbd-8617-7bf1-c38340666854"

#FS_PARAMS="-virtfs proxy,id=dpc_src,socket=/var/run/virtfs-dpc-src,mount_tag=diet-pc-src"

#REDIR_PARAMS="-device pci-assign,host=01:00.0 -device pci-assign,host=01:00.1"
#REDIR_PARAMS="-device vfio-pci,host=01:00.0,multifunction=on,x-vga=on,addr=7.0 \
#	-device vfio-pci,host=01:00.1,x-vga=on,addr=7.1"
#REDIR_PARAMS="-device vfio-pci,host=01:00.0,x-vga=on"

#USB_PARAMS="-device piix3-usb-uhci -device usb-tablet"
USB_PARAMS="-device piix3-usb-uhci \
	-device usb-host,vendorid=0x093a,productid=0x2510 \
	-device usb-host,vendorid=0x0557,productid=0x2213"

SPICE_PARAMS="-global qxl.vram_size=67108864 -spice port=5934,disable-ticketing,agent-mouse=on \
	-device virtio-serial-pci,id=virtio-serial0 \
	-chardev spicevmc,id=vdagent,name=vdagent \
	-device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent"

NET_PARAMS="-net nic,macaddr=52:54:00:66:68:54,model=virtio \
	-net tap,ifname=squeeze-x64,vhost=on"

DISK_PARAMS="-drive file=$HERE/squeeze-x64.raw,if=virtio,aio=native \
	-drive file=/dev/raid/tlxdev,if=virtio,index=1,aio=native"

# One of: a (floppy), c (hard disk), d (cdrom), n (network using PXE)
BOOT_PARAMS='-boot order=c'

echo '== Display on 5934, monitor on 2934 ==='

eval qemu-system-x86_64 $CORE_PARAMS $REDIR_PARAMS $USB_PARAMS \
	$NET_PARAMS $DISK_PARAMS $BOOT_PARAMS
