dom0+vm/qvm-usb: First implementation of udev rules and supporting scripts.

This commit is contained in:
Alexandre Bezroutchko 2012-10-07 19:35:46 +02:00
parent a9fd8ec5dd
commit e1fc07613d
3 changed files with 29 additions and 0 deletions

10
misc/qubes_usb.rules Normal file
View File

@ -0,0 +1,10 @@
# Expose all USB devices (except block) via xenstore
# Handle only USB devices
SUBSYSTEM!="usb", GOTO="qubes_usb_end"
ACTION=="add", IMPORT{program}="/usr/lib/qubes/usb_add_change"
ACTION=="change", IMPORT{program}="/usr/lib/qubes/usb_add_change"
ACTION=="remove", RUN+="/usr/lib/qubes/usb_remove"
LABEL="qubes_usb_end"

9
misc/usb_add_change Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
[ "x$DEVTYPE" = "xusb_device" ] || exit 0
NAME="${ID_VENDOR_ID}_${ID_MODEL_ID}"
DESC="${NAME} ${ID_SERIAL}"
XS_KEY="qubes-usb-devices/$NAME"
xenstore-write "$XS_KEY/desc" "$DESC"

10
misc/usb_remove Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
[ "x$DEVTYPE" = "xusb_device" ] || exit 0
NAME="${ID_VENDOR_ID}_${ID_MODEL_ID}"
DESC="${NAME} ${ID_SERIAL}"
XS_KEY="qubes-usb-devices/$NAME"
xenstore-rm "$XS_KEY"