Patch attached.

-- 
Mauricio Faria de Oliveira
From f31f72dded8c83ce14d342096773891820698585 Mon Sep 17 00:00:00 2001
From: Mauricio Faria de Oliveira <m...@canonical.com>
Date: Wed, 30 Jan 2019 17:26:59 -0200
Subject: [PATCH] Add iSCSI iBFT support to disk-detect

This patch adds support for iSCSI LUNs configured with
iBFT to disk-detect via 'disk-detect/ibft/enable=true'.

Signed-off-by: Mauricio Faria de Oliveira <m...@canonical.com>
---
 debian/changelog             |  9 +++++++++
 debian/disk-detect.templates |  6 ++++++
 disk-detect.sh               | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index a2884a045aac..01565db69aab 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+hw-detect (1.136+ibft1) unstable; urgency=medium
+
+  * disk-detect.templates: add the option
+    'disk-detect/ibft/enable' for preseed.
+  * disk-detect.sh: add support for iSCSI iBFT
+    with 'disk-detect/ibft/enable=true' option.
+
+ -- Mauricio Faria de Oliveira <m...@canonical.com>  Thu, 07 Mar 2019 15:47:55 -0300
+
 hw-detect (1.136) unstable; urgency=medium
   * Team upload
 
diff --git a/debian/disk-detect.templates b/debian/disk-detect.templates
index e42bfa2f95ae..7d4710680569 100644
--- a/debian/disk-detect.templates
+++ b/debian/disk-detect.templates
@@ -42,3 +42,9 @@ Default: false
 Description: for internal use; can be preseeded
  Check for the presence of multipath devices?
 
+Template: disk-detect/ibft/enable
+Type: boolean
+Default: false
+Description: for internal use; can be preseeded
+ Check for the presence of iSCSI devices with
+ the iSCSI Boot Firmware Table (iBFT)?
diff --git a/disk-detect.sh b/disk-detect.sh
index e97def78afa4..25d4fe807340 100755
--- a/disk-detect.sh
+++ b/disk-detect.sh
@@ -120,10 +120,44 @@ EOF
 	fi
 }
 
+iscsi_ibft_probe() {
+
+	if is_not_loaded iscsi_ibft; then
+		depmod -a >/dev/null 2>&1 || true
+		module_probe iscsi_ibft || true
+	fi
+
+	if ! log-output -t disk-detect iscsistart -f; then
+		logger -t disk-detect "Error: iBFT information not found"
+		return 1
+	fi
+
+	if ! log-output -t disk-detect iscsistart -N; then
+		logger -t disk-detect "Error: iBFT network configuration failed"
+		return 1
+	fi
+
+	if ! log-output -t disk-detect iscsistart -b; then
+		logger -t disk-detect "Error: iBFT login failed"
+		return 1
+	fi
+
+	# Done
+	update-dev --settle
+	logger -t disk-detect "iBFT disk detection finished."
+	return 0
+}
+
 if ! hw-detect disk-detect/detect_progress_title; then
 	log "hw-detect exited nonzero"
 fi
 
+# Activate support for iSCSI iBFT
+db_get disk-detect/ibft/enable
+if [ "$RET" = true ]; then
+	iscsi_ibft_probe || true
+fi
+
 while ! disk_found; do
 	CHOICES=""
 	for mod in $(list_disk_modules | sort); do
-- 
2.17.1

Reply via email to