800917b5a2
- Update to Xen 4.1.2_rc2 c/s 23152 - bnc#716695 - domUs using tap devices will not start updated multi-xvdp.patch - Upstream patches from Jan 23803-intel-pmu-models.patch 23800-x86_64-guest-addr-range.patch 23795-intel-ich10-quirk.patch 23804-x86-IPI-counts.patch - bnc#706106 - Inconsistent reporting of VM names during migration xend-migration-domname-fix.patch - bnc#712823 - L3:Xen guest does not start reliable when rebooted xend-vcpu-affinity-fix.patch OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=143
122 lines
3.6 KiB
Bash
122 lines
3.6 KiB
Bash
#!/bin/bash
|
|
|
|
# Usage: block-npiv [add npiv | remove dev]
|
|
|
|
dir=$(dirname "$0")
|
|
. "$dir/block-npiv-common.sh"
|
|
. "$dir/block-common.sh"
|
|
|
|
#set -x
|
|
#command=$1
|
|
|
|
case "$command" in
|
|
add)
|
|
# Params is one big arg, with fields separated by hyphens:
|
|
# single path:
|
|
# FABRIC-VPWWPN-VPWWNN-TGTWWPN-LUN#
|
|
# multipath:
|
|
# {FABRIC1.FABRIC2}-{VPWWPN1.VPWWPN2.VPWWPN3}-VPWWNN-TGTWWPN-LUN#
|
|
# arg 2 - Fabric Name
|
|
# arg 3 - VPORT's WWPN
|
|
# arg 4 - VPORT's WWNN
|
|
# arg 5 - Target's WWPN
|
|
# arg 6 - LUN # on Target
|
|
# no wwn contains a leading 0x - it is a 16 character hex value
|
|
# You may want to optionally pick a specific adapter ?
|
|
par=`xenstore-read $XENBUS_PATH/params` || true
|
|
#par=$2
|
|
NPIVARGS=$par;
|
|
LUN=${NPIVARGS##*-*-*-*-}; NPIVARGS=${NPIVARGS%-*}
|
|
if test $LUN = $NPIVARGS ; then exit 1; fi
|
|
TGTWWPN=${NPIVARGS##*-*-*-}; NPIVARGS=${NPIVARGS%-*}
|
|
if test $TGTWWPN = $NPIVARGS ; then exit 1; fi
|
|
VPORTWWNN=${NPIVARGS##*-*-}; NPIVARGS=${NPIVARGS%-*}
|
|
if test $VPORTWWNN = $NPIVARGS ; then exit 1; fi
|
|
VPORTWWPNS=${NPIVARGS##*-}; NPIVARGS=${NPIVARGS%-*}
|
|
if test $VPORTWWPNS = $NPIVARGS ; then exit 1; fi
|
|
FABRICNMS=$NPIVARGS
|
|
|
|
# Ensure we compare everything using lower-case hex characters
|
|
TGTWWPN=`echo $TGTWWPN | tr A-Z a-z`
|
|
VPORTWWPNS=`echo $VPORTWWPNS | tr A-Z a-z |sed 's/[{.}]/ /g'`
|
|
VPORTWWNN=`echo $VPORTWWNN | tr A-Z a-z`
|
|
FABRICNMS=`echo $FABRICNMS | tr A-Z a-z |sed 's/[{.}]/ /g'`
|
|
|
|
|
|
claim_lock "npiv"
|
|
paths=0
|
|
for FABRICNM in $FABRICNMS; do
|
|
for VPORTWWPN in $VPORTWWPNS; do
|
|
find_vhost $VPORTWWPN $FABRICNM
|
|
if test -z "$vhost" ; then
|
|
create_vport $FABRICNM $VPORTWWPN $VPORTWWNN
|
|
if [ $? -ne 0 ] ; then exit 2; fi
|
|
sleep 8
|
|
find_vhost $VPORTWWPN $FABRICNM
|
|
if test -z "$vhost" ; then exit 3; fi
|
|
fi
|
|
find_sdev $vhost $TGTWWPN $LUN
|
|
if test -z "$dev"; then
|
|
echo "- - -" > /sys/class/scsi_host/$vhost/scan
|
|
sleep 2
|
|
find_sdev $vhost $TGTWWPN $LUN
|
|
fi
|
|
if test -z "$dev"; then
|
|
exit 4
|
|
fi
|
|
paths=$(($paths+1))
|
|
done
|
|
done
|
|
release_lock "npiv"
|
|
|
|
if test $paths -gt 1; then
|
|
xenstore-write $XENBUS_PATH/multipath 1
|
|
/etc/init.d/multipathd start
|
|
if test $? -ne 0 ; then exit 4; fi
|
|
dm=`multipath -l /dev/$dev | grep dm | cut -f2 -d' '`
|
|
else
|
|
xenstore-write $XENBUS_PATH/multipath 0
|
|
dm=$dev
|
|
fi
|
|
|
|
if test ! -z "$dm"; then
|
|
xenstore-write $XENBUS_PATH/node /dev/$dm
|
|
write_dev /dev/$dm
|
|
exit 0
|
|
fi
|
|
|
|
exit 4
|
|
;;
|
|
|
|
remove)
|
|
node=`xenstore-read $XENBUS_PATH/node` || true
|
|
multipath=`xenstore-read $XENBUS_PATH/multipath` || true
|
|
# this is really screwy. the first delete of a lun will
|
|
# terminate the entire vport (all luns)
|
|
if test $multipath = 1; then
|
|
par=`xenstore-read $XENBUS_PATH/params` || true
|
|
NPIVARGS=$par;
|
|
FABRICNMS=${NPIVARGS%%-*}; NPIVARGS=${NPIVARGS#*-}
|
|
VPORTWWPNS=${NPIVARGS%%-*}
|
|
VPORTWWPNS=`echo $VPORTWWPNS | tr A-Z a-z |sed 's/[{.}]/ /g'`
|
|
FABRICNMS=`echo $FABRICNMS | tr A-Z a-z |sed 's/[{.}]/ /g'`
|
|
for FABRICNM in $FABRICNMS; do
|
|
for VPORTWWPN in $VPORTWWPNS; do
|
|
find_vhost $VPORTWWPN $FABRICNM
|
|
if test -z "$vhost" ; then exit 5; fi
|
|
flush_nodes_on_vhost $vhost
|
|
delete_vhost $vhost
|
|
done
|
|
done
|
|
else
|
|
dev=$node; dev=${dev#/dev/}
|
|
find_vhost_from_dev $dev
|
|
if test -z "$vhost" ; then exit 5; fi
|
|
flush_nodes_on_vhost $vhost
|
|
delete_vhost $vhost
|
|
fi
|
|
|
|
exit 0
|
|
;;
|
|
esac
|