Skip to content

Add handler for internal feature #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 27, 2025
Merged

Conversation

ben-grande
Copy link
Contributor

@ben-grande ben-grande commented Apr 17, 2025

For: QubesOS/qubes-issues#1512


I didn't run the tests but I manually tested on R4.3 bench.

One thing I encountered is that a newly created qube can appear on the list for some miliseconds before it's internal feature is added.

Copy link

codecov bot commented Apr 17, 2025

Codecov Report

Attention: Patch coverage is 87.61905% with 13 lines in your changes missing coverage. Please review.

Project coverage is 79.18%. Comparing base (9acc13c) to head (5d9c320).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
qubes_menu/vm_manager.py 80.59% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #55      +/-   ##
==========================================
- Coverage   81.44%   79.18%   -2.26%     
==========================================
  Files          22       23       +1     
  Lines        2387     2561     +174     
==========================================
+ Hits         1944     2028      +84     
- Misses        443      533      +90     

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

@ben-grande ben-grande force-pushed the preload-dispvm branch 5 times, most recently from 353aafa to 0dc860f Compare April 28, 2025 16:39
@marmarta
Copy link
Member

marmarta commented May 6, 2025

I'm a bit confused here: is the goal to hide every VM based on a template that's internal? Or do I misunderstand something? (also very possible)

@ben-grande
Copy link
Contributor Author

ben-grande commented May 6, 2025

is the goal to hide every VM based on a template that's internal?

That is correct. If the qube is internal, hide it, but if it is not internal but it's template is, it also should be hidden.

@marmarta
Copy link
Member

marmarta commented May 6, 2025

That is correct. If the qube is internal, hide it, but if it is not internal but it's template is, it also should be hidden.

Hm, I'm a bit worried that this could be confusing... Could we document this in user-facing documentation somewhere? Preferably somewhere where the internal feature is described...

@ben-grande
Copy link
Contributor Author

@marmarta
Copy link
Member

marmarta commented May 6, 2025

I mean in the qubes-doc somewhere, too

@ben-grande
Copy link
Contributor Author

I mean in the qubes-doc somewhere, too

I grepped for internal in the qubes-doc and the only mention in the same context is about default-mgmt-dvm:

https://github.com/QubesOS/qubes-doc/blob/690d2898862903c6151031d27ec135c77e2fb658/user/templates/templates.md?plain=1#L240

And it doesn't even mention that it is a feature, just an internal qube. I think it would be wrong to add it to qubes-doct as only people deploying configuration for others do need to know about this feature and not end users.

But if you are sure about this, please let me know in which page to add.

@marmarta
Copy link
Member

marmarta commented May 6, 2025

Hmm, I see. But I keep thinking on it, and I think I figured out the problem case: if a system has been configured for end-user (like in SecureDrop case), you might get 'internal' templates managed by the system itself (auto-updated etc.) and qubes based on those templates that should very much be visible to the end-user. I think only qubes that are internal themselves should be hidden.

@ben-grande
Copy link
Contributor Author

ben-grande commented May 6, 2025 via email

@marmarta
Copy link
Member

marmarta commented May 6, 2025

I'm confused. Currently yeah, I see that it is a problem, but I don't think a good solution is just not showing all qubes with template with internal (especially as I think this PR would also hide an AppVM whose template has 'internal' set to true - correct me if I'm wrong, if that's not true, then this reservation is partially withheld). I think this would have us think about how to show this case in the menu in a sensible way, not just hide it?

@ben-grande
Copy link
Contributor Author

I think this would have us think about how to show this case in the menu in a sensible way, not just hide it?

A little bit of background. The preloaded disposables was setting the internal feature when preloading and emptying it when marking the preloaded as used. Now, if the disposable template has the internal feature set to true, it is not removing it anymore.

About a sensible way to show it, I don't know how.

@marmarta
Copy link
Member

marmarta commented May 7, 2025

A little bit of background. The preloaded disposables was setting the internal feature when preloading and emptying it when marking the preloaded as used. Now, if the disposable template has the internal feature set to true, it is not removing it anymore.

