diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2020-09-09 15:04:52 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2020-09-09 15:04:52 +0200 |
commit | 25ef69650687f0fca9951bdcb16b2b3679a0601d (patch) | |
tree | eee80b51a0a0e1c573f16cbb9c8a971000603f31 /etc/private/vm-start-base | |
parent | 1a4a071568116f1131507f692f5618d5e5748b71 (diff) |
Updates to private install infrastructure and instructions
Diffstat (limited to 'etc/private/vm-start-base')
-rwxr-xr-x | etc/private/vm-start-base | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/etc/private/vm-start-base b/etc/private/vm-start-base index a88ea2d..4a81661 100755 --- a/etc/private/vm-start-base +++ b/etc/private/vm-start-base @@ -15,6 +15,9 @@ # --mac <addr> # MAC address to use for the machine. # +# --pid <path> +# PID file path, /tmp/vm-<tap>.pid if unspecified. +# # --monitor <path> # Monitor UNIX socket path, /tmp/vm-<tap>-mon.sock if unspecified. # @@ -22,15 +25,16 @@ # Console UNIX socket path, /tmp/vm-<tap>-con.sock if unspecified. # # --stdio -# Connect both console and monitor to stdio (multiplexed). +# Connect both console and monitor to stdio (multiplexed). This disables +# the creation of the monitor and console sockets. # # --stdio-monior -# Connect only monitor to stdio. +# Connect only monitor to stdio. This disables the creation of the monitor +# socket. # usage="usage: $0 [<options>] <vm-img> [<extra-qemu-options>]" -owd="$(pwd)" -trap "{ cd '$owd'; exit 1; }" ERR +trap "{ exit 1; }" ERR set -o errtrace # Trap in functions. function info () { echo "$*" 1>&2; } @@ -46,6 +50,7 @@ cpu=1 ram=2G tap= mac="de:ad:be:ef:b8:da" +pid= mon= con= stdio= @@ -73,6 +78,11 @@ while [ "$#" -gt 0 ]; do mac="$1" shift ;; + --pid) + shift + pid="$1" + shift + ;; --monitor) shift mon="$1" @@ -133,6 +143,11 @@ if [ -z "$tap" ]; then del_tap=true fi +if [ -z "$pid" ]; then + pid="/tmp/vm-$tap.pid" +fi +echo "$$" >"$pid" + if [ -z "$mon" ]; then mon="/tmp/vm-$tap-mon.sock" fi @@ -182,6 +197,10 @@ fi "${qemu[@]}" "${ops[@]}" -boot c "$@" +if [ "$pid" -o "$mon" -o "$con" ]; then + rm -f "$pid" "$mon" "$con" +fi + if [ "$del_tap" ]; then sudo ip tuntap delete "$tap" mode tap fi |