#!/bin/bash
set -eux

# from vm to make a shared folder
if [ $# -lt 1 ] ; then
	echo """
	"""
	echo "cheat sheet: mount -t 9p -o trans=virtio hostshare /mnt"
	exit 1
fi

# --- Configurable defaults ---
IMG=${1:-disc_alpine.qcow2}
SSH=${2:-2222}
SHARE=${3:-$PWD/shared}
CPUS=${4:-2}
SIZE=${5:-16G}
RAM=${6:-2G}

# --- Setup ---
mkdir -p "$SHARE"

# --- Optional install script ---
# Drop any file named install.sh in ./share to execute it inside the VM later:
# e.g. `bash /mnt/share/install.sh` after mounting



qemu-system-x86_64 \
	-m $RAM \
	-boot once=d \
	-drive file=$IMG \
	-enable-kvm \
	-display spice-app,show-cursor=on \
	-nic user,hostfwd=tcp::"${SSH}"-:22

