From 7acb3ed20b541b6ff0d66e702866a9dfc9405421 Mon Sep 17 00:00:00 2001 From: Bilal Godil Date: Thu, 16 Apr 2026 15:30:46 -0700 Subject: [PATCH] fix capture path: guard against set -u + preserve cmd_capture's empty-host ISO Two bugs surfaced by end-to-end testing against a freshly-built qcow2: 1. $STACK_EMULATOR_CLI_WROTE_ISO was referenced unguarded under `set -u`, so any code path that didn't set it (capture, direct-shell) tripped `unbound variable` before reaching the early-return. Use :- default. 2. ensure_runtime_config_iso was overwriting cmd_capture's specialized empty-VM_DIR_HOST ISO with the host-dir variant. Since virtfs is detached in capture mode, run-stack-container then tried to publish internal-pck to /host/... and restart-looped stack.service, so no service ever became healthy and capture aborted after 240s. Previously masked by snapshot_fallback_to_cold_boot; 510ef3801 fixed the fallback mask and exposed this. Skip regen when EMULATOR_CAPTURING_SNAPSHOT=1. --- docker/local-emulator/qemu/run-emulator.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docker/local-emulator/qemu/run-emulator.sh b/docker/local-emulator/qemu/run-emulator.sh index 088d08a9f..7b52436e1 100755 --- a/docker/local-emulator/qemu/run-emulator.sh +++ b/docker/local-emulator/qemu/run-emulator.sh @@ -174,7 +174,15 @@ ensure_runtime_config_iso() { # otherwise we'd fall through to make_iso_from_dir and require # hdiutil/mkisofs/genisoimage, which is exactly the host dep the CLI path # is designed to remove. - if [ "$STACK_EMULATOR_CLI_WROTE_ISO" = "1" ] && [ -s "$(runtime_iso_path)" ]; then + if [ "${STACK_EMULATOR_CLI_WROTE_ISO:-}" = "1" ] && [ -s "$(runtime_iso_path)" ]; then + return 0 + fi + # In capture mode, cmd_capture already wrote a specialized ISO with an + # empty STACK_EMULATOR_VM_DIR_HOST — required because virtfs is detached + # for snapshot compatibility, and run-stack-container would otherwise + # try to publish internal-pck to /host/... and restart-loop + # stack.service. Trust that write and don't overwrite it. + if [ "${EMULATOR_CAPTURING_SNAPSHOT:-}" = "1" ] && [ -s "$(runtime_iso_path)" ]; then return 0 fi # Direct-shell invocation path: regenerate unconditionally. Port env vars