#!/bin/sh
IMAGE_DIR="${0%/*}/"

if [ "${1}" = "serial-only" ]; then
    EXTRA_ARGS='-nographic'
else
    EXTRA_ARGS='-serial stdio'
fi

module load qemu
exec qemu-system-x86_64 -M pc \
	-kernel ${IMAGE_DIR}/bzImage \
	-drive file=${IMAGE_DIR}/rootfs.ext2,if=virtio,format=raw \
	-append "rootwait root=/dev/vda console=tty1 console=ttyS0" \
	-net nic,model=virtio -net user ${EXTRA_ARGS}
