Commit Graph

15 Commits

Author SHA1 Message Date
Marek Marczykowski-Górecki
9eafc65cb4
udev: don't call udev-block-add-change for devices excluded by other rules
The script call is quite expensive (it does multiple things, including
checking device-mapper, qubesdb etc). Don't call it for devices we (or
else) already excluded earlier.
This is the most relevant for dom0, where udev "change" event is
triggered quite often, for multiple LVM volumes - all excluded, because
being VM's disks.
2018-04-20 16:47:46 +02:00
Marek Marczykowski-Górecki
764b0f3f07
udev: major cleanup in block devices handling
1. Do not detach device forcefully when it's removed. This breaks
libvirt (which thinks the device is still there). After this change, it
is possible to detach device using libvirt, even if it was already
removed physically from backend domain (unless it is dom0 - in which
case it is still broken). So, this is partial fix for
QubesOS/qubes-issues#1082.

2. Do not trigger "change" udev event when only QubesDB state needs to
be updated - this leads to massive udev events queue, and heavy I/O
usage - for example scanning all LVM many times. In some cases it even
caused infinite event queue.

3. Do not use QUBES_EXPOSED udev property - it was needed a while back
before QubesDB, because concurrent xenstore accesses are expensive
(because of transactions). It isn't the problem on QubesDB.

4. Cache information about device-mapper, so it is possible to
reconstruct it at device remove - when the actual device cannot be
queried anymore. This is specifically about list of lower layer devices
used.

5. Allow excluding loop devices pointing at a file in directory marked
with ".qubes-exclude-block-devices" file. This is more generic than
hardcoding /var/lib/qubes.

QubesOS/qubes-issues#3084
Fixes QubesOS/qubes-issues#3073
QubesOS/qubes-issues#1082
2017-09-12 04:25:34 +02:00
Marek Marczykowski-Górecki
0d4c561064
udev: don't list in qvm-block any device marked to be ignored by udev
Not only device-mapper one.
This especially include loop devices for VM disk images.

QubesOS/qubes-issues#2319
2017-07-06 19:40:51 +02:00
Marek Marczykowski-Górecki
db2b027153
udev: use DM ignore device flag only for DM devices
For example do not exclude (from exposing to qvm-block) loop devices
with this flag set, otherwise `qvm-block -l` would not list just
attached disk image files.

Fixes QubesOS/qubes-issues#2453
2016-11-23 03:40:37 +01:00
Marek Marczykowski-Górecki
6ac3fc3247
udev: ignore devices set to be ignore elsewhere
There are already some other rules to ignore not interesting devices.
This includes device-mapper assembled in initramfs manually. 'dmroot'
isn't properly detected as mounted because /dev/mapper/dmroot isn't a
symlink to /dev/dm-0 and /proc/mounts contains the former name, while
udev event the later.

Fixes QubesOS/qubes-issues#1586
2016-01-07 03:00:32 +01:00
Marek Marczykowski-Górecki
50145d448a
udev: do not assume static device-mapper major number
It is not static.

QubesOS/qubes-issues#1586
2016-01-06 04:22:50 +01:00
Marek Marczykowski-Górecki
7148f8d135
Move udev scripts to /usr/lib/qubes, move rules to /lib/udev/
Resolve udev-rule-in-etc, non-standard-dir-in-usr, file-in-unusual-dir
lintian warnings.

QubesOS/qubes-issues#1416
2015-11-26 22:18:03 +01:00
Marek Marczykowski-Górecki
643ff5876d udev: do not use a separate lock for udev block scripts
Since migration to QubesDB, it isn't needed anymore (QubesDB have no
problem with concurrent writes, as transactions are not supported).
This should speedup system startup.
2015-06-28 21:59:39 +02:00
Marek Marczykowski
dc41fbad79 Use Qubes DB instead of Xenstore 2014-11-19 15:10:58 +01:00
Marek Marczykowski-Górecki
36a2c99b49 udev: filter out template's root device 2014-07-05 16:12:37 +02:00
Marek Marczykowski-Górecki
58df64ad20 udev: skip empty device-mapper nodes
It can happen during device reconfiguration - do not decide to expose
the device until its known what device it will be.
This fixes bug where root.img was visible in qvm-block as normal device
and could be detached.
2014-07-04 03:29:38 +02:00
Marek Marczykowski-Górecki
570446f448 udev: better support device-mapper/LVM
Do not ignore them completely.
2014-06-07 04:53:32 +02:00
Marek Marczykowski-Górecki
be74125d40 udev: hide internal drives from file-selection dialogs 2014-02-07 05:26:52 +01:00
Marek Marczykowski-Górecki
b51435c903 udev: add locking on block device processing
xenstored does handle concurrent writes very harshly - it aborts the
whole transaction if any other write happened the same time. For udev
(which process all the events almost at once) it means hundreds of
retries and in some times even exceed udev timeout (60s or so).
To prevent this problem, add locking to allow only one such event being
processed at once. It looks like it should slow down the system startup,
but actually it does otherwise.
2014-01-13 05:01:56 +01:00
Marek Marczykowski
42e133b753 Qrexec common code, qubes.Filecopy common code, udev scripts 2013-03-20 06:27:32 +01:00