Repository navigation
kvm: honour the force flag when stopping a domain - #6441
Conversation
|
Claude finished @eriknordmark's task in 2m 20s —— View job Code reviewReviewed the change against Two low-severity observations posted inline:
No correctness, security, or watchdog regressions found (the QMP-hang case was already covered by |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6441 +/- ##
==========================================
+ Coverage 25.87% 26.22% +0.34%
==========================================
Files 510 520 +10
Lines 93575 95303 +1728
==========================================
+ Hits 24212 24990 +778
- Misses 67494 68257 +763
- Partials 1869 2056 +187 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
52cbfd5 to
a68435b
Compare
Picks up the four new commits on lf-edge#6063 through the fork#6 chain and adds lf-edge#6441. Notes that lf-edge#6440 is an issue rather than a PR, and that lf-edge#6441 states it is not the cure for it. Signed-off-by: eriknordmark <erik@zededa.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Picks up the four new commits on lf-edge#6063 through the fork#7 chain and adds lf-edge#6441. Restates that this line only exercises the fault gates when the build passes FAULT_INJECTION, and where the rootfs cap and the storage-resizer pin come from. Signed-off-by: eriknordmark <erik@zededa.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Picks up the four new commits on lf-edge#6063 through the fork#6 chain and adds lf-edge#6441. Notes that lf-edge#6440 is an issue rather than a PR, and that lf-edge#6441 states it is not the cure for it. Signed-off-by: eriknordmark <erik@zededa.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Picks up the four new commits on lf-edge#6063 through the fork#7 chain and adds lf-edge#6441. Restates that this line only exercises the fault gates when the build passes FAULT_INJECTION, and where the rootfs cap and the storage-resizer pin come from. Signed-off-by: eriknordmark <erik@zededa.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
@eriknordmark , @claude , why you are doing all of this? We can just send a |
|
Claude finished @rene's task in 50s —— View job Why not just send
|
a68435b to
2ad60b3
Compare
2ad60b3 to
6a90531
Compare
A forced stop was the same ACPI poweroff request as a graceful one, which a guest that cannot service it yet - one still early in boot, for instance - simply ignores. Nothing then made the domain go away until domainmgr gave up waiting and deleted it, so an application stopped shortly after it started stayed reported as halting for as long as those waits took, and its memory and any assigned devices stayed held. A forced stop now terminates the process, which is what the interface promises and what the xen and containerd implementations of the same method already do. The termination path Delete already used, a monitor quit followed by a kill if that does not take, is shared rather than duplicated. Termination reports whether it worked, so a stop that could not make the process go away - an unusable pid file leaving nothing to signal, or a process that outlives the SIGKILL - reaches the caller rather than only the log, and domainmgr's Shutdown(force) succeeded line means what it says. Delete carries the same outcome, so a domain whose process is still there is not reported as deleted just because its state directory was removed. Signed-off-by: eriknordmark <erik@zededa.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Nothing obliges a guest to service the ACPI poweroff request, and when it does not, only terminating the domain ends the stop. The guest here ignores it by construction: acpid is what services the power button on Alpine, and cloud-init stops it and removes it from the runlevel. The mode is HVM, which already gets the short first wait, so what is left under test is what the escalation after it does. The assertion is on how long the application takes to be reported HALTED, because the reported state sequence is the same either way -- only the time spent halting differs. The bound separates two hardcoded budgets an order of magnitude apart rather than an amount of work, so a loaded host moves both ends a little and crosses neither. Signed-off-by: eriknordmark <erik@zededa.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
6a90531 to
0f363f2
Compare
|
@rene The
It also brings kvm in line with the other backends on the same flag — xen appends |
Description
Fixes #6452.
A forced stop of a KVM domain was the same ACPI poweroff request as a graceful
one:
KvmContext.Stopdiscarded itsforceargument and issued QMPsystem_powerdowneither way. A guest which cannot service that yet - one stillearly in boot, for instance - ignores both, so nothing made the domain go away
until domainmgr gave up waiting and deleted it. An application stopped shortly
after it started therefore stayed reported as halting for as long as those waits
took, holding its memory and any assigned PCI devices meanwhile, and the
Shutdown(force) succeededline domainmgr logs was not true.A forced stop now terminates the process. That is what the interface promises
and what the xen (
xl shutdown -F) and containerd implementations of the samemethod already do. The termination path
Deletealready had - pause the vCPUs,quit over the monitor, and a kill if that does not take - is factored out and
shared rather than duplicated, and now reports whether it worked, so
Shutdown(force) succeededmeans what it says.Measured on EVE-kvm amd64, an
HVMAlpine guest with acpid stopped so itignores the request, deactivated once running:
The 605s difference is domainmgr's second wait, and 701s matches the ~11m45s
#5916 recorded for four eclient pods in one CI run. The third row is the
control: bounding the graceful wait cannot help, because
HVMalready gets60s there.
Related to #6440 but deliberately not a fix for it -- see "What this does not
fix" below.
PR dependencies
None.
How to test and validate this PR
Covered by an evetest test and by unit tests, all validated against un-fixed
code.
TestHaltUnresponsiveGuest, inevetest/tests/appsand registered inTestAppsSuite, deploys anHVMAlpine VM whose cloud-init stops acpid andremoves it from the runlevel, so the guest ignores the poweroff request by
construction. Against an EVE image without this change -- one carrying the
bounded graceful wait of #6453, so that only this PR is under test -- it fails
on its 300s bound; with it the application reports HALTED 1m36s after the
deactivation. It pulls its image from
dl-cdn.alpinelinux.org, whichtests/appsdid not previously depend on (tests/security/vcom_test.goalready does).
The assertion is on elapsed time because the reported state sequence is
identical either way -- RUNNING, HALTING, HALTED -- and only the time spent
halting differs. The bound separates two hardcoded budgets an order of magnitude
apart rather than an amount of work, so it is not a stopwatch on a loaded host.
The unit tests in
kvm_force_test.gocover a domain whose monitor cannot bereached, which is the path a guest that never services the poweroff request
takes; one with no pid file, so the absence of the only handle on the process
cannot wedge the caller; and one whose pid file is there but unreadable, where
nothing can be signalled and the caller has to be told rather than hearing that
the stop succeeded.
Changelog notes
None. A forced stop now does what its name says, which no current caller
reaches before its effect is already moot; nothing user-facing changes yet.
PR Backports
The defect has been present since the KVM driver was first written
(
ef4d38f1c, 2020), so every stable branch carries it.Checklist
this changes; the method's contract is stated on the interface.
path; the end-to-end reproduction in kvm: forced domain stop is the same ACPI request as a graceful one #6440 was run before the fix, not after.
architecture independent.
What this does not fix
Stating it plainly, because the two look alike: this change does not shorten
the stall in #6440. There the application's mode is
PV-- evetest leavesVirtualizationModeunset andVmMode_PVis the zero value -- so thedoInactivateswitch leavesfirstDelayatmaxDelayand the whole budget isspent in the first, graceful
waitForDomainGone, before the forced stopthis PR fixes is reached. Deactivating a container application in the same
second it reported RUNNING:
This PR adds nothing to the second row: once the graceful wait is bounded the
guest is ACPI-capable by the time the request is re-sent. #6453 is the cure for
#6440, and it is equally not a cure for #6452 -- the control row in the
Description shows it leaving that stall at 703s. The two are complementary and
neither subsumes the other: bounding the graceful wait fixes the guest which
becomes capable, and this PR fixes the guest which never does.
Note on scope
kubevirtContext.Stopignores the same argument, and there it is namedforcerather than_so nothing flags it. That is deliberately left alonehere: it is a different mechanism and #6271 is the live conversation about that
code.
Whether
PVshould keep a 600s graceful budget before escalating -HVMandFMLget 60s,PVfalls through tomaxDelay- is a separate decision this PRdoes not take, and it affects Xen PV guests too. Without it the graceful wait is
unchanged; this PR only makes the escalation after it real.