diff --git a/zconf/lstape b/zconf/lstape index 3c779751..e2410e1b 100755 --- a/zconf/lstape +++ b/zconf/lstape @@ -223,6 +223,24 @@ function SysfsCreateListCCW() { ' | sort } +# handle SCSI device not necessarily zfcp-attached, e.g. virtio-scsi-ccw +function SCSISearchCCWBusid() +{ + local SCSI_DEV=$1 + local SDEVCAN=$(readlink -e $SCSI_DEV) + while [ -n "$SDEVCAN" ]; do + # ascend to parent: strip last path part + SDEVCAN=${SDEVCAN%/*} + [ -h $SDEVCAN/subsystem ] || continue + local SUBSYSTEM=$(readlink -e $SDEVCAN/subsystem) + if [ "${SUBSYSTEM##*/}" = "ccw" ]; then + echo ${SDEVCAN##*/} + return + fi + done + echo "N/A" +} + function SysfsCreateListSCSI() { for SCSI_DEV in $1/bus/scsi/devices/*:*:*:*; do @@ -335,8 +353,11 @@ function SysfsCreateListSCSI() $STATE if $VERBOSE; then - HBA_ID="N/A" - [ -r $SCSI_DEV/hba_id ] && HBA_ID=$(cat $SCSI_DEV/hba_id) + if [ -r $SCSI_DEV/hba_id ]; then + HBA_ID=$(cat $SCSI_DEV/hba_id) + else + HBA_ID=$(SCSISearchCCWBusid $SCSI_DEV) + fi WWPN="N/A" [ -r $SCSI_DEV/wwpn ] && WWPN=$(cat $SCSI_DEV/wwpn) printf "$SCSIVFORMAT" \ diff --git a/zconf/lstape.8 b/zconf/lstape.8 index 4d9f83a5..019b6e58 100644 --- a/zconf/lstape.8 +++ b/zconf/lstape.8 @@ -112,8 +112,9 @@ For SCSI devices, the --verbose option additionally displays: .TP .B HBA The device bus-ID of the FCP device +or of the virtio-scsi-ccw virtual HBA through which the tape drive is attached. -"N/A" if device is not attached through zfcp. +"N/A" if the device does not have a sysfs ancestor with subsystem ccw. .TP .B WWPN The WWPN (worldwide port name) of the tape drive in the SAN.