backup: Also run with Ethernet connection
[bin.git] / vm
1 #!/bin/sh
2 set -e
3 image="$1"
4 [ -e "$image" ] || { echo "Usage: $0 <image> [options...]" >&2; exit 1; }
5 shift
6 # determine ssh forward port
7 ssh_port=22000
8 while echo '' | nc localhost $ssh_port >/dev/null; do
9     ssh_port=$((ssh_port+1))
10 done
11 echo "Host ssh port: $ssh_port"
12 qemu-system-x86_64 -enable-kvm -display gtk -m 2048 -device virtio-rng-pci \
13     -drive file="$image",if=virtio \
14     -virtfs local,id=src,path=$HOME,security_model=none,mount_tag=home,readonly \
15     -net nic,model=virtio -net user,hostfwd=tcp::${ssh_port}-:22 "$@"