[17.0] pillar: promptly reap powered-off kvm domains - #6155
Merged
Conversation
Stopping or purging a KVM app (container or VM) took ~100s on every stop, and occasionally the full ~11-minute force budget, even though the guest finished its ACPI poweroff in about a second. qemu runs with -no-shutdown, so on guest poweroff the process does not exit: it pauses in QMP run-state "shutdown" while still holding its memory and any assigned PCI devices. KvmContext.Info() discarded that QMP state and reported the (still-RUNNING) containerd task, so domainmgr could not tell the guest was down and polled out the graceful-shutdown timers before forcing the domain off. Info() now surfaces the QMP "shutdown" run-state as HALTING (via a small decideKvmState helper with a unit-test truth table). waitForDomainGone and verifyStatus act on HALTING to reap the paused domain immediately instead of waiting out the budget, and Delete now SIGKILLs the qemu pid if the QMP quit does not make it exit, so teardown - and the release of memory and PCI passthrough - is bounded even when the monitor is wedged. The published state machine is unchanged: HALTED is still reported only once the process is gone and resources are freed; while a guest is genuinely still shutting down its QMP run-state stays "running", so the long graceful budget (e.g. a Windows VM) is preserved. The change is scoped to the qemu/-no-shutdown backend; NOHYPER, xen and kubevirt do not have the pause and are untouched. Fixes lf-edge#5916 Signed-off-by: eriknordmark <erik@zededa.com> Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> (cherry picked from commit 38fc3e7)
eriknordmark
requested review from
milan-zededa,
rene,
rucoder and
shjala
as code owners
July 10, 2026 03:13
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 17.0 #6155 +/- ##
==========================================
+ Coverage 20.47% 20.88% +0.41%
==========================================
Files 490 500 +10
Lines 91763 93495 +1732
==========================================
+ Hits 18785 19526 +741
- Misses 71413 72222 +809
- Partials 1565 1747 +182 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rene
approved these changes
Jul 10, 2026
Contributor
|
@eriknordmark , please, let's close this PR in favor of #6156 , which already contains this one. |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Backport of #6120.
Reaps the qemu
-no-shutdownpaused domain promptly instead of waiting out thegraceful-shutdown budget, so stopping or purging a KVM app completes within a
second or two of guest poweroff instead of ~100s (occasionally the full
~11-minute force budget). Included in 17.0 per the
next-17.0.0-rclabel on theoriginal PR.
Cherry-picked from master (
git cherry-pick -x 38fc3e7). The only conflict wasin
kvm_test.go: the cherry-pick's diff context referenced a master-only testfunction absent from 17.0, so the region was resolved to add only the
TestDecideKvmStatetruth table this change introduces. The applied code diffis identical to the original.
How to test and validate this PR
Deploy a container or VM app under
HV=kvm, then stop or purge it. Before thischange, teardown waits ~100s (or up to the full force budget) after the guest has
already powered off; after it, the domain is reaped within a second or two of
guest poweroff and its memory / PCI passthrough are released promptly. A guest
that is genuinely still shutting down (QMP run-state "running") keeps its full
graceful budget.
pkg/pillar/hypervisor/kvm_test.gocoversdecideKvmState(the QMP run-state to SwState mapping) as a truth table.
Changelog notes
Stopping or purging an app on a KVM-based device now completes promptly once the
guest has powered off, instead of waiting up to several minutes for the
graceful-shutdown timeout.
PR Backports
Checklist