Skip to content

qubesos: add force parameter to shutdown and restarted states#36

Open
jmynes wants to merge 1 commit into
QubesOS:mainfrom
jmynes:feat/shutdown-force
Open

qubesos: add force parameter to shutdown and restarted states#36
jmynes wants to merge 1 commit into
QubesOS:mainfrom
jmynes:feat/shutdown-force

Conversation

@jmynes

@jmynes jmynes commented Apr 22, 2026

Copy link
Copy Markdown

Adds a force parameter to the qubesos module's state: shutdown / state: restarted, passed through to qubesadmin.vm.QubesVM.shutdown(force=True). Equivalent to qvm-shutdown --force: the target halts even when other VMs are connected to it.

Default is false, so existing playbooks are unaffected. state: destroyed still does vm.kill() (hard kill), unchanged.

Test added using the existing vm + netvm fixtures.

Refs QubesOS/qubes-issues#10856

@codecov-commenter

codecov-commenter commented Apr 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.34%. Comparing base (6072fde) to head (05d292a).
⚠️ Report is 71 commits behind head on main.

Files with missing lines Patch % Lines
plugins/modules/qubesos.py 66.66% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #36   +/-   ##
=======================================
  Coverage   73.34%   73.34%           
=======================================
  Files           1        1           
  Lines         529      529           
=======================================
  Hits          388      388           
  Misses        141      141           
Flag Coverage Δ
unittests 73.34% <66.66%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

Exposes qubesadmin.vm.QubesVM.shutdown(force=True) through a new
module parameter. When force: true is set alongside state: shutdown
(or state: restarted), the target VM halts gracefully regardless
of whether other VMs are connected to it (e.g. AppVMs using it as
a netvm). This matches the semantics of qvm-shutdown --force on
the CLI.

Distinct from state: destroyed, which calls vm.kill() (a SIGKILL
of the Xen domain with no graceful shutdown). The force parameter
only skips the "connected domains" precondition; the target itself
still halts gracefully, as it does with state: shutdown today.

The default is force=false, preserving current behavior. Adds a
pytest case in tests/qubes/test_module.py that exercises the new
parameter against a running dependent VM.

Refs: QubesOS/qubes-issues#10856
@andrewdavidwong

Copy link
Copy Markdown
Member

Suggestion: If you intend for this pull request to resolve the associated issue and would like for it to be linked to the issue automatically, you can put Closes QubesOS/qubes-issues#XXXX in the PR message (where XXXX is the issue number). Closes is one of several special keywords that GitHub will recognize. If and when the PR is merged, GitHub will automatically close the associated issue.

@jmynes

jmynes commented Apr 23, 2026

Copy link
Copy Markdown
Author

Closes QubesOS/qubes-issues#10856

(Accidentally mentioned 10586, deleted comment, then posted fixed comment)

@andrewdavidwong

andrewdavidwong commented Apr 24, 2026

Copy link
Copy Markdown
Member

Closes QubesOS/qubes-issues#10856

(Accidentally mentioned 10586, deleted comment, then posted fixed comment)

You have to edit your first post (at the very top) and add this there in order for this to work.

@Guiiix

Guiiix commented Apr 26, 2026

Copy link
Copy Markdown
Member

Hi @jmynes! Thanks for your contribution.

The module has been refactored to a new module qubesos.core.qube and the legacy qubesos module is now deprecated. Could you please rebase your work on the updated main branch?

marmarek added a commit that referenced this pull request May 15, 2026
* origin/pr/40:
  qubesos: add force parameter to shutdown and restarted states

Pull request description:

This PR is based on the original work from @jmynes in PR #36 rebased on top of the current main branch.

The `force` parameter is added to both legacy `qubesos` and `qubesos.core.qube` modules.

Thanks to @jmynes for the original contribution.
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.

4 participants