Skip to content

Conversation

ben-grande
Copy link
Contributor

Fixes: QubesOS/qubes-issues#10227
For: QubesOS/qubes-issues#1512


Missing some tests.

qubes/app.py Outdated
and getattr(obj, prop.__name__) == vm
):
if getattr(obj, "is_preload") and (
prop.__name__ in ["default_dispvm", "template"]
Copy link
Member

Choose a reason for hiding this comment

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

You sure about default_dispvm here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, see logs from qubesmanager tests:

'This qube cannot be removed. It is used as: <br> - <b>default_dispvm</b> for qube <b>anon-whonix</b>

Copy link
Member

Choose a reason for hiding this comment

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

if it's really used as default_dispvm for anon-whonix the removal should be blocked... the only thing that shouldn't be blocked is being a template (only) for preloaded disposables, that you are going to kill/remove below anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hum, then I need to do it another way because a disposable qube has the default_dispvm property set to its template, so it must be only if those two properties matches.

if newvalue:
return
if any(self.dispvms):
if any(True for disp in self.dispvms if not disp.is_preload):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if any(True for disp in self.dispvms if not disp.is_preload):
if any(not disp.is_preload for disp in self.dispvms):

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Better

@ben-grande ben-grande force-pushed the preload-template-switch branch from e427a69 to 0947f51 Compare September 16, 2025 20:01
@marmarek
Copy link
Member

CI says typo:

AttributeError: 'DispVM' object has no attribute 'is_prelaod'. Did you mean: 'is_preload'?

@ben-grande ben-grande force-pushed the preload-template-switch branch from 0947f51 to a30519b Compare September 17, 2025 05:33
@codecov
Copy link

codecov bot commented Sep 17, 2025

Codecov Report

❌ Patch coverage is 90.90909% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.70%. Comparing base (7e72d38) to head (ed344a6).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
qubes/vm/dispvm.py 25.00% 6 Missing ⚠️
qubes/vm/mix/dvmtemplate.py 98.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #733      +/-   ##
==========================================
+ Coverage   70.61%   70.70%   +0.09%     
==========================================
  Files          61       61              
  Lines       13642    13728      +86     
==========================================
+ Hits         9633     9707      +74     
- Misses       4009     4021      +12     
Flag Coverage Δ
unittests 70.70% <90.90%> (+0.09%) ⬆️

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

☔ 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-template-switch branch 2 times, most recently from 28276e3 to 0e2a25d Compare September 17, 2025 08:06
)

@qubes.events.handler("domain-pre-delete")
def on_domain_pre_deleted(self, event, vm):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't like the code duplication.

Especially the part some lines below "see 'journalctl'" because not everything is returned to the caller. The preloads are introducing one extra discrepancy on top of device assignment only seen from dom0 journal.

I think there should be an API method to check if the qube is deletale and if not, the (vm, prop) is returned via exception. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

It's done this way because the caller may not see the whole system (it can be for example a GUIVM with access to a subset of qubes). Returning the whole list may leak info about other qubes that the caller should not see.
The utility function in core-admin-client is supposed to find where the qube is used - based on what the caller actually can see.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make sense, thanks for the explanation.

@ben-grande ben-grande force-pushed the preload-template-switch branch 7 times, most recently from c202c55 to c2093bf Compare September 17, 2025 15:54
@ben-grande
Copy link
Contributor Author

Are integration tests necessary seen that coverage is high?

@ben-grande ben-grande force-pushed the preload-template-switch branch from c2093bf to b52c6c7 Compare September 17, 2025 17:17
@ben-grande ben-grande marked this pull request as ready for review September 17, 2025 17:19
"Cannot remove %s as it is used by %s",
vm,
", ".join(
":".join(str(i) for i in tup) for tup in dependencies
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All the client tools, qvm-remove and qube-manager show a nice view of dependencies, the journal/logs were not showing them. Discovered that qube names can end with a . dot... I guess and hope : will never be allowed in qube names.

if isinstance(obj, qubes.app.Qubes):
dependencies.append(('"GLOBAL"', prop.__name__))
elif not obj.property_is_default(prop):
dependencies.append((obj.name, prop.__name__))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't find a better name than "GLOBAL" for the global property, it is using quotes to distinguish from a qube name. It prints as such:

ERROR: Cannot remove default-dvm as it is used by disp-test:template, sys-firewall:template, sys-usb:template, "GLOBAL":default_dispvm

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.

Can't change property (referencing a qube) or state of qube when there are preloaded disposables in chain

2 participants