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

Shin'ichiro Kawasaki
2024-11-29T13:26:30Z

From: Hannes Reinecke <hare@suse.de>

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

Signed-off-by: Hannes Reinecke <hare@suse.de>
[Shin'ichiro: rebased on the commit e3fe06e and resolved conflicts]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@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