[PATCH blktests v3 09/20] nvme/rc: add nqn/uuid args to target setup/cleanup helper
Daniel Wagner
dwagner at suse.de
Tue Mar 26 06:13:51 PDT 2024
Make these helper a bit more flexible, so that the caller
can setup not just the default subsysnqn.
Signed-off-by: Daniel Wagner <dwagner at suse.de>
---
tests/nvme/rc | 38 +++++++++++++++++++++++++++++++-------
1 file changed, 31 insertions(+), 7 deletions(-)
diff --git a/tests/nvme/rc b/tests/nvme/rc
index 535bd869bf58..7f436037eb94 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -817,6 +817,8 @@ _nvmet_target_setup() {
local blkdev
local ctrlkey=""
local hostkey=""
+ local subsysnqn="${def_subsysnqn}"
+ local subsys_uuid="${def_subsys_uuid}"
local port
while [[ $# -gt 0 ]]; do
@@ -833,6 +835,14 @@ _nvmet_target_setup() {
hostkey="$2"
shift 2
;;
+ --subsysnqn)
+ subsysnqn="$2"
+ shift 2
+ ;;
+ --subsys-uuid)
+ subsys_uuid="$2"
+ shift 2
+ ;;
*)
echo "WARNING: unknown argument: $1"
shift
@@ -847,11 +857,11 @@ _nvmet_target_setup() {
blkdev="$(_nvme_def_file_path)"
fi
- _create_nvmet_subsystem "${def_subsysnqn}" "${blkdev}" \
- "${def_subsys_uuid}"
+ _create_nvmet_subsystem "${subsysnqn}" "${blkdev}" \
+ "${subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}" \
+ _add_nvmet_subsys_to_port "${port}" "${subsysnqn}"
+ _create_nvmet_host "${subsysnqn}" "${def_hostnqn}" \
"${hostkey}" "${ctrlkey}"
}
@@ -859,14 +869,28 @@ _nvmet_target_cleanup() {
local ports
local port
local blkdev
+ local subsysnqn="${def_subsysnqn}"
+
+ while [[ $# -gt 0 ]]; do
+ case $1 in
+ --subsysnqn)
+ subsysnqn="$2"
+ shift 2
+ ;;
+ *)
+ echo "WARNING: unknown argument: $1"
+ shift
+ ;;
+ esac
+ done
- _get_nvmet_ports "${def_subsysnqn}" ports
+ _get_nvmet_ports "${subsysnqn}" ports
for port in "${ports[@]}"; do
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
+ _remove_nvmet_subsystem_from_port "${port}" "${subsysnqn}"
_remove_nvmet_port "${port}"
done
- _remove_nvmet_subsystem "${def_subsysnqn}"
+ _remove_nvmet_subsystem "${subsysnqn}"
_remove_nvmet_host "${def_hostnqn}"
_cleanup_blkdev
--
2.44.0
More information about the Linux-nvme
mailing list