|
|
|
|
|
|
|
|
|
|
xen-devel
[Xen-devel] block-iscsi RFC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
This version of block-iscsi is partly based on the work of Kurt Garloff.
But his code wasn't in a working state any more, and my own version was
working but used an stupid syntax based on udev.
I would like to have some feedback, maybe how the bash script can be
prettified.
Stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHnkeNYH1+F2Rqwn0RCpuxAKCQ26kxpnuD7bYOZgCzCoxo/riUEQCfdyN5
9+gc0d5tNcLbcDXsxVjJdSc=
=y/ip
-----END PGP SIGNATURE-----
#!/bin/bash
# Usage: block-iscsi
dir=$(dirname "$0")
. "$dir/block-common.sh"
# echo "DBG:xen/scripts/block-iscsi $1 $2 XENBUS_PATH=$XENBUS_PATH $par $node"
>> /tmp/output.tmp
find_sdev()
{
unset dev
for session in /sys/class/iscsi_session/session*; do
if [ "$1" = "`cat $session/targetname`" ]; then
dev=`readlink $session/device/target*/*:0:*/block*`
dev=${dev##*/}
return
fi
done
}
find_sdev_rev()
{
unset tgt
for session in /sys/class/iscsi_session/session*; do
dev=`readlink $session/device/target*/*:0:*/block*`
dev=${dev##*/}
if [ "$dev" = "$1" ]; then
tgt=`cat $session/targetname`
return
fi
done
}
case "$command" in
add)
# list of targets on node
/usr/sbin/iscsiadm -m discovery | sed "s/ .*//g" | while read line; do
/usr/sbin/iscsiadm -m discovery -t sendtargets -p $line; done >/dev/null
par=`xenstore-read $XENBUS_PATH/params` || true
TGTID=`echo $par | sed "s/\/\///g"`
while read rec uuid; do
if [ "$uuid" = "$TGTID" ]; then
find_sdev $TGTID
if [ -z "$dev" ]; then
/usr/sbin/iscsiadm -m node -T $uuid -p $rec --login || exit 2
sleep 4
find_sdev $TGTID
fi
xenstore-write $XENBUS_PATH/node /dev/$dev
write_dev /dev/$dev
exit 0
fi
done < <(/usr/sbin/iscsiadm -m node)
exit 1
;;
remove)
node=`xenstore-read $XENBUS_PATH/node` || true
dev=$node; dev=${dev#/dev/}
find_sdev_rev $dev
if [ -x /sbin/blockdev -a -n "$node"; then blockdev --flushbufs "$node" ];
fi
test -z "$tgt" && exit 2
/usr/sbin/iscsiadm -m node -T $tgt --logout
exit 1
;;
esac
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
<Prev in Thread] |
Current Thread |
[Next in Thread> |
- [Xen-devel] block-iscsi RFC,
Stefan de Konink <=
|
|
|
|
|