clavarium 0.2.94-next.1 → 0.2.95-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deploy/clavarium-host +36 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/deploy/clavarium-host
CHANGED
|
@@ -211,6 +211,18 @@ run() { if [ "$SAY" = "yes" ]; then printf '%s\n' "$*"; else exec "$@"; fi; }
|
|
|
211
211
|
# with a letter; no trailing hyphen; 32 at most. The same rule as the server.
|
|
212
212
|
is_name() { [[ "$1" =~ ^[a-z]([a-z0-9-]{0,30}[a-z0-9])?$ ]]; }
|
|
213
213
|
vm_of() { is_name "${1#clv-}" && [ "$1" != "${1#clv-}" ] || refuse "not one of our VMs: ${1:-<empty>}"; }
|
|
214
|
+
# The qemu process(es) of one of our machines -- a qemu-system whose disk is in
|
|
215
|
+
# that instance, the mapping "server room" also uses. Empty when none is left,
|
|
216
|
+
# which is what a suspend that freed the RAM leaves behind.
|
|
217
|
+
vm_qemu_pids() {
|
|
218
|
+
local want="$1" pid vm
|
|
219
|
+
for pid in $(pgrep qemu-system 2>/dev/null || true); do
|
|
220
|
+
vm="$(tr '\0' '\n' < "/proc/$pid/cmdline" 2>/dev/null | grep -oE '/instances/clv(shelf)?-[a-z0-9-]+/' | head -1 | cut -d/ -f3)" || vm=""
|
|
221
|
+
[ "$vm" = "$want" ] && printf '%s\n' "$pid"
|
|
222
|
+
done
|
|
223
|
+
}
|
|
224
|
+
# No qemu left for this machine after a short grace: its RAM has been freed.
|
|
225
|
+
vm_freed() { local v="$1" i; for i in $(seq 1 24); do [ -z "$(vm_qemu_pids "$v")" ] && return 0; sleep 0.5; done; return 1; }
|
|
214
226
|
number() { [[ "$1" =~ ^[0-9]{1,6}$ ]] || refuse "not a number: ${1:-<empty>}"; }
|
|
215
227
|
# A disk or partition named by its device: /dev/sdX, /dev/vdX, /dev/nvmeNnN(pN),
|
|
216
228
|
# /dev/xvdX, /dev/mmcblkN(pN), with a digit or two at the end; a loop device only
|
|
@@ -770,9 +782,32 @@ case "$AREA $VERB" in
|
|
|
770
782
|
"vm info")
|
|
771
783
|
[ $# -eq 1 ] || usage; vm_of "$1"
|
|
772
784
|
run "$MULTIPASS" info "$1" --format json ;;
|
|
773
|
-
"vm start"|"vm stop"
|
|
785
|
+
"vm start"|"vm stop")
|
|
774
786
|
[ $# -eq 1 ] || usage; vm_of "$1"
|
|
775
787
|
run "$MULTIPASS" "$VERB" "$1" ;;
|
|
788
|
+
"vm suspend")
|
|
789
|
+
# Veille: suspend must save the machine's state AND free its RAM by ending
|
|
790
|
+
# its qemu process. Multipass saves the state reliably but at times leaves
|
|
791
|
+
# qemu alive (canonical/multipass #446, #2152, #5432), so the RAM stays
|
|
792
|
+
# taken though the machine shows "Suspended". The state being saved, we make
|
|
793
|
+
# the RAM come back, gentlest first: a second suspend from a clean running
|
|
794
|
+
# state usually ends qemu (and keeps the ~2s resume); failing that, a clean
|
|
795
|
+
# stop frees it for sure (it then wakes by a boot). Normally qemu is already
|
|
796
|
+
# gone after the first suspend and none of this runs.
|
|
797
|
+
[ $# -eq 1 ] || usage; vm_of "$1"
|
|
798
|
+
if [ "$SAY" = "yes" ]; then
|
|
799
|
+
printf '%s\n' "$MULTIPASS suspend $1" \
|
|
800
|
+
"if its qemu still holds the RAM: $MULTIPASS start $1 && $MULTIPASS suspend $1 (wake+resleep)" \
|
|
801
|
+
"if it still does: $MULTIPASS stop $1 (free it; it wakes by a boot)"
|
|
802
|
+
exit 0
|
|
803
|
+
fi
|
|
804
|
+
"$MULTIPASS" suspend "$1" || refuse "suspend of $1 failed"
|
|
805
|
+
vm_freed "$1" && exit 0
|
|
806
|
+
"$MULTIPASS" start "$1" >/dev/null 2>&1 && "$MULTIPASS" suspend "$1" >/dev/null 2>&1
|
|
807
|
+
vm_freed "$1" && exit 0
|
|
808
|
+
"$MULTIPASS" stop "$1" >/dev/null 2>&1 || true
|
|
809
|
+
vm_freed "$1" && exit 0
|
|
810
|
+
refuse "suspended $1 but its memory was not freed (its qemu stayed); the VM manager likely needs a restart" ;;
|
|
776
811
|
"vm kill")
|
|
777
812
|
# A stop that does not wait for the system inside: asked only after a
|
|
778
813
|
# clean stop hung or failed (a restart the owner asked for).
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.95-next.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.95-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|