Skip to content

知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.

build(windows): vmctl.sh stop shuts the test VM down and frees its memory

wquguru0eab6c4ba205
diff --git a/windows/vm/vmctl.sh b/windows/vm/vmctl.sh
index d9f9828..1eebaab 100755
--- a/windows/vm/vmctl.sh
+++ b/windows/vm/vmctl.sh
@@ -6,6 +6,7 @@
# vmctl.sh put <local> <remote> # copy into the VM
# vmctl.sh run <local.ps1> # run a script in the VM's desktop session and print its output
# vmctl.sh g <verb> <args…> # guest.ps1 in the VM (desk, launch, shot, click, key, front, windows, play)
+# vmctl.sh stop # shut Windows down and wait for QEMU to exit (frees its 8 GB)
set -euo pipefail
VM="${VM:-$HOME/VMs/cicada-win11}"
common=(-i "$VM/vm_key" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR -o ConnectTimeout=5)
@@ -21,5 +22,10 @@ case "$1" in
run) # a local .ps1 in the VM's desktop session: no quoting through ssh and schtasks
"$0" put "$2" C:/cicada-test/run.ps1 && "$0" g desk "'& C:\\cicada-test\\run.ps1'" ;;
put) scp -r "${common[@]}" -P 2222 "$2" "[email protected]:$3" ;;
- *) echo "usage: vmctl.sh shot|mon|ssh|put" >&2; exit 2 ;;
+ stop)
+ pid=$(cat "$VM/qemu.pid" 2>/dev/null) && kill -0 "$pid" 2>/dev/null || { echo "not running"; exit 0; }
+ mon system_powerdown || true
+ for _ in $(seq 60); do kill -0 "$pid" 2>/dev/null || { echo "stopped"; exit 0; }; sleep 2; done
+ mon quit || true; echo "forced off after 2 min" ;;
+ *) echo "usage: vmctl.sh shot|mon|ssh|put|run|g|stop" >&2; exit 2 ;;
esac