core-admin/misc/usb_add_change
2012-10-21 14:59:34 +02:00

24 lines
725 B
Bash
Executable File

#!/bin/sh
##
## This script is invoked by udev rules whenever USB device appears or
## changes. This happens in usbvm domain (or dom0 if USB controller
## drivers are in dom0). The script records information about available
## USB devices into XS directory, making it available to qvm-usb tool
## running in dom0.
##
# FIXME: Ignore USB hubs.
[ "$DEVTYPE" = "usb_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"
#xenstore-write "$XS_KEY/_devname" "$DEVNAME"
#xenstore-write "$XS_KEY/_devtype" "$DEVTYPE"
# Make sure PVUSB backend driver is loaded.
/sbin/modprobe xen-usbback 2> /dev/null || /sbin/modprobe usbbk