device busy attribute to prevent attaching devices whose children are in use - #840
piotrbartman wants to merge 5 commits into
Conversation
Systemd's mount unit appears for mounted filesystems, so maybe there is a way to get events about it via dbus? Or maybe there is some systemd hook for this? But generally, there should be clear role split who is responsible for setting/clearing the busy flag. It should be either the backend (in which case qubesd should not change it without coordination), or qubesd (in which case, the backend shouldn't have influence over it - so, store outside of qubesdb). The mixed model is asking for troubles, when both sides have different idea about the current state. |
OpenQA test summaryComplete test suite and dependencies: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.3&build=2026071723-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 tests22 failures
Fixed failuresCompared to: https://openqa.qubes-os.org/tests/176874#dependencies 25 fixed
Unstable testsDetails
Performance TestsPerformance degradation:19 performance degradations
Remaining performance tests:91 tests
|
This tests needs an update, to look at the busy attribute now. |
I need to think about it |
we want to avoid the situation when we attach device which sub-devices are already attached and in the same time we want to keep this device visible. previous behavior removing the parent from QDB and hide it entirely instead of just blocking attachment, but then we have subdevice with parent that "does not exist" from point of Qubes The busy=True means that this device cannot be attached
if one of subdevices are locally used (e.g. in sys-usb) the parent is considered busy
`busy` = device or *its descendant* is `used` or `attached` the `attached` part is discovered by qubesd itself the `used` part is read from backend QubesDB If the backend does not support usage reporting, only devices that have no children can be attached. Other devices require the `--force` flag. Device listings was optimized to reduce number of passes.
New `device-check-available:<class>`, fired from `QubesVM.start()` for every required assignment to prevent stealing. `DeviceUsed` for "not free to take" refusal.
ef5b1eb to
bb5bb9c
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #840 +/- ##
==========================================
+ Coverage 70.75% 71.10% +0.34%
==========================================
Files 61 61
Lines 14456 14648 +192
==========================================
+ Hits 10229 10416 +187
- Misses 4227 4232 +5
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:
|
Add a
busyconcept toDeviceInfo,BlockDevice:Truewhen the device itself or any of its children (partition, sub-device) is in use (attached, or used locally inside the backend, e.g. mounted, dm slave, swap etc.). Busy devices get refused at attach time and skipped by auto-attach.BlockDevice.busylazily reads/caches /qubes-block-devices//busy from the backend's QDBqubes.RefreshBlockDevices, (see device busy attribute to prevent attaching devices whose children are in use qubes-linux-utils#144) rather than blindly clearing as dom0 can't see local mounts inside the backend, so a naive clear could free a USB parent while a sibling partition is still mounted there. This change is in the second commit and might be opted out after discussion.Open items:
_refresh_busy_after_detachdoesawait asyncio.sleep(1)before calling the backend (I'm not happy here, >.<), waiting for vbd teardown to actually disappear from sysfs.qubes.RefreshBlockDevicesthe code falls back to an attachment-based unmark which ignore internal usage. IMHO these are limited consequences._mark_parents_busy,_unmark_parents_busyswallow all exceptions silently (# best effort)fix: QubesOS/qubes-issues#9566
fix: QubesOS/qubes-issues#10180
should fix: QubesOS/qubes-issues#10828