Use Qubes DB instead of Xenstore

This commit is contained in:
Marek Marczykowski 2013-06-07 05:21:41 +02:00 committed by Marek Marczykowski-Górecki
parent a91a8c8312
commit dc41fbad79
6 changed files with 22 additions and 23 deletions

View File

@ -5,11 +5,12 @@ NAME=${DEVNAME#/dev/}
DESC="`echo "${ID_MODEL} (${ID_FS_LABEL})" | iconv -f utf8 -t ascii//TRANSLIT`"
SIZE=$[ $(cat /sys/$DEVPATH/size) * 512 ]
MODE=w
XS_KEY="qubes-block-devices/$NAME"
QDB_KEY="/qubes-block-devices/$NAME"
xs_remove() {
if [ "$QUBES_EXPOSED" == "1" ]; then
xenstore-rm "$XS_KEY"
qubesdb-rm "$QDB_KEY"
qubesdb-write /qubes-block-devices ''
fi
echo QUBES_EXPOSED=0
}
@ -59,17 +60,12 @@ if [ -n "$DM_NAME" ]; then
DESC="$DM_NAME"
fi
# Get lock only in dom0 - there are so many block devices so it causes xenstore
# deadlocks sometimes.
if [ -f /etc/qubes-release ]; then
# Skip xenstore-write if cannot obtain lock. This can mean very early system startup
# stage without /run mounted (or populated). Devices will be rediscovered later
# by qubes-core startup script.
exec 9>>/var/run/qubes/block-xenstore.lock || exit 0
flock 9
fi
xenstore-write "$XS_KEY/desc" "$DESC" "$XS_KEY/size" "$SIZE" "$XS_KEY/mode" "$MODE"
# The last one is meant to trigger watches
qubesdb-write \
"$QDB_KEY/desc" "$DESC" \
"$XS_KEY/size" "$SIZE" \
"$XS_KEY/mode" "$MODE" \
/qubes-block-devices ''
echo QUBES_EXPOSED=1
# Make sure that block backend is loaded

View File

@ -1,8 +1,9 @@
#!/bin/sh
NAME=${DEVNAME#/dev/}
XS_KEY="qubes-block-devices/$NAME"
xenstore-rm "$XS_KEY"
QDB_KEY="/qubes-block-devices/$NAME"
qubesdb-rm "$XS_KEY"
qubesdb-write /qubes-block-devices ''
# If device was connected to some VM - detach it
# Notice: this can be run also in VM, so we cannot use xl...

View File

@ -1,4 +1,4 @@
# Expose all (except xen-frontend) block devices via xenstore
# Expose all (except xen-frontend) block devices via Qubes DB
# Only block devices are interesting
SUBSYSTEM!="block", GOTO="qubes_block_end"

View File

@ -1,4 +1,4 @@
# Expose all USB devices (except block) via xenstore
# Expose all USB devices (except block) via Qubes DB
# Handle only USB devices
SUBSYSTEM!="usb", GOTO="qubes_usb_end"

View File

@ -12,7 +12,7 @@
[ "`echo $TYPE | cut -f1 -d/`" = "9" ] && exit 0
[ "$DEVTYPE" != "usb_device" ] && exit 0
# xenstore doesn't allow dot in key name
# qubesdb doesn't allow dot in key name
XSNAME=`basename ${DEVPATH} | tr . _`
# FIXME: For some devices (my Cherry keyboard) ID_SERIAL does not
@ -31,10 +31,11 @@ else
exit 0
fi
XS_KEY="qubes-usb-devices/$XSNAME"
QDB_KEY="/qubes-usb-devices/$XSNAME"
xenstore-write "$XS_KEY/desc" "$DESC"
xenstore-write "$XS_KEY/usb-ver" "$VERSION"
qubesdb-write "$QDB_KEY/desc" "$DESC"
qubesdb-write "$QDB_KEY/usb-ver" "$VERSION"
qubesdb-write /qubes-usb-devices ''
# Make sure PVUSB backend driver is loaded.
/sbin/modprobe xen-usbback 2> /dev/null || /sbin/modprobe usbbk

View File

@ -4,6 +4,7 @@
[ "`echo $TYPE | cut -f1 -d/`" = "9" ] && exit 0
NAME=`basename ${DEVPATH} | tr . _`
XS_KEY="qubes-usb-devices/$NAME"
QDB_KEY="/qubes-usb-devices/$NAME"
xenstore-rm "$XS_KEY"
qubesdb-rm "$QDB_KEY"
qubesdb-write /qubes-usb-devices ''