Skip to content

qvm-device: add --force flag for dom0 device attachment#466

Open
nihalxkumar wants to merge 1 commit into
QubesOS:mainfrom
nihalxkumar:main
Open

qvm-device: add --force flag for dom0 device attachment#466
nihalxkumar wants to merge 1 commit into
QubesOS:mainfrom
nihalxkumar:main

Conversation

@nihalxkumar
Copy link
Copy Markdown

@nihalxkumar nihalxkumar commented Apr 8, 2026

Attaching a device directly to dom0 carries security risks, so the tool now requires explicit user confirmation when the target is an AdminVM(dom0).

A new --force / -f flag bypasses the interactive prompt for scripted or automated use.

The confirmation reads from stdin and treats EOF (closed/piped stdin) as a cancellation, preventing silent attachments in non-interactive contexts.

fixes: QubesOS/qubes-issues#10825

related: QubesOS/qubes-core-admin#798

@parulin
Copy link
Copy Markdown

parulin commented Apr 8, 2026

It should also be documented.

@nihalxkumar
Copy link
Copy Markdown
Author

It should also be documented.

Thanks @parulin. The introduction of this change is still in discussion. Would of course document it.

@marmarek
Copy link
Copy Markdown
Member

The build fails because of missing man page entry:

11:59:54 [qb.build_rpm.core-admin-client.host-fc41.build] DEBUG: Undocumented arguments for command 'qvm-device attach': '--force, -f'

@rustybird
Copy link
Copy Markdown
Contributor

When invoked without --force, IMO it should behave like qvm-remove or qvm-volume clear do when invoked without --force. They interactively prompt to confirm:

https://github.com/QubesOS/qubes-core-admin-client/blob/v4.3.30/qubesadmin/tools/qvm_volume.py#L175-L180

@ben-grande
Copy link
Copy Markdown
Contributor

About the use of --force or a flag with another name, wait for a response to Rusty's comment on QubesOS/qubes-issues#10825 (comment).

@ben-grande
Copy link
Copy Markdown
Contributor

Also, next time, don't use your main branch, create a separate branch for making commits. Now, if you force push to base on a different branch, I think Github will force close this PR, so keep as is.

@ben-grande
Copy link
Copy Markdown
Contributor

Please add "Fixes: QubesOS/qubes-issues#10825" to the commit message.

@nihalxkumar
Copy link
Copy Markdown
Author

@ben-grande commit message or PR description or both?

@ben-grande
Copy link
Copy Markdown
Contributor

Both is better.

@nihalxkumar
Copy link
Copy Markdown
Author

nihalxkumar commented May 15, 2026

@parulin @marmarek @rustybird
MAN page + interactive confirmation
I prefer --force as with the consensus on the issue

@ben-grande
Copy link
Copy Markdown
Contributor

Please squash the commits.

@ben-grande
Copy link
Copy Markdown
Contributor

There is a merge commit. To squash, I normally do git rebase -i upstream/main and do "fixup".

@nihalxkumar
Copy link
Copy Markdown
Author

all good now

Comment thread qubesadmin/tools/qvm_device.py Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.86%. Comparing base (f79b7ee) to head (7df44bf).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #466      +/-   ##
==========================================
+ Coverage   76.82%   76.86%   +0.03%     
==========================================
  Files          53       53              
  Lines        9361     9374      +13     
==========================================
+ Hits         7192     7205      +13     
  Misses       2169     2169              

☔ View full report in Codecov by Sentry.
📢 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.

elif vm.klass == 'AdminVM':
print('Attaching a device to dom0 can be a security risk ',
file=sys.stderr)
try:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I think you can make this try block less repetitive.
  • Please add appropriate test
  • In the case of EOFError, it should not exit 0.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, pls check

…ive confirmation

Add --force/-f flag to skip the interactive confirmation prompt when
attaching a device to dom0. Without this flag, attaching to dom0 will
interactively ask for confirmation, matching the pattern used by
qvm-volume clear and qvm-remove.

Includes manpage documentation and test coverage.

Fixes: QubesOS/qubes-issues#10825
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.

Make it more difficult to attach domU devices to dom0

5 participants