#!/bin/bash set -eux # from vm to make a shared folder if [ $# -lt 1 ] ; then echo """ IMG=${1:-disc_alpine.qcow2} SSH=${2:2223} SHARE=${3:-$PWD/share} CPUS=${4:-2} SIZE=${5:-16G} RAM=${6:-2G} GITEA=${7:-3000} """ echo "cheat sheet: mount -t 9p -o trans=virtio hostshare /mnt" exit 1 fi # --- Configurable defaults --- IMG=${1:-disc_alpine.qcow2} SSH=${2:-2223} SHARE=${3:-$PWD/share} CPUS=${4:-2} SIZE=${5:-16G} RAM=${6:-2G} GITEA=${7:-3000} # --- 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 \ -device virtio-vga \ -enable-kvm \ -display default,show-cursor=on \ -nic user,hostfwd=tcp::"${SSH}"-:22,hostfwd=tcp::"${GITEA}"-:3000 \ -virtfs local,id=share,path="$SHARE",security_model=none,mount_tag=hostshare