Repository navigation
[13.4-stable] remove stale dir of deleted domain - #6562
Merged
eriknordmark merged 1 commit intoSep 18, 2026
Merged
Conversation
KvmContext.Delete returned as soon as the QMP quit command failed and never reached the os.RemoveAll of /run/hypervisor/kvm/<domain>. The quit fails precisely when qemu is already gone: a qemu that crashed (e.g. on a fatal signal) does not unlink its sockets, so the executor socket passes the os.Stat, the connect fails after the retry loop, and the state directory with its stale pid and listener.qmp files survives for the lifetime of the device. That surviving listener.qmp is what keeps the old domain's qmpEventHandler alive on 13.4.x: its liveness check is an os.Stat of that very file, so after the crash it spins on the closed event channel logging 'Unhandled event:' with an empty name a few hundred times a second per dead domain. A device seen with two crashed generations had two such goroutines running for a week. Master no longer has this path since dbb5dc5 replaced the quit with terminateQemu, which removes the directory unconditionally. Mirror that here: log the quit failure, always remove the directory, and return the quit error afterwards so callers still see it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Paul Gaiduk <paulg@zededa.com>
europaul
requested review from
rene,
rouming,
rucoder and
shjala
as code owners
September 16, 2026 16:13
This was referenced Sep 16, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 13.4-stable #6562 +/- ##
===============================================
+ Coverage 24.78% 32.66% +7.88%
===============================================
Files 8 9 +1
Lines 1138 1090 -48
===============================================
+ Hits 282 356 +74
+ Misses 788 654 -134
- Partials 68 80 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
@europaul Please, fix PR title |
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.
Description
KvmContext.Deletereturns as soon as the QMPquitcommand fails and never reaches theos.RemoveAllof/run/hypervisor/kvm/<domain>. The quit fails precisely when qemu is already gone: a qemu that crashed (e.g. on a fatal signal) does not unlink its sockets, so the executor socket passes theos.Stat, the connect fails after the retry loop, and the state directory with its stalepidandlistener.qmpfiles survives for the lifetime of the device.That surviving
listener.qmpis what keeps the old domain'sqmpEventHandleralive on this branch: its liveness check is anos.Statof that very file, so after a crash it spins on the closed event channel loggingUnhandled event:with an empty name a few hundred times a second per dead domain. A 13.4.3-lts device seen with two crashed generations had two such goroutines running for a week.Why not a cherry-pick from master
Master fixed this as a side effect of #6120 (
38fc3e75c, "promptly reap powered-off kvm domains"), which dropped the early return while adding a SIGKILL backstop; #6441 (dbb5dc5e5) then refactored that intoterminateQemu. Both are on 17.0-stable (#6120 as0a034d02c, #6441 as #6490).waitProcessGoneand the reshapedDelete()from pillar: promptly reap powered-off kvm domains #6120, so a cherry-pick conflicts on every branch below 17.0.This PR is the correctness slice only: log the quit failure, always remove the directory, return the quit error (joined with a removal error, if any). If the outstanding #6441 backports to these branches are done later, they will meet a small conflict in
Delete()— take #6441's version.This is a stable-only fix — there is nothing to backport from master. Sibling PRs: #6563 #6564
How to test and validate this PR
<uuid>.<ver>.1under/run/hypervisor/kvm/.kill -SEGV $(cat /run/hypervisor/kvm/<domain>/pid).verifyStatusto mark the app BROKEN (≤ 1 min).ls /run/hypervisor/kvm/— the dead domain's directory is gone. Before this fix it stays, andlogreadfills withqmpEventHandler: Unhandled event: from QMP socket: .../<domain>/listener.qmp.Changelog notes
After a VM's QEMU process crashes, its runtime state directory is now cleaned up; previously it leaked and caused a continuous stream of
Unhandled eventwarnings in the device log.Checklist
I've provided a proper description
I've added the proper documentation — not applicable
I've tested my PR on amd64 device — reproduction analysed from a customer collect-info; not yet re-run on a lab device
I've tested my PR on arm64 device
I've written the test verification instructions
I've set the proper labels to this PR
I've checked the boxes above, or I've provided a good reason why I didn't
check them.
🤖 Generated with Claude Code