From e1fc07613df0f4f87b49f12c7eb41eb8873049e5 Mon Sep 17 00:00:00 2001 From: Alexandre Bezroutchko Date: Sun, 7 Oct 2012 19:35:46 +0200 Subject: [PATCH] dom0+vm/qvm-usb: First implementation of udev rules and supporting scripts. --- misc/qubes_usb.rules | 10 ++++++++++ misc/usb_add_change | 9 +++++++++ misc/usb_remove | 10 ++++++++++ 3 files changed, 29 insertions(+) create mode 100644 misc/qubes_usb.rules create mode 100755 misc/usb_add_change create mode 100755 misc/usb_remove diff --git a/misc/qubes_usb.rules b/misc/qubes_usb.rules new file mode 100644 index 0000000..5b3c875 --- /dev/null +++ b/misc/qubes_usb.rules @@ -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" diff --git a/misc/usb_add_change b/misc/usb_add_change new file mode 100755 index 0000000..fa9c15f --- /dev/null +++ b/misc/usb_add_change @@ -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" diff --git a/misc/usb_remove b/misc/usb_remove new file mode 100755 index 0000000..ea66b7c --- /dev/null +++ b/misc/usb_remove @@ -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" +