Use admin.vm.List method to get VM class#439
Conversation
Normally, VM class is cached when getting list of all (accessible) VMs. This means the admin.vm.property.Get+klass is normally not used. But if there is a case where VM object is created without listing all VMs first, it will not get the 'klass' property set. Apparently preloaded disposables trigger this case in audiovm. The thing is, admin.vm.property.Get+klass is mostly redundant with admin.vm.List (directed at a specific qube), since admin.vm.List contains that information already - so it doesn't make much sense to force everybody to add both to the policy. Fix this by using admin.vm.List to get the VM class. Fixes QubesOS/qubes-issues#10717
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #439 +/- ##
==========================================
+ Coverage 76.17% 76.18% +0.01%
==========================================
Files 53 53
Lines 9312 9321 +9
==========================================
+ Hits 7093 7101 +8
- Misses 2219 2220 +1 ☔ 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=2026030114-4.3&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=2026020304-devel&flavor=update
Failed tests26 failures
Fixed failuresCompared to: https://openqa.qubes-os.org/tests/166096#dependencies 25 fixed
Unstable testsDetailsPerformance TestsPerformance degradation:15 performance degradations
Remaining performance tests:96 tests
|
|
I tried to test this, but I am facing issues unrelated to this PR... Details
[user@sys-audio ~]$ qvm-start-daemon --all --watchTraceback (most recent call last):
File "/usr/lib/python3.13/site-packages/qubesadmin/base.py", line 386, in __setattr__
self.qubesd_call(
~~~~~~~~~~~~~~~~^
self._method_dest,
^^^^^^^^^^^^^^^^^^
self._method_prefix + 'Set',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
key,
^^^^
str(value).encode('utf-8'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/site-packages/qubesadmin/base.py", line 87, in qubesd_call
return self.app.qubesd_call(dest, method, arg, payload,
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
payload_stream)
^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/site-packages/qubesadmin/app.py", line 1023, in qubesd_call
raise qubesadmin.exc.QubesDaemonAccessError(
"Service call error: %s", stderr.decode()
)
qubesadmin.exc.QubesDaemonAccessError: Service call error: Request refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/qvm-start-daemon", line 5, in <module>
sys.exit(main())
~~~~^^
File "/usr/lib/python3.13/site-packages/qubesadmin/tools/qvm_start_daemon.py", line 1097, in main
args = parser.parse_args()
File "/usr/lib/python3.13/site-packages/qubesadmin/tools/__init__.py", line 431, in parse_args
action.parse_qubes_app(self, namespace)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/site-packages/qubesadmin/tools/__init__.py", line 163, in parse_qubes_app
for vm in app.domains
^^^^^^^^^^^
File "/usr/lib/python3.13/site-packages/qubesadmin/app.py", line 153, in __iter__
yield self[vm]
~~~~^^^^
File "/usr/lib/python3.13/site-packages/qubesadmin/app.py", line 109, in __getitem__
return self.get_blind(item)
~~~~~~~~~~~~~~^^^^^^
File "/usr/lib/python3.13/site-packages/qubesadmin/app.py", line 126, in get_blind
self._vm_objects[item] = cls(
~~~^
self.app, item, klass=klass, power_state=power_state
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/lib/python3.13/site-packages/qubesadmin/vm/__init__.py", line 60, in __init__
self.log = logging.getLogger(name)
^^^^^^^^
File "/usr/lib/python3.13/site-packages/qubesadmin/base.py", line 393, in __setattr__
raise qubesadmin.exc.QubesPropertyAccessError(key)
qubesadmin.exc.QubesPropertyAccessError: Failed to access 'log' propertyWhy it is trying to set the logger like this... I tried to downgrade qubes-core-admin-client to much older versions, but it didn't help. |
|
Did you took the whole repo, or just one fie? There were recently other changes in the repo related to type hints that look related to the error you get. |
Just that file and latest released version 4.3.29. I then cloned the repo from main branch and placed into PYTHONPATH, tried with some preloaded disposables, and it worked, no exception. |
Normally, VM class is cached when getting list of all (accessible)
VMs. This means the admin.vm.property.Get+klass is normally not used.
But if there is a case where VM object is created without listing all
VMs first, it will not get the 'klass' property set. Apparently
preloaded disposables trigger this case in audiovm.
The thing is, admin.vm.property.Get+klass is mostly redundant with
admin.vm.List (directed at a specific qube), since admin.vm.List
contains that information already - so it doesn't make much sense to
force everybody to add both to the policy.
Fix this by using admin.vm.List to get the VM class.
Fixes QubesOS/qubes-issues#10717