qemush : nouvelle commande spice
This commit is contained in:
parent
bbf59bab0b
commit
c23eedd9e4
1 changed files with 15 additions and 1 deletions
16
bin/qemush
16
bin/qemush
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# version=0.6.1
|
# version=0.7.0
|
||||||
|
|
||||||
# Re-exec the script as qemu via sudo (only if needed)
|
# Re-exec the script as qemu via sudo (only if needed)
|
||||||
[ "$(whoami)" != qemu ] && exec sudo -E -H -u qemu -- "$0" "$@"
|
[ "$(whoami)" != qemu ] && exec sudo -E -H -u qemu -- "$0" "$@"
|
||||||
|
@ -40,6 +40,7 @@ ${name}: usage:
|
||||||
${name} help - show this help
|
${name} help - show this help
|
||||||
${name} add <path to script> [<VM name>] - add a launching script
|
${name} add <path to script> [<VM name>] - add a launching script
|
||||||
${name} do <command> - run shell input as user qemu
|
${name} do <command> - run shell input as user qemu
|
||||||
|
${name} spice <running VM> [<TCP port>] - expose a SPICE socket to TCP
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +167,19 @@ public_do() {
|
||||||
exec sh -c "$*"
|
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
|
# Retrieve user requested function
|
||||||
function="$1"
|
function="$1"
|
||||||
shift
|
shift
|
||||||
|
|
Loading…
Reference in a new issue