Skip to content

Skip running check for untrusted_qdb access#818

Closed
ben-grande wants to merge 2 commits into
QubesOS:mainfrom
ben-grande:slow-dev
Closed

Skip running check for untrusted_qdb access#818
ben-grande wants to merge 2 commits into
QubesOS:mainfrom
ben-grande:slow-dev

Conversation

@ben-grande

Copy link
Copy Markdown
Contributor

One access doesn't takes few nanoseconds, but when looping through domains multiple times, this blocking operation can impact the responsiveness of qubesd.

For: QubesOS/qubes-issues#9902
For: QubesOS/qubes-issues#10569
For: QubesOS/qubes-issues#10648

Comment thread qubes/app.py
):
import qubesdb # pylint: disable=import-error

vm._qdb_connection = qubesdb.QubesDB(vm.name)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The reason I had to move to qubes.app is because firing the event "domain-load" reaches extensions before it reaches qubes.vm.qubesvm...

One access doesn't takes few nanoseconds, but when looping through
domains multiple times, this blocking operation can impact the
responsiveness of qubesd.

For: QubesOS/qubes-issues#9902
For: QubesOS/qubes-issues#10569
For: QubesOS/qubes-issues#10648
@marmarek

marmarek commented Jun 1, 2026

Copy link
Copy Markdown
Member

This PR likely completely breaks qubesdb access for freshly started VMs (as in - started when qubesd is already running).
Why exactly you do that? Generally, qdb property shouldn't be accessed if VM isn't running, so the case of this hitting not vm.is_running() (so, not opening the conneciton) should be rather rare.
And the just-pushed force-push is even worse - checking for untrusted_qdb property as a proxy for checking if VM is running is a very obscure solution.

Is it all to avoid calling vm.is_running()? Why? Did you found it slow? If so, the proper (the only acceptable) solution would be to optimize it, not avoid it. Maybe cache that info in the VM object, and update it based on libvirt events?

@ben-grande

Copy link
Copy Markdown
Contributor Author

This PR likely completely breaks qubesdb access for freshly started VMs (as in - started when qubesd is already running). Why exactly you do that? Generally, qdb property shouldn't be accessed if VM isn't running, so the case of this hitting not vm.is_running() (so, not opening the conneciton) should be rather rare. And the just-pushed force-push is even worse - checking for untrusted_qdb property as a proxy for checking if VM is running is a very obscure solution.

Is it all to avoid calling vm.is_running()? Why? Did you found it slow?

Yes. It is slow. One call is fine, but many blocking calls takes a considerable time considering it can be called thousand of times (3k-5k just from the two recorded API calls) to check that a halted domain, that has no untrusted_qdb, is not running.

I find it horrible to call libvirt_domain.isActive() multiple times for domains that is not running, and that we would need to write to their qubesdb, which is only available when the domain is running anyway.

If so, the proper (the only acceptable) solution would be to optimize it, not avoid it. Maybe cache that info in the VM object, and update it based on libvirt events?

I guess that is possible... I though it would be dangerous to cache such state, but I can try and see how it goes.

@ben-grande

Copy link
Copy Markdown
Contributor Author

Superseded by #819

@ben-grande ben-grande closed this Jun 1, 2026
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.

2 participants