[PATCH v1 1/2] nvme/rc: Parse optional arguments in _nvme_connect_subsys()

Daniel Wagner
2023-03-20T17:38:26Z

Extend the nvme_connect_subsys() function to parse optional arguments.
This avoids that all test have to pass in always all arguments.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
tests/nvme/rc | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)

diff --git a/tests/nvme/rc b/tests/nvme/rc
index 210a82aea384..8f4b4601c44e 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -316,6 +316,42 @@ _nvme_disconnect_subsys() {
}

_nvme_connect_subsys() {
+ local positional_args=()
+
+ local nr_io_queues=""
+ local nr_write_queues=""
+ local nr_poll_queues=""
+
+ while [[ $# -gt 0 ]]; do
+ case $1 in
+ -i|--nr-io-queues)
+ nr_io_queues="$2"
+ shift
+ shift
+ ;;
+ -W|--nr-write-queues)
+ nr_write_queues="$2"
+ shift
+ shift
+ ;;
+ -P|--nr-poll-queues)
+ nr_poll_queues="$2"
+ shift
+ shift
+ ;;
+ -*|--*)
+ echo "Unknown option $1"
+ exit 1
+ ;;
+ *)
+ positional_args+=("$1")
+ shift
+ ;;
+ esac
+ done
+
+ set -- "${positional_args[@]}"
+
local trtype="$1"
local subsysnqn="$2"
local traddr="${3:-$def_traddr}"
@@ -344,6 +380,16 @@ _nvme_connect_subsys() {
if [[ -n "${ctrlkey}" ]]; then
ARGS+=(--dhchap-ctrl-secret="${ctrlkey}")
fi
+ if [[ -n "${nr_io_queues}" ]]; then
+ ARGS+=(--nr-io-queues="${nr_io_queues}")
+ fi
+ if [[ -n "${nr_write_queues}" ]]; then
+ ARGS+=(--nr-write-queues="${nr_write_queues}")
+ fi
+ if [[ -n "${nr_poll_queues}" ]]; then
+ ARGS+=(--nr-poll-queues="${nr_poll_queues}")
+ fi
+
nvme connect "${ARGS[@]}" 2> /dev/null
}

--
2.40.0