diff --git a/bin/qemush b/bin/qemush index ae826bb..1f568c8 100755 --- a/bin/qemush +++ b/bin/qemush @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# version=0.6.1 +# version=0.7.0 # Re-exec the script as qemu via sudo (only if needed) [ "$(whoami)" != qemu ] && exec sudo -E -H -u qemu -- "$0" "$@" @@ -40,6 +40,7 @@ ${name}: usage: ${name} help - show this help ${name} add [] - add a launching script ${name} do - run shell input as user qemu + ${name} spice [] - expose a SPICE socket to TCP EOF } @@ -166,6 +167,19 @@ public_do() { exec sh -c "$*" } +# Expose SPICE via TCP +public_spice() { + QEMUSH_NAME="$1" + if [ -n "$2" ]; then + port=$2 + else + port=$(first-free-port 5900) + fi + + exec tmux new -d -s "TCP port ${port} -> ${QEMUSH_NAME}" \ + socat TCP-LISTEN:"${port},reuseaddr,fork" UNIX-CLIENT:"$(pathof spice)" +} + # Retrieve user requested function function="$1" shift