Bug#1106420: xen-utils-common: block-iscsi script doesn't work when iqn
From
Tim Woodall@21:1/5 to
All on Sat May 24 18:40:02 2025
Package: xen-utils-common
Version: 4.17.5+23-ga4e5191dc0-1+deb12u1
Severity: normal
two issues with block-iscsi
1. If the iqn that is being used as a disk device is a prefix of an
existing in use iqn then xl create will fail with
libxl: error: libxl_device.c:1337:device_hotplug_child_death_cb: script: Device already opened
My fix is to match a space before and after the iqn.
iscsiadm -m session | grep ' iqn.xen17:trixie17 '
tcp: [32] [fd01:8b0:bfcd:100:230:18ff:fe08:5ad6]:3260,1 iqn.xen17:trixie17 (non-flash)
Without the trailing space:
iscsiadm -m session | grep 'iqn.xen17:trixie17'
tcp: [30] [fd01:8b0:bfcd:100:230:18ff:fe08:5ad6]:3260,1 iqn.xen17:trixie17-build (non-flash)
tcp: [32] [fd01:8b0:bfcd:100:230:18ff:fe08:5ad6]:3260,1 iqn.xen17:trixie17 (non-flash)
2. There's no way to specify the LUN, it seems to always want lun-0. All
of my LUNS are 1, so I've changed the default to 1 rather than 0 but it
needs an extra lun=<> parameter.
diff -u scripts/block-iscsi.distrib scripts/block-iscsi
--- scripts/block-iscsi.distrib 2022-12-29 23:12:25.000000000 +0000
+++ scripts/block-iscsi 2025-05-24 16:24:53.000000000 +0000
@@ -26,6 +26,8 @@
dir=$(dirname "$0")
. "$dir/block-common.sh"
+LUN=1
+
remove_label()
{
echo $1 | sed "s/^\("$2"\)//"
@@ -59,6 +61,9 @@
multipath=*)
multipath=$(remove_label $param "multipath=")
;;
+ lun=*)
+ LUN=$(remove_label $param "lun=")
+ ;;
esac
done
if [ -z "$iqn" ] || [ -z "$portal" ]; then
@@ -73,7 +78,7 @@
find_device()
{
count=0
- while [ ! -e /dev/disk/by-path/*"$iqn"-lun-0 ]; do
+ while [ ! -e /dev/disk/by-path/*"$iqn"-lun-"${LUN}" ]; do
sleep 1
count=`expr $count + 1`
if [ count = 100 ]; then
@@ -81,7 +86,7 @@
fatal "timeout waiting for iSCSI disk to settle"
fi
done
- sddev=$(readlink -f /dev/disk/by-path/*"$iqn"-lun-0 || true)
+ sddev=$(readlink -f /dev/disk/by-path/*"$