#!/bin/bash

ISOS_DIR=out
HD_IMG=
SSH_FWD_HOST_PORT=
ISO="$(ls -t $ISOS_DIR/*.iso | head -n 1)"
VIRTIO_NET_DEV="-netdev user,id=vmnic,hostfwd=tcp::$SSH_FWD_HOST_PORT-:22 \
                -device virtio-net,netdev=vmnic"
[ "$HD_IMG" ] && HD="-drive file=$HD_IMG,format=raw,cache=writeback" || HD=''
[ "$SSH_FWD_HOST_PORT" ] && NET_DEV="$VIRTIO_NET_DEV" || NET_DEV=''


qemu-system-x86_64 -enable-kvm -m 2G $HD -cdrom $ISO -boot order=d $NET_DEV  \
                   -vga std -soundhw hda -display sdl -no-frame -show-cursor
