Skip to content

[16.0-stable] kvm: honour the force flag when stopping a domain - #6843

Merged
eriknordmark merged 1 commit into
lf-edge:16.0-stablefrom
milan-zededa:16.0-backport-6441-kvm-force-stop
Oct 19, 2026
Merged

eriknordmark merged 1 commit into
lf-edge:16.0-stablefrom
milan-zededa:16.0-backport-6441-kvm-force-stop

Conversation

@milan-zededa

Copy link
Copy Markdown
Contributor

Description

Backport of #6441 to 16.0-stable.

Cherry-picked with -x from dbb5dc5e52. Only the pillar commit of the PR is
backported; its evetest commit is part of the evetest backport (#6842).

The cherry-pick needed conflict resolution in pkg/pillar/hypervisor/kvm.go,
because Stop and Delete look different in 16.0:

  • the new terminateQemu logic (and the unit test kvm_force_test.go) is
    taken as is, and Delete keeps the error joining that 16.0 already has;
  • decideKvmState, which comes from an unrelated change that is not in
    16.0, is not brought over;
  • the procutils call is replaced with the utils package that 16.0 has,
    and the errors and syscall imports are added.

Without this fix TestHaltUnresponsiveGuest fails: a guest that ignores the
ACPI power-off request is not force-stopped.

PR dependencies

None.

How to test and validate this PR

Covered by the evetest test TestHaltUnresponsiveGuest (added to 16.0-stable by #6842):

EVETEST_EVE_VERSION=<16.0-stable build with this PR> make evetest NAME=TestHaltUnresponsiveGuest

Changelog notes

Fixed forced stop and deletion of an application whose guest ignores the ACPI power-off request: the QEMU process is now killed if it does not exit.

Checklist

  • I've provided a proper description
  • I've added the proper documentation
  • I've tested my PR on amd64 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

For backport PRs (remove it if it's not a backport):

  • I've added a reference link to the original PR
  • PR's title follows the template

And the last but not least:

  • I've checked the boxes above, or I've provided a good reason why I didn't
    check them.

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)
Signed-off-by: Milan Lenco <milan@zededa.com>
@codecov

codecov Bot commented Oct 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 26.89%. Comparing base (7fcc23e) to head (43e097c).
⚠️ Report is 1 commits behind head on 16.0-stable.

Additional details and impacted files
@@               Coverage Diff               @@
##           16.0-stable    #6843      +/-   ##
===============================================
- Coverage        29.12%   26.89%   -2.24%     
===============================================
  Files               10       25      +15     
  Lines             1133     4332    +3199     
===============================================
+ Hits               330     1165     +835     
- Misses             768     2938    +2170     
- Partials            35      229     +194     

☔ 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 f7f4757 into lf-edge:16.0-stable Oct 19, 2026
69 of 73 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants