Cache libvirt domain state#819
Conversation
|
PipelineRetryFailed |
|
Didn't run openqa locally, only experiment some things, start, shutdown, kill, checking Domains Widget. |
|
PipelineRetryFailed |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #819 +/- ##
==========================================
- Coverage 70.42% 70.12% -0.30%
==========================================
Files 61 61
Lines 14143 14174 +31
==========================================
- Hits 9960 9940 -20
- Misses 4183 4234 +51
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
5eff83f to
aa2e823
Compare
|
PipelineRetryFailed |
1 similar comment
|
PipelineRetryFailed |
|
Marked as draft as there still is some caching issues for the |
|
If necessary (or simpler), it's IMO okay to use cache only for |
Experimenting with cache a bit more and it's getting better, but if I don't get it to a hundred percent, will not cache the power state. |
|
From my tests, it seems to be working. My nemesis, OpenQA, should try me. Do you know a subset of tests that are interesting before joining this PR in the full run? Looking at this recent test:
Line to use after this PR is not draft anymore: |
|
I'd include also at least one of the guivm tests |
9538d21 to
6011ca3
Compare
|
PipelineRetryFailed |
|
Last CI failed on Fedora 43 to due to: So it finally reached this repo. |
|
PipelineRetryFailed |
|
openQArun TEST=system_tests_suspend,system_tests_usbproxy,system_tests_devices,system_tests_gui_tools,system_tests_guivm_gui_interactive |
7bda37a to
a0a7e60
Compare
Since there is "resume", and there is a moment when resuming that domain might still be suspended, or event suspending a domain on purposed, allow clients to know the domain state.
Useful when debugging to know what's happening. I thought of logging the pretty name of the detail, but that got really big and I think it's out of scope from the Qubes OS project and in scope of the python-libvirt package.
- Keep events related to domain state in the same place - Shorter exception messages, as it's already prefixed with qube name - Much easier to read with less body on the if statements - Will help on a future commit to access private attributes without having to disable pylint checks - The events are related to a domain, not to the larger app instance
f140ed3 to
29678d5
Compare
The state changes rarely, but querying it can take a considerable blocking time, worse when looping through the state of multiple domains. For: QubesOS/qubes-issues#10569 For: QubesOS/qubes-issues#9902
2d4a274 to
fd6ef64
Compare
These data only changes once when domain is running.
This function reimports the same information over and over and is time consuming when looping through multiple domains. Reduce listing USB devices while there is no cache from 2.8s to 0.5s.
Method 'startwith' adds considerable overhead.
Libvirt API can be quite slow on the methods for "listAllDevices" and "XMLDesc", aggravated in loops.
Assuming that hotplug is unsupported.
Each call was recording 1ms, now the calls are below that.
Although it doesn't help reduce the time to get the XML, as XMLDesc() is super slow, this helps cleanup the code a bit.
Skip PVH when listing attached PCI devices, as they can't possibly be there.
fd6ef64 to
3e21f97
Compare
DemiMarie
left a comment
There was a problem hiding this comment.
XPath variables are super nice. They are the XPath equivalent of SQL parameterized queries.
| if source.get("dev") == "/dev/%s" % volume.vid: | ||
| return True | ||
| disks = parsed_xml.xpath( | ||
| "//domain/devices/disk/source[@dev='/dev/{}']".format(volume.vid) |
There was a problem hiding this comment.
Instead of injecting the variable with .format(), use XPath variables. Something like this (not tested):
disks = parsed_xml.xpath(
"//domain/devices/disk/source[@dev = $dev]",
dev = "/dev/" + volume.vid)This avoids an XPath injection vulnerability if volume.vid winds up containing an apostraphe. You can use a regular expression to validate volume.vid, but even then it is much better to use XPath variables.
.find() is even faster if it’s an option.
| disks = parsed_xml.xpath( | ||
| "//domain/devices/disk/source[@dev='/dev/{}']".format(volume.vid) | ||
| ) |
The state changes rarely, but querying it can take a considerable time, that is blocking, when looping through the state of multiple domains.
For: QubesOS/qubes-issues#10569
For: QubesOS/qubes-issues#9902
Didn't run openqa locally, only experiment some things:
qubed-query -e dom0 admin.vm.CurrentState QUBETODO: