Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

scripts: use DEVPATH in block-frontend

Newer kernels don't set PHYSDEVPATH for add/remove device uevents.
Note that this requires a kernel with CONFIG_SYSFS_DEPRECATED disabled
or DEVPATH won't contain the type and ID in the path.

Signed-off-by: Simon Rowe <simon.rowe@eu.citrix.com>
  • Loading branch information...
commit 2535f7d197db1b5171997b10c204eb6ce2f35f9d 1 parent abf5ca8
@dvrabel dvrabel authored Simon Rowe committed
Showing with 14 additions and 15 deletions.
  1. +14 −15 scripts/block-frontend
View
29 scripts/block-frontend
@@ -3,24 +3,23 @@
# Writes to the store when this domain's frontend block device appears.
# Once this happens we should be safe opening the device.
-# NB special handling of partition events:
-# If we block-attach a device and then create partitions, events are
-# generated with DEVPATHs of the form /block/xvde/xvde1 -- we ignore these
-# If we block-attach a partition directly then events are generated
-# with DEVPATHs of the form /block/xvde1 -- we act on these.
+# FIXME: The interface with xapi doesn't distinguish between the whole
+# device and any partitions so we handle them identically.
-PARTITION=`echo ${DEVPATH} | cut -f 4 -d '/'`
-if [ ! -z ${PARTITION} ]; then
- # the bad kind of partition
- exit
-fi
-
DOMID=`xenstore-read domid`
-# Extract the device type and ID from the PHYSDEVPATH eg
-# PHYSDEVPATH=/devices/xen/vbd-51728
-TYPE=`echo ${PHYSDEVPATH} | cut -f 4 -d '/' | cut -f 1 -d '-'`
-DEVID=`echo ${PHYSDEVPATH} | cut -f 2 -d '-'`
+if [ ! -z ${PHYSDEVPATH} ]; then
+ # Extract the device type and ID from the PHYSDEVPATH eg
+ # PHYSDEVPATH=/devices/xen/vbd-51728
+ TYPE=`echo ${PHYSDEVPATH} | cut -f 4 -d '/' | cut -f 1 -d '-'`
+ DEVID=`echo ${PHYSDEVPATH} | cut -f 2 -d '-'`
+else
+ # Extract the device type and ID from DEVPATH. e.g.,
+ # DEVPATH=/devices/vbd-51728/block/xvda1
+ id=$(echo ${DEVPATH} | cut -f 3 -d '/')
+ TYPE=$(echo ${id} | cut -f 1 -d '-')
+ DEVID=$(echo ${id} | cut -f 2 -d '-')
+fi
XAPI=/xapi/${DOMID}/frontend/${TYPE}/${DEVID}
Please sign in to comment.
Something went wrong with that request. Please try again.