Commit Graph

20 Commits

Author SHA1 Message Date
Marek Marczykowski-Górecki
c7420318e2
udev: fix loop devices exclusion based on directory flagfile
Getting loop device backing file path was broken:
${NAME%p*} for not-partitioned devices will cut the actual device name.
Use full name instead. This probably breaks handling partitioned
devices, but such devices should not appear in a directory flagged to be
ignored (VM images)

QubesOS/qubes-issues#3084
2017-09-15 05:25:42 +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
e0acdee23c
udev-block-add-change: fix checking if partition is mounted
is_used() function should operate on its argument, not global $DEVNAME.
2016-07-17 05:08:25 +02:00
Rusty Bird
a032129b80
udev-block-add-change: simplify a check 2016-07-15 16:15:42 +00:00
Rusty Bird
6b32378158
udev-block-add-change: don't exclude already attached devs
For example, attaching a device-mapper device to another VM increases
its "dmsetup info" open count in is_used(), which triggered its removal
from qvm-block.
2016-07-15 16:15:41 +00:00
Rusty Bird
e7d7111f13
udev-block-add-change: better mount status check
The canonical device name is not necessarily used in /proc/mounts or
/proc/self/mountinfo, see /dev/dm-0 vs. /dev/mapper/dmroot. (And only
checking by major:minor is not possible in the case of btrfs.)

Also fixes another bug where e.g. dm-10 would match when really only
dm-1 was mounted, or when the mountpoint path included the device name,
etc.

Also catches enabled swap.
2016-07-15 16:15:41 +00:00
Marek Marczykowski-Górecki
cdbcb2eb55
udev: fix deadlock on xenstore access during dom0 boot
During early dom0 boot, before xenstored is started any access to it
through /proc/xen/xenbus (or /dev/xen/xenbus) will wait until xenstored
is started. If that happens in script ordered to start before xenstored,
we have a deadlock. Prevent this by using `xenstore-ls -s` in dom0,
which will fail immediately when xenstored isn't running yet. This fail
isn't a problem, because when xenstored isn't running yet, surely device
isn't attached anywhere.

QubesOS/qubes-issues#1081
2016-05-17 22:41:51 +02:00
Marek Marczykowski-Górecki
098bfb634d
udev/qvm-block: exclude device if its partition is already attached
This prevents simultaneous attachment of the same device (in practice)
to multiple VMs.
This change to be effective requires udev action being called when such
device is attached/detached to some domain. Script
/etc/xen/scripts/block will take care of it.

Fixes QubesOS/qubes-issues#1081
2016-05-16 11:53:30 +02:00
Marek Marczykowski-Górecki
efd9854376
udev/qvm-block: exclude devices used elsewhere
Exclude exclude device if mounted/part of other device, or any of its
partition is used (same definition). Update this state whenever device
or it's partition receives udev event.

Fixes QubesOS/qubes-issues#1600
2016-05-16 11:52:57 +02:00
Marek Marczykowski-Górecki
22d6892ec9
udev: fix hiding devices from qvm-block
When device becomes non-attachable (for example because it gets mounted,
or used as part of LVM/RAID/whatever), it should be removed from
advertised available devices. The code for removing QubesDB entry was
buggy - the device is actually a directory in QubesDB, not a single
entry.

QubesOS/qubes-issues#1600
2016-01-14 05:01:27 +01:00
Marek Marczykowski-Górecki
68bbd408d7 udev: fix block devices ignoring rule
First of all there was missing ']'. Bu additionally change that rule to
detect partitioned loop devices instead of device-mapper.
2015-04-03 11:14:15 +02:00
Marek Marczykowski-Górecki
c731fa5b28 udev: ignore temporary devices created during VM startup 2015-03-30 04:54:37 +02:00
Marek Marczykowski-Górecki
b4f48c1770 udev: update hotplug block scripts for QubesDB
Some initial work was done, but apparently not complete and buggy.
2014-12-11 06:06:57 +01:00
Marek Marczykowski
dc41fbad79 Use Qubes DB instead of Xenstore 2014-11-19 15:10:58 +01:00
Marek Marczykowski-Górecki
35300b54ac udev: update dmsetup path
Debian has it in /sbin/dmsetup. Fedora has /sbin->/usr/sbin symlink, so
it should work on both.
2014-07-26 15:47:15 +02:00
Marek Marczykowski-Górecki
644372149f udev: convert device description to ascii only 2014-07-05 16:13:08 +02:00
Marek Marczykowski-Górecki
44e5c20806 udev: fix perms of udev-block-add-change
Accidentally "x" was removed.
2014-06-29 21:57:20 +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
23ea1ebe19 qvm-block: detect read-only devices 2013-10-01 04:19:14 +02:00
Marek Marczykowski
42e133b753 Qrexec common code, qubes.Filecopy common code, udev scripts 2013-03-20 06:27:32 +01:00