Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 7c62863b04
Fetching contributors…

Cannot retrieve contributors at this time

executable file 45 lines (41 sloc) 1.49 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
#!/bin/sh

TYPE=`echo ${XENBUS_PATH} | cut -f 2 -d '/'`
DOMID=`echo ${XENBUS_PATH} | cut -f 3 -d '/'`
DEVID=`echo ${XENBUS_PATH} | cut -f 4 -d '/'`

HOTPLUG=/xapi/${DOMID}/hotplug/${TYPE}/${DEVID}
HOTPLUG_STATUS="${XENBUS_PATH}/hotplug-status"

syslog ()
{
logger -tscripts-block "$*"
}

case "$1" in
add)
        params=$(xenstore-read "${XENBUS_PATH}/params")
        frontend="/local/domain/${DOMID}/device/${TYPE}/${DEVID}"
        syslog "${XENBUS_PATH}: add params=\"${params}\""
        # We don't have PV drivers for CDROM devices, so we prevent blkback
        # from opening the physical-device
xenstore-exists "${XENBUS_PATH}/no-physical-device"
        if [ $? -ne 0 ]; then
          physical_device=$(/usr/bin/stat --format="%t:%T" "${params}")
          syslog "${XENBUS_PATH}: physical-device=${physical_device}"
          xenstore-exists "${XENBUS_PATH}/physical-device"
          if [ $? -eq 1 ]; then
syslog "${XENBUS_PATH}: writing physical-device=${physical-device}"
            xenstore-write "${XENBUS_PATH}/physical-device" "${physical_device}"
          fi
        else
          syslog "${XENBUS_PATH}: not writing physical-device because no-physical-device is present"
        fi
        xenstore-write "${HOTPLUG}/hotplug" "online"
        xenstore-write "${HOTPLUG_STATUS}" "connected"
;;
change)
syslog "${XENBUS_PATH}: change"
;;
remove)
syslog "${XENBUS_PATH}: remove"
    xenstore-rm "${HOTPLUG_STATUS}"
xenstore-rm "${HOTPLUG}/hotplug"
;;
esac
Something went wrong with that request. Please try again.