Reject wrong default_dispvm and management_dispvm#809
Conversation
afbb24f to
bb2ea80
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #809 +/- ##
==========================================
+ Coverage 70.24% 70.43% +0.19%
==========================================
Files 61 61
Lines 14073 14139 +66
==========================================
+ Hits 9885 9959 +74
+ Misses 4188 4180 -8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
OpenQA test summaryComplete test suite and dependencies: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.3&build=2026052509-devel&flavor=pull-requests Test run included the following:
Upload failures
New failures, excluding unstableCompared to: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.3&build=2026050504-devel&flavor=update
Failed tests23 failures
Fixed failuresCompared to: https://openqa.qubes-os.org/tests/176874#dependencies 26 fixed
Unstable testsDetails
Performance TestsPerformance degradation:16 performance degradations
Remaining performance tests:56 tests
|
| ) | ||
|
|
||
| mock_events.reset_mock() | ||
| self.app.default_dispvm = False |
There was a problem hiding this comment.
| self.app.default_dispvm = False | |
| self.app.default_dispvm = None |
| used_by_system = [] | ||
| if self == getattr(self.app, "default_dispvm", None): | ||
| used_by_system.append("default_dispvm") | ||
| if self == getattr(self.app, "management_dispvm", None): | ||
| used_by_system.append("management_dispvm") | ||
| if used_by_system: | ||
| msg = ( | ||
| "Cannot change template_for_dispvms to False while it is the " | ||
| "system's %s" % (", ".join(used_by_system)) | ||
| ) | ||
| self.log.error("%s", msg) | ||
| raise qubes.exc.QubesVMInUseError(self, msg) | ||
| used_by_qube: dict[str, list] = {} | ||
| for qube in self.app.domains: | ||
| for prop in ["default_dispvm", "management_dispvm"]: | ||
| if self == getattr(qube, prop, None): | ||
| used_by_qube.setdefault(str(qube), []).append(prop) |
There was a problem hiding this comment.
This looks quite similar to qubes.on_domain_pre_deleted() handler. Maybe better extract that into a helper function and use in both places? That function would need to have a parameter for properties list, because here you want just template, management_dispvm and default_dispvm, but in remove case you want all (including netvm, guivm for example).
010bec3 to
80cd0d2
Compare
Validation on pre-events is not called when using "app.add_new_vm()", a setter is necessary for those cases. Setter plus pre-set is unnecessary when validating only newvalue. Also prohibit removing "template_for_dispvms" when disposable template is referenced as a property by the system or any other qube, including itself. Fixes: QubesOS/qubes-issues#10881
80cd0d2 to
95895a4
Compare
|
PipelineRetry |
Validation on pre-events is not called when using "app.add_new_vm()", a
setter is necessary for those cases. Setter plus pre-set is unnecessary
when validating only newvalue.
Also prohibit removing template_for_dispvms when disposable template is referenced as a property by the system or any other qube, including itself.
Fixes: QubesOS/qubes-issues#10881