Skip to content

Commit

Permalink
CP-24532: trigger pusb scan
Browse files Browse the repository at this point in the history
add udev rule to call usb_change script when USB device change is
detected, usb_change call pusb scan if license check is OK.

Signed-off-by: Talons Lee <[email protected]>
Reviewed-by: Germano Percossi <[email protected]>
  • Loading branch information
TalonsLee authored and MarkSymsCtx committed Jan 30, 2018
1 parent f5d45df commit c3e7ef0
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ SM_LIBS += fcoelib
SM_LIBS += constants
SM_LIBS += cbtutil

UDEV_RULES = 39-multipath 40-multipath 55-xs-mpath-scsidev 58-xapi
UDEV_RULES = 39-multipath 40-multipath 55-xs-mpath-scsidev 57-usb 58-xapi
MPATH_DAEMON = sm-multipath
MPATH_CONF = multipath.conf
CIFS_CONF = cifs.conf
Expand Down Expand Up @@ -199,6 +199,7 @@ install: precheck
mkdir -p $(SM_STAGING)$(LIBEXEC)
install -m 755 scripts/local-device-change $(SM_STAGING)$(LIBEXEC)
install -m 755 scripts/check-device-sharing $(SM_STAGING)$(LIBEXEC)
install -m 755 scripts/usb_change $(SM_STAGING)$(LIBEXEC)
$(MAKE) -C dcopy install DESTDIR=$(SM_STAGING)
$(MAKE) -C snapwatchd install DESTDIR=$(SM_STAGING)
$(MAKE) -C mpathroot install DESTDIR=$(SM_STAGING)
Expand Down
21 changes: 21 additions & 0 deletions scripts/usb_change
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh
#
# Copyright (C) Citrix Systems Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; version 2.1 only.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# called by UDEV rule to trigger pusb scan, when USB device change is detected

. /etc/xensource-inventory
xe pusb-scan host-uuid=${INSTALLATION_UUID}
17 changes: 17 additions & 0 deletions udev/57-usb.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# enable the following line info about usb device
# SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", GOTO="label_usb"
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_interface", GOTO="label_usb"
# enable the following line info about usb block disk
# SUBSYSTEM=="block", SUBSYSTEMS=="usb", KERNEL!="*[0-9]", GOTO="label_usb"

GOTO="label_end_usb"

###############################################################################

LABEL="label_usb"

ACTION=="add|change|remove", RUN+="/opt/xensource/libexec/usb_change %E{DEVTYPE} %E{ACTION} %E{SEQNUM} %k"

###############################################################################

LABEL="label_end_usb"

0 comments on commit c3e7ef0

Please sign in to comment.