-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy path58-xapi.rules
76 lines (53 loc) · 2.76 KB
/
58-xapi.rules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Quickly skip stuff we don't care about at all:
# Skip block devices - no networks in here
SUBSYSTEM!="block", GOTO="end_xapi"
ACTION=="add|change", KERNEL=="xvd*|td*|nbd*", GOTO="ignore_device"
# srX are not partitions, go check if it's a cdrom. handle remove specially.
ACTION=="remove", KERNEL=="sr[0-9]", GOTO="usb_symlink"
KERNEL=="sr[0-9]", GOTO="maybe_cdrom"
# Skip partitions - whole disks only please
KERNEL=="*[0-9]", GOTO="end_xapi"
# Split on device type: ##############################################################
LABEL="maybe_cdrom"
# Is it a CDROM?
PROGRAM=="/bin/grep '^drive name:.*\W%k\(\W\|$$\)' /proc/sys/dev/cdrom/info", GOTO="usb_cdrom_symlink"
# Is it USB?
SUBSYSTEMS=="usb", GOTO="usb_symlink"
# If neither of those, ignore
GOTO="end_xapi"
# Handle all CDROM devices here: #####################################################
LABEL="usb_cdrom_symlink"
# For CDs, create a symlink and start the corresponding cdrommon service
# This is done on the "change" action as well as "add" because devices that exist from
# boot are only triggered with the "change" action.
ACTION=="add|change", SYMLINK+="xapi/cd/%k"
ACTION=="add|change", TAG+="systemd", ENV{SYSTEMD_WANTS}+="cdrommon@$name.service"
ACTION=="add", RUN+="/bin/sh -c '/opt/xensource/libexec/local-device-change %k 2>&1 >/dev/null&'"
ACTION=="remove", RUN+="/bin/sh -c '/opt/xensource/libexec/local-device-change %k 2>&1 >/dev/null&'"
GOTO="end_xapi"
# Handle all non-CDROM USB devices here: #############################################
LABEL="usb_symlink"
# Skip devices which fail the local sharing check (to filter out root/mounted devices)
ACTION=="add", PROGRAM!="/opt/xensource/libexec/check-device-sharing %k", GOTO="end_xapi"
ACTION=="add|change", SYMLINK+="xapi/block/%k"
ACTION=="add", RUN+="/bin/sh -c '/opt/xensource/libexec/local-device-change %k 2>&1 >/dev/null&'"
ACTION=="remove", RUN+="/bin/sh -c '/opt/xensource/libexec/local-device-change %k 2>&1 >/dev/null&'"
GOTO="end_xapi"
# Handle VDIs plugged into Dom0 here: #############################################
LABEL="ignore_device"
# Do not let udev access them: it would prevent unplugging during VDI import
# To avoid patching other udev rule files we set env vars to skip processing rules
# from dm_disable in 10-dm.rules
# will also disable 65-md-incremental.rules processing
ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}="1"
ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="1"
ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
OPTIONS:="nowatch"
# prevent 60-persistent-storage.rules processing
# depends on backported env flag in systemd
ENV{UDEV_DISABLE_PERSISTENT_STORAGE_RULES_FLAG}="1"
# prevent 62-multipath.rules processing
ENV{nompath}="1"
GOTO="end_xapi"
######################################################################################
LABEL="end_xapi"