Skip to content

Commit

Permalink
scripts: use DEVPATH in block-frontend
Browse files Browse the repository at this point in the history
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
David Vrabel authored and Simon Rowe committed Jun 1, 2012
1 parent abf5ca8 commit 2535f7d
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions scripts/block-frontend
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down

0 comments on commit 2535f7d

Please sign in to comment.