dom0+vm: expose block devices info in xenstore (#226)
This commit is contained in:
parent
0b746bbf70
commit
012dc63c53
29
common/block_add_change
Executable file
29
common/block_add_change
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
NAME=${DEVNAME#/dev/}
|
||||
DESC="${ID_MODEL} (${ID_FS_LABEL})"
|
||||
SIZE=$(cat /sys/$DEVPATH/size)
|
||||
MODE=w
|
||||
XS_KEY="qubes-block-devices/$NAME"
|
||||
|
||||
# Ignore mounted...
|
||||
if fgrep -q $DEVNAME /proc/mounts; then
|
||||
xenstore-rm "$XS_KEY"
|
||||
exit 0
|
||||
fi
|
||||
# ... and used by device-mapper
|
||||
if [ -n "`ls -A /sys/$DEVPATH/holders 2> /dev/null`" ]; then
|
||||
xenstore-rm "$XS_KEY"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Special case for CD
|
||||
if [ "$ID_TYPE" = "cd" ]; then
|
||||
if [ "$ID_MEDIA_CDROM" != "1" ]; then
|
||||
# Hide empty cdrom drive
|
||||
xenstore-rm "$XS_KEY"
|
||||
exit 0
|
||||
fi
|
||||
MODE=r
|
||||
fi
|
||||
xenstore-write "$XS_KEY/desc" "$DESC" "$XS_KEY/size" "$SIZE" "$XS_KEY/mode" "$MODE"
|
5
common/block_remove
Executable file
5
common/block_remove
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
NAME=${DEVNAME#/dev/}
|
||||
XS_KEY="qubes-block-devices/$NAME"
|
||||
xenstore-rm "$XS_KEY"
|
19
common/qubes_block.rules
Normal file
19
common/qubes_block.rules
Normal file
@ -0,0 +1,19 @@
|
||||
# Expose all (except xen-frontend) block devices via xenstore
|
||||
|
||||
# Only block devices are interesting
|
||||
SUBSYSTEM!="block", GOTO="qubes_block_end"
|
||||
|
||||
# Skip xen-blkfront devices
|
||||
ENV{MAJOR}=="202", GOTO="qubes_block_end"
|
||||
|
||||
# Skip loop devices
|
||||
ENV{MAJOR}=="7", GOTO="qubes_block_end"
|
||||
|
||||
# Skip device-mapper devices
|
||||
ENV{MAJOR}=="253", GOTO="qubes_block_end"
|
||||
|
||||
ACTION=="add", RUN+="/usr/lib/qubes/block_add_change"
|
||||
ACTION=="change", RUN+="/usr/lib/qubes/block_add_change"
|
||||
ACTION=="remove", RUN+="/usr/lib/qubes/block_remove"
|
||||
|
||||
LABEL="qubes_block_end"
|
@ -78,9 +78,12 @@ cp serial.conf $RPM_BUILD_ROOT/var/lib/qubes/
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/udev/rules.d
|
||||
cp qubes_network.rules $RPM_BUILD_ROOT/etc/udev/rules.d/99-qubes_network.rules
|
||||
cp qubes_memory.rules $RPM_BUILD_ROOT/etc/udev/rules.d/50-qubes_memory.rules
|
||||
cp qubes_block.rules $RPM_BUILD_ROOT/etc/udev/rules.d/99-qubes_block.rules
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/lib/qubes/
|
||||
cp setup_ip $RPM_BUILD_ROOT/usr/lib/qubes/
|
||||
cp qubes_download_dom0_updates.sh $RPM_BUILD_ROOT/usr/lib/qubes/
|
||||
cp block_add_change $RPM_BUILD_ROOT/usr/lib/qubes/
|
||||
cp block_remove $RPM_BUILD_ROOT/usr/lib/qubes/
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/yum/post-actions
|
||||
cp qubes_trigger_sync_appmenus.action $RPM_BUILD_ROOT/etc/yum/post-actions/
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/lib/qubes
|
||||
@ -243,9 +246,12 @@ rm -rf $RPM_BUILD_ROOT
|
||||
/usr/bin/xenstore-watch-qubes
|
||||
/etc/udev/rules.d/99-qubes_network.rules
|
||||
/etc/udev/rules.d/50-qubes_memory.rules
|
||||
/etc/udev/rules.d/99-qubes_block.rules
|
||||
/etc/sysconfig/modules/qubes_core.modules
|
||||
/usr/lib/qubes/setup_ip
|
||||
/etc/yum/post-actions/qubes_trigger_sync_appmenus.action
|
||||
/usr/lib/qubes/qubes_trigger_sync_appmenus.sh
|
||||
/usr/lib/qubes/qubes_download_dom0_updates.sh
|
||||
/usr/lib/qubes/block_add_change
|
||||
/usr/lib/qubes/block_remove
|
||||
/lib/firmware/updates
|
||||
|
Loading…
Reference in New Issue
Block a user