Skip to content

[17.0-stable] kvm: honour the force flag when stopping a domain - #6490

Merged
eriknordmark merged 1 commit into
lf-edge:17.0-stablefrom
eriknordmark:kvm-honour-force-shutdown-17.0-stable
Sep 10, 2026
Merged

eriknordmark merged 1 commit into
lf-edge:17.0-stablefrom
eriknordmark:kvm-honour-force-shutdown-17.0-stable

Conversation

@eriknordmark

Copy link
Copy Markdown
Contributor

Description

Backport of #6441 to 17.0-stable.

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, as the xen and containerd
implementations of the same method already do, and reports whether that worked so
a process that outlives the SIGKILL reaches the caller rather than only the log.

The pillar commit is cherry-picked with -x and applied cleanly. The source PR's
second commit, evetest: halt a guest which ignores ACPI, is not carried:
evetest/tests/apps does not exist on this branch, so the test has no suite to
join.

How to test and validate this PR

go test ./hypervisor/ in pkg/pillar — kvm_force_test.go covers the forced
path, including the pid-file and surviving-process failures. go build ./... and
go vet ./hypervisor/ are clean on this branch.

On a device, stop an application a few seconds after starting it, while the guest
is still early in boot and ignoring ACPI. The domain goes away promptly instead of
staying in halting until domainmgr's wait expires, and its memory and any assigned
PCI devices are released at that point.

Changelog notes

An application stopped while its guest is still booting now halts promptly
instead of staying in a halting state until the shutdown wait expires.

PR Backports

  • 17.0-stable: This PR.
  • 16.0-stable: To be backported.
  • 14.5-stable: To be backported.
  • 13.4-stable: To be backported.

Checklist

  • I've provided a proper description
  • I've added the proper documentation
  • I've tested my PR on amd64 device (via kvm: honour the force flag when stopping a domain #6441)
  • 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 added a reference link to the original PR
  • PR's title follows the template

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>
(cherry picked from commit dbb5dc5)
@eriknordmark eriknordmark added the bug Something isn't working label Sep 8, 2026
@eriknordmark
eriknordmark removed the request for review from OhmSpectator September 8, 2026 16:55
@codecov

codecov Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.55556% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 21.80%. Comparing base (e69cda3) to head (e6ca40e).
⚠️ Report is 3 commits behind head on 17.0-stable.

Files with missing lines Patch % Lines
pkg/pillar/hypervisor/kvm.go 55.55% 11 Missing and 1 partial ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           17.0-stable    #6490      +/-   ##
===============================================
+ Coverage        21.38%   21.80%   +0.41%     
===============================================
  Files              500      510      +10     
  Lines            92650    94360    +1710     
===============================================
+ Hits             19813    20572     +759     
- Misses           71191    71958     +767     
- Partials          1646     1830     +184     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eriknordmark
eriknordmark merged commit 5459050 into lf-edge:17.0-stable Sep 10, 2026
52 of 53 checks passed
@eriknordmark
eriknordmark deleted the kvm-honour-force-shutdown-17.0-stable branch September 19, 2026 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants