device busy attribute to prevent attaching devices whose children are in use#840
device busy attribute to prevent attaching devices whose children are in use#840piotrbartman wants to merge 2 commits into
Conversation
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
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. |
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)