]> piware.de Git - bin.git/commitdiff
add vm script to launch QEMU with ssh port redirection and virtio
authorMartin Pitt <martin.pitt@ubuntu.com>
Tue, 3 Mar 2015 10:15:43 +0000 (11:15 +0100)
committerMartin Pitt <martin.pitt@ubuntu.com>
Tue, 3 Mar 2015 10:15:43 +0000 (11:15 +0100)
vm [new file with mode: 0755]

diff --git a/vm b/vm
new file mode 100755 (executable)
index 0000000..5c49759
--- /dev/null
+++ b/vm
@@ -0,0 +1,13 @@
+#!/bin/sh
+set -e
+image="$1"
+[ -e "$image" ] || { echo "Usage: $0 <image> [options...]" >&2; exit 1; }
+shift
+# determine ssh forward port
+ssh_port=22000
+while echo '' | nc localhost $ssh_port >/dev/null; do
+    ssh_port=$((ssh_port+1))
+done
+echo "Host ssh port: $ssh_port"
+qemu-system-x86_64 -enable-kvm -m 2048 -drive file="$image",if=virtio \
+    -net nic,model=virtio -net user,hostfwd=tcp::${ssh_port}-:22 "$@"