Hmm, so the issue is basically that an in-use preloaded dispvm shows up in the menu with a fake parent? My proposal would be then:

  • an initial bandaid: do not show only those VMs in the menu (pre-loaded ones)
  • next step: make an issue to rework how parent VM is shown to account for VMs whose parent is internal (right now I'm torn between "show parent, just don't allow running stuff in it" and "completely change how parents are shown, aaaa"

@ben-grande
Copy link
Contributor Author

ben-grande commented May 7, 2025 via email

@marmarta
Copy link
Member

marmarta commented Jun 9, 2025

I think this looks fine on my side now, but codecov claims most of the actual internal-related lines are not covered by tests?

@ben-grande
Copy link
Contributor Author

ben-grande commented Jun 9, 2025

but codecov claims

From what I see, every failed check related to internal is a false positive.


The changes pushed are because I changed my mind on querying the template features, using check_with_template() now for uniformity with other Qubes components.

@marmarek
Copy link
Member

This is not resilient against not having access to the feature:

Jun 10 00:54:26 sys-gui qubes-app-menu[1285]: Traceback (most recent call last):
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:   File "/usr/lib/python3.13/site-packages/qubes_menu/appmenu.py", line 281, in do_activate
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:     self.perform_setup()
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:     ~~~~~~~~~~~~~~~~~~^^
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:   File "/usr/lib/python3.13/site-packages/qubes_menu/appmenu.py", line 401, in perform_setup
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:     self.vm_manager = VMManager(self.qapp, self.dispatcher)
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:                       ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:   File "/usr/lib/python3.13/site-packages/qubes_menu/vm_manager.py", line 210, in __init__
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:     self.load_vm_from_name(vm.name)
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:     ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:   File "/usr/lib/python3.13/site-packages/qubes_menu/vm_manager.py", line 228, in load_vm_from_name
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:     if vm.features.check_with_template("internal", False):
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:   File "/usr/lib/python3.13/site-packages/qubesadmin/features.py", line 83, in check_with_template
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:     qubesd_response = self.vm.qubesd_call(
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:         self.vm.name, 'admin.vm.feature.CheckWithTemplate', feature)
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:   File "/usr/lib/python3.13/site-packages/qubesadmin/base.py", line 76, in qubesd_call
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:     return self.app.qubesd_call(dest, method, arg, payload,
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:            ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:         payload_stream)
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:         ^^^^^^^^^^^^^^^
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:   File "/usr/lib/python3.13/site-packages/qubesadmin/app.py", line 1021, in qubesd_call
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:     raise qubesadmin.exc.QubesDaemonAccessError(
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:         "Service call error: %s", stderr.decode()
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]:     )
Jun 10 00:54:26 sys-gui qubes-app-menu[1285]: qubesadmin.exc.QubesDaemonAccessError: Service call error: Request refused
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]: Traceback (most recent call last):
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:   File "/usr/lib/python3.13/site-packages/qubes_menu/appmenu.py", line 281, in do_activate
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:     self.perform_setup()
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:     ~~~~~~~~~~~~~~~~~~^^
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:   File "/usr/lib/python3.13/site-packages/qubes_menu/appmenu.py", line 401, in perform_setup
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:     self.vm_manager = VMManager(self.qapp, self.dispatcher)
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:                       ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:   File "/usr/lib/python3.13/site-packages/qubes_menu/vm_manager.py", line 210, in __init__
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:     self.load_vm_from_name(vm.name)
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:     ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:   File "/usr/lib/python3.13/site-packages/qubes_menu/vm_manager.py", line 228, in load_vm_from_name
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:     if vm.features.check_with_template("internal", False):
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:   File "/usr/lib/python3.13/site-packages/qubesadmin/features.py", line 83, in check_with_template
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:     qubesd_response = self.vm.qubesd_call(
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:         self.vm.name, 'admin.vm.feature.CheckWithTemplate', feature)
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:   File "/usr/lib/python3.13/site-packages/qubesadmin/base.py", line 76, in qubesd_call
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:     return self.app.qubesd_call(dest, method, arg, payload,
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:            ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:         payload_stream)
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:         ^^^^^^^^^^^^^^^
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:   File "/usr/lib/python3.13/site-packages/qubesadmin/app.py", line 1021, in qubesd_call
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:     raise qubesadmin.exc.QubesDaemonAccessError(
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:         "Service call error: %s", stderr.decode()
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]:     )
Jun 10 00:54:46 sys-gui qubes-app-menu[1285]: qubesadmin.exc.QubesDaemonAccessError: Service call error: Request refused

It choked on dom0 specifically:

Jun 10 00:54:45.982922 dom0 qrexec-policy-daemon[1733]: qrexec: admin.vm.feature.CheckWithTemplate+internal: sys-gui -> dom0: denied: no matching rule found

I guess sys-gui should be able to get properties/features of dom0. But still, menu shouldn't explode if permissions are limited.

@ben-grande
Copy link
Contributor Author

But still, menu shouldn't explode if permissions are limited.

Handling exception now.

@marmarek
Copy link
Member

mypy complains, and looking at the message it's a valid complain

@marmarek
Copy link
Member

Can you split formatting and functional changes into separate commits?

@marmarek
Copy link
Member

PipelineRetry

@marmarek marmarek merged commit 4cfd5a0 into QubesOS:main Jun 27, 2025
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants