[PATCH blktests 4/7] nvme/rc: add argument '--ports' to _nvmet_target_setup()

Shin'ichiro Kawasaki shinichiro.kawasaki at wdc.com
Fri Nov 29 05:26:14 PST 2024


From: Hannes Reinecke <hare at suse.de>

Add an argument '--ports' to _nvmet_target_setup() to specify the
number of ports to create.

Signed-off-by: Hannes Reinecke <hare at suse.de>
[Shin'ichiro: rebased on the commit e3fe06e and resolved conflicts]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki at wdc.com>
---
 common/nvme | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/common/nvme b/common/nvme
index 9786e4e..dfd9876 100644
--- a/common/nvme
+++ b/common/nvme
@@ -798,7 +798,8 @@ _nvmet_target_setup() {
 	local hostkey=""
 	local subsysnqn="${def_subsysnqn}"
 	local subsys_uuid
-	local port
+	local port p
+	local num_ports=1
 	local -a ARGS
 
 	while [[ $# -gt 0 ]]; do
@@ -827,6 +828,10 @@ _nvmet_target_setup() {
 				resv_enable="--resv_enable"
 				shift 1
 				;;
+			--ports)
+				num_ports="$2"
+				shift 2
+				;;
 			*)
 				echo "WARNING: unknown argument: $1"
 				shift
@@ -855,8 +860,12 @@ _nvmet_target_setup() {
 	fi
 	_create_nvmet_subsystem "${ARGS[@]}"
 
-	port="$(_create_nvmet_port)"
-	_add_nvmet_subsys_to_port "${port}" "${subsysnqn}"
+	p=0
+	while (( p < num_ports )); do
+		port="$(_create_nvmet_port)"
+		_add_nvmet_subsys_to_port "${port}" "${subsysnqn}"
+		p=$(( p + 1 ))
+	done
 	_create_nvmet_host "${subsysnqn}" "${def_hostnqn}" \
 			"${hostkey}" "${ctrlkey}"
 }
-- 
2.47.0




More information about the Linux-nvme mailing list