This repository was archived by the owner on Jun 13, 2026. It is now read-only.
Add graceful stop control command — fixes the power-cut-only shutdown - #24
Merged
Conversation
Fixes #22. Every VM stop was a host-side power cut: QEMU SIGTERM never reaches the guest and busybox init has no ACPI handling, so init's careful teardown path (stop katana, sync, umount, luksClose, poweroff) was unreachable from outside. Database writes still in the guest page cache (ext2 writeback lags ~30s) were lost on stop — discovered when the SNP E2E reboot test found a torn database seconds after genesis initialization. - init: new `stop` control verb — acknowledge with "ok stopping" (before teardown closes the channel), then run teardown_and_halt. QEMU exits on the guest poweroff. - start-vm.sh: cleanup now requests a graceful stop first and waits up to 30s for the guest to power off, falling back to the existing SIGTERM/KILL path for wedged guests or pre-stop initrds. - test-initrd.sh: the smoke test now exercises `stop` on every PR — ack, teardown evidence in the serial log, QEMU exit. - test-snp-e2e.sh: graceful stop replaces the 45s writeback sleep, with no wait at all on the graceful path — boot 2 is now a regression test for shutdown durability. Releases whose initrd predates `stop` reply "err unknown-command" and get the legacy 45s wait, keeping the E2E workflow valid for old tags. - README: document the command and the durability semantics. The init script is part of the measured initrd, so this changes the launch measurement at the next release. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #22.
What
Adds a
stopverb to the virtio-serial control channel. The guest acknowledges (ok stopping) and then runs the existingteardown_and_halt: Katana gets a TERM (KILL after 30s),sync, unmount of the sealed data disk,luksClose,poweroff— and QEMU exits on the guest poweroff. Recent writes become durable across restarts instead of depending on ext2 writeback timing.Layers
scripts/build-initrd.sh(guest init)stophandler — ack first (teardown closes the channel), thenteardown_and_haltstart-vm.shscripts/test-initrd.shstopon every PR: ack,Teardown: poweroffin the serial log, QEMU exit within 60sscripts/test-snp-e2e.shstopreplyerr unknown-commandand get the legacy 45s wait, keeping the E2E workflow valid for existing tagsREADME.mdNotes
launch-measurement-<tag>.txtas usual.build-and-bootcheck exercises the new command end to end in plain QEMU.🤖 Generated with Claude Code