2023-07-26 13:09:20

by Daniel Wagner

[permalink] [raw]
Subject: [PATCH blktests v1 00/11] Switch to allowed_host

Max asked me to replace replace the 'nvme/rc: Avoid triggering host nvme-cli
autoconnect' feature with using allowed_host on the target side [1]

So while looking into this new feature, I first started to refactor existing
code so that it looks a bit more consistent. I think there is even more
potential to make it smaller, by introducing something similiar to
_nvmet_passthru_target_setup() and _nvmet_passthru_target_cleanup() for non
passthru tests. A lot of duplicated setup/cleanup code in many tests.

Except the last two patches are just refactoring patches. So if we decide to use
common target setup/cleanup helpers, I think we could add them before the last
two patches, which would make the last patch way smaller.

Daniel

[1] https://lore.kernel.org/all/[email protected]/

Daniel Wagner (11):
nvme/{003,004,005,013,046,049}: Group all variables declarations
nvme: Reorganize test preamble code section
nvme/rc: Add common subsystem nqn define
nvme: Use def_subsysnqn variable instead local variable
nvme/{041,042,043,044,045,048}: Remove local variable hostnqn and
hostid
nvme/rc: Add common file_path name define
nvme: Use def_file_path variable instead local variable
nvme/rc: Add common def_subsys_uuid define
nvme: Use def_subsys_uuid variable
nvme/rc: Add helper for adding/removing to allow list
nvme: Add explicitly host to allow_host list

tests/nvme/003 | 11 ++++----
tests/nvme/004 | 27 +++++++++++---------
tests/nvme/005 | 27 +++++++++++---------
tests/nvme/006 | 21 ++++++++-------
tests/nvme/007 | 20 ++++++---------
tests/nvme/008 | 26 +++++++++----------
tests/nvme/009 | 24 +++++++++---------
tests/nvme/010 | 26 +++++++++----------
tests/nvme/011 | 25 +++++++++---------
tests/nvme/012 | 26 +++++++++----------
tests/nvme/013 | 25 +++++++++---------
tests/nvme/014 | 26 +++++++++----------
tests/nvme/015 | 24 +++++++++---------
tests/nvme/016 | 17 ++++++-------
tests/nvme/017 | 26 ++++++++-----------
tests/nvme/018 | 24 +++++++++---------
tests/nvme/019 | 26 +++++++++----------
tests/nvme/020 | 24 +++++++++---------
tests/nvme/021 | 24 +++++++++---------
tests/nvme/022 | 24 +++++++++---------
tests/nvme/023 | 26 +++++++++----------
tests/nvme/024 | 24 +++++++++---------
tests/nvme/025 | 24 +++++++++---------
tests/nvme/026 | 24 +++++++++---------
tests/nvme/027 | 24 +++++++++---------
tests/nvme/028 | 24 +++++++++---------
tests/nvme/029 | 26 +++++++++----------
tests/nvme/030 | 19 +++++++-------
tests/nvme/031 | 14 +++++-----
tests/nvme/033 | 9 ++++---
tests/nvme/034 | 9 ++++---
tests/nvme/035 | 9 ++++---
tests/nvme/036 | 9 ++++---
tests/nvme/037 | 8 +++---
tests/nvme/038 | 6 ++---
tests/nvme/039 | 4 +--
tests/nvme/040 | 30 ++++++++++++----------
tests/nvme/041 | 50 ++++++++++++++++--------------------
tests/nvme/042 | 55 ++++++++++++++++++----------------------
tests/nvme/043 | 52 +++++++++++++++++--------------------
tests/nvme/044 | 69 +++++++++++++++++++++++---------------------------
tests/nvme/045 | 61 ++++++++++++++++++++------------------------
tests/nvme/046 | 1 +
tests/nvme/047 | 30 +++++++++++-----------
tests/nvme/048 | 46 +++++++++++++++------------------
tests/nvme/049 | 1 +
tests/nvme/rc | 30 +++++++++++++++++++---
47 files changed, 572 insertions(+), 585 deletions(-)

--
2.41.0



2023-07-26 13:09:20

by Daniel Wagner

[permalink] [raw]
Subject: [PATCH blktests v1 11/11] nvme: Add explicitly host to allow_host list

Only allow to connect to our setup target with the correct hostnqn.

Thus we have to explicitly add the test hostnqn to the test subsysnqn
allow_host list.

Signed-off-by: Daniel Wagner <[email protected]>
---
tests/nvme/004 | 2 ++
tests/nvme/005 | 4 +++-
tests/nvme/008 | 2 ++
tests/nvme/009 | 2 ++
tests/nvme/010 | 2 ++
tests/nvme/011 | 2 ++
tests/nvme/012 | 2 ++
tests/nvme/013 | 2 ++
tests/nvme/014 | 2 ++
tests/nvme/015 | 2 ++
tests/nvme/018 | 2 ++
tests/nvme/019 | 2 ++
tests/nvme/020 | 2 ++
tests/nvme/021 | 2 ++
tests/nvme/022 | 2 ++
tests/nvme/023 | 2 ++
tests/nvme/024 | 2 ++
tests/nvme/025 | 2 ++
tests/nvme/026 | 2 ++
tests/nvme/027 | 2 ++
tests/nvme/028 | 2 ++
tests/nvme/029 | 2 ++
tests/nvme/030 | 11 ++++++-----
tests/nvme/040 | 3 +++
tests/nvme/047 | 2 ++
tests/nvme/rc | 7 +++++--
26 files changed, 61 insertions(+), 8 deletions(-)

diff --git a/tests/nvme/004 b/tests/nvme/004
index 54d74b61f689..697c758d3059 100755
--- a/tests/nvme/004
+++ b/tests/nvme/004
@@ -34,6 +34,7 @@ test() {
_create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
"${def_subsys_uuid}"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -46,6 +47,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"
losetup -d "$loop_dev"
rm "${def_file_path}"

diff --git a/tests/nvme/005 b/tests/nvme/005
index e49de7d905ba..402eb01fd3d8 100755
--- a/tests/nvme/005
+++ b/tests/nvme/005
@@ -34,6 +34,7 @@ test() {
_create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
"${def_subsys_uuid}"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" ${def_subsysnqn}

@@ -46,8 +47,9 @@ test() {
_nvme_disconnect_ctrl "${nvmedev}"
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_port "${port}"
-
_remove_nvmet_subsystem "${def_subsysnqn}"
+ _remove_nvmet_host "${def_hostnqn}"
+
losetup -d "$loop_dev"
rm "${def_file_path}"

diff --git a/tests/nvme/008 b/tests/nvme/008
index 752ab30a756b..3921fc6992b2 100755
--- a/tests/nvme/008
+++ b/tests/nvme/008
@@ -32,6 +32,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -46,6 +47,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

losetup -d "${loop_dev}"

diff --git a/tests/nvme/009 b/tests/nvme/009
index 7debd837cc76..aac3c1e0f642 100755
--- a/tests/nvme/009
+++ b/tests/nvme/009
@@ -28,6 +28,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -42,6 +43,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

rm "${def_file_path}"

diff --git a/tests/nvme/010 b/tests/nvme/010
index cba711b29af8..19bb7f3fc7a7 100755
--- a/tests/nvme/010
+++ b/tests/nvme/010
@@ -32,6 +32,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -47,6 +48,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

losetup -d "${loop_dev}"

diff --git a/tests/nvme/011 b/tests/nvme/011
index ba2718d81bd9..0e54c2588bc8 100755
--- a/tests/nvme/011
+++ b/tests/nvme/011
@@ -29,6 +29,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -44,6 +45,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

rm "${def_file_path}"

diff --git a/tests/nvme/012 b/tests/nvme/012
index 629b5194435e..c6b82c821bf2 100755
--- a/tests/nvme/012
+++ b/tests/nvme/012
@@ -36,6 +36,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -50,6 +51,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

losetup -d "${loop_dev}"

diff --git a/tests/nvme/013 b/tests/nvme/013
index ca51544b82d1..441db7477d75 100755
--- a/tests/nvme/013
+++ b/tests/nvme/013
@@ -32,6 +32,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -46,6 +47,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

rm "${def_file_path}"

diff --git a/tests/nvme/014 b/tests/nvme/014
index 6d27300cfb30..3656f9399687 100755
--- a/tests/nvme/014
+++ b/tests/nvme/014
@@ -35,6 +35,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -56,6 +57,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

losetup -d "${loop_dev}"

diff --git a/tests/nvme/015 b/tests/nvme/015
index 1b3aa4aa36c2..bc04e39c628c 100755
--- a/tests/nvme/015
+++ b/tests/nvme/015
@@ -32,6 +32,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -53,6 +54,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

rm "${def_file_path}"

diff --git a/tests/nvme/018 b/tests/nvme/018
index b66056d43041..68729c3cb070 100755
--- a/tests/nvme/018
+++ b/tests/nvme/018
@@ -30,6 +30,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -50,6 +51,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

rm "${def_file_path}"

diff --git a/tests/nvme/019 b/tests/nvme/019
index b456b38d038e..33a25d52e9fd 100755
--- a/tests/nvme/019
+++ b/tests/nvme/019
@@ -34,6 +34,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -48,6 +49,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

losetup -d "${loop_dev}"

diff --git a/tests/nvme/020 b/tests/nvme/020
index ba88921d75af..f436cdc8b262 100755
--- a/tests/nvme/020
+++ b/tests/nvme/020
@@ -30,6 +30,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -44,6 +45,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

rm -f "${def_file_path}"

diff --git a/tests/nvme/021 b/tests/nvme/021
index 02ef9727ee59..5043fe4916be 100755
--- a/tests/nvme/021
+++ b/tests/nvme/021
@@ -29,6 +29,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -45,6 +46,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

rm -f "${def_file_path}"

diff --git a/tests/nvme/022 b/tests/nvme/022
index 74c12c3e0ba9..8b6f610c4894 100755
--- a/tests/nvme/022
+++ b/tests/nvme/022
@@ -29,6 +29,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -45,6 +46,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

rm -f "${def_file_path}"

diff --git a/tests/nvme/023 b/tests/nvme/023
index 413b6afa6d14..90af0338e81f 100755
--- a/tests/nvme/023
+++ b/tests/nvme/023
@@ -32,6 +32,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -48,6 +49,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

losetup -d "${loop_dev}"

diff --git a/tests/nvme/024 b/tests/nvme/024
index 1baf5487ae64..7a89ddd79fd9 100755
--- a/tests/nvme/024
+++ b/tests/nvme/024
@@ -29,6 +29,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -44,6 +45,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

rm -f "${def_file_path}"

diff --git a/tests/nvme/025 b/tests/nvme/025
index 9eecd4d4a604..90f214eff6c8 100755
--- a/tests/nvme/025
+++ b/tests/nvme/025
@@ -29,6 +29,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -45,6 +46,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

rm -f "${def_file_path}"

diff --git a/tests/nvme/026 b/tests/nvme/026
index 8a8bc58170e2..ec352acaa489 100755
--- a/tests/nvme/026
+++ b/tests/nvme/026
@@ -29,6 +29,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -45,6 +46,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

rm -f "${def_file_path}"

diff --git a/tests/nvme/027 b/tests/nvme/027
index 723e721202be..339f7605a9f5 100755
--- a/tests/nvme/027
+++ b/tests/nvme/027
@@ -29,6 +29,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -44,6 +45,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

rm -f "${def_file_path}"

diff --git a/tests/nvme/028 b/tests/nvme/028
index d4e62e8cae1c..7f387eb337f6 100755
--- a/tests/nvme/028
+++ b/tests/nvme/028
@@ -29,6 +29,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -44,6 +45,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

rm -f "${def_file_path}"

diff --git a/tests/nvme/029 b/tests/nvme/029
index b113e387f1fa..461e6c6c4454 100755
--- a/tests/nvme/029
+++ b/tests/nvme/029
@@ -65,6 +65,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"

@@ -85,6 +86,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

losetup -d "${loop_dev}"

diff --git a/tests/nvme/030 b/tests/nvme/030
index a0b999cace94..9251e1744f61 100755
--- a/tests/nvme/030
+++ b/tests/nvme/030
@@ -28,6 +28,7 @@ test() {

_create_nvmet_subsystem "${subsys}1" "$(losetup -f)"
_add_nvmet_subsys_to_port "${port}" "${subsys}1"
+ _create_nvmet_host "${subsys}1" "${def_hostnqn}"

genctr=$(_discovery_genctr)

@@ -36,13 +37,13 @@ test() {

genctr=$(_check_genctr "${genctr}" "adding a subsystem to a port")

- echo 0 > "${NVMET_CFS}/subsystems/${subsys}2/attr_allow_any_host"
+ _add_nvmet_allow_hosts "${subsys}2" "${def_hostnqn}"

- genctr=$(_check_genctr "${genctr}" "clearing attr_allow_any_host")
+ genctr=$(_check_genctr "${genctr}" "adding host to allow_hosts")

- echo 1 > "${NVMET_CFS}/subsystems/${subsys}2/attr_allow_any_host"
+ _remove_nvmet_allow_hosts "${subsys}2" "${def_hostnqn}"

- genctr=$(_check_genctr "${genctr}" "setting attr_allow_any_host")
+ genctr=$(_check_genctr "${genctr}" "removing host from allow_hosts")

_remove_nvmet_subsystem_from_port "${port}" "${subsys}2"
_remove_nvmet_subsystem "${subsys}2"
@@ -51,8 +52,8 @@ test() {

_remove_nvmet_subsystem_from_port "${port}" "${subsys}1"
_remove_nvmet_subsystem "${subsys}1"
-
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

echo "Test complete"
}
diff --git a/tests/nvme/040 b/tests/nvme/040
index 452ecd690edf..1a9be5c9342c 100755
--- a/tests/nvme/040
+++ b/tests/nvme/040
@@ -32,6 +32,8 @@ test() {
port="$(_create_nvmet_port "${nvme_trtype}")"
_create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
udevadm settle
nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
@@ -56,6 +58,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

losetup -d "${loop_dev}"

diff --git a/tests/nvme/047 b/tests/nvme/047
index 2b81f7ea9ffd..1da24b5638a6 100755
--- a/tests/nvme/047
+++ b/tests/nvme/047
@@ -35,6 +35,7 @@ test() {
"${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
--nr-write-queues 1 || echo FAIL
@@ -57,6 +58,7 @@ test() {
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_subsystem "${def_subsysnqn}"
_remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"

losetup -d "${loop_dev}"

diff --git a/tests/nvme/rc b/tests/nvme/rc
index 706f95d74a4b..0000254da731 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -608,7 +608,7 @@ _create_nvmet_subsystem() {
local cfs_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}"

mkdir -p "${cfs_path}"
- echo 1 > "${cfs_path}/attr_allow_any_host"
+ echo 0 > "${cfs_path}/attr_allow_any_host"
_create_nvmet_ns "${nvmet_subsystem}" "1" "${blkdev}" "${uuid}"
}

@@ -679,7 +679,7 @@ _create_nvmet_passthru() {
local passthru_path="${subsys_path}/passthru"

mkdir -p "${subsys_path}"
- echo 1 > "${subsys_path}/attr_allow_any_host"
+ echo 0 > "${subsys_path}/attr_allow_any_host"

_test_dev_nvme_ctrl > "${passthru_path}/device_path"
echo 1 > "${passthru_path}/enable"
@@ -694,6 +694,7 @@ _remove_nvmet_passhtru() {
local passthru_path="${subsys_path}/passthru"

echo 0 > "${passthru_path}/enable"
+ rm -f "${subsys_path}"/allowed_hosts/*
rmdir "${subsys_path}"
}

@@ -785,6 +786,7 @@ _nvmet_passthru_target_setup() {
_create_nvmet_passthru "${subsys_name}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
+ _create_nvmet_host "${subsys_name}" "${def_hostnqn}"

echo "$port"
}
@@ -811,6 +813,7 @@ _nvmet_passthru_target_cleanup() {
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_port "${port}"
_remove_nvmet_passhtru "${subsys_name}"
+ _remove_nvmet_host "${def_hostnqn}"
}

_discovery_genctr() {
--
2.41.0


2023-07-26 13:37:48

by Daniel Wagner

[permalink] [raw]
Subject: [PATCH blktests v1 09/11] nvme: Use def_subsys_uuid variable

As all tests are using the same subsys uuid name anyway, use
the def_subsys_uuid variable.

Signed-off-by: Daniel Wagner <[email protected]>
---
tests/nvme/004 | 2 +-
tests/nvme/005 | 2 +-
tests/nvme/006 | 2 +-
tests/nvme/007 | 2 +-
tests/nvme/008 | 2 +-
tests/nvme/009 | 2 +-
tests/nvme/010 | 2 +-
tests/nvme/011 | 2 +-
tests/nvme/012 | 2 +-
tests/nvme/013 | 2 +-
tests/nvme/014 | 2 +-
tests/nvme/015 | 2 +-
tests/nvme/017 | 2 +-
tests/nvme/018 | 2 +-
tests/nvme/019 | 2 +-
tests/nvme/020 | 2 +-
tests/nvme/021 | 2 +-
tests/nvme/022 | 2 +-
tests/nvme/023 | 2 +-
tests/nvme/024 | 2 +-
tests/nvme/025 | 2 +-
tests/nvme/026 | 2 +-
tests/nvme/027 | 2 +-
tests/nvme/028 | 2 +-
tests/nvme/029 | 2 +-
tests/nvme/041 | 2 +-
tests/nvme/047 | 2 +-
tests/nvme/048 | 2 +-
28 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/tests/nvme/004 b/tests/nvme/004
index 78b11c7b84c5..54d74b61f689 100755
--- a/tests/nvme/004
+++ b/tests/nvme/004
@@ -32,7 +32,7 @@ test() {
loop_dev="$(losetup -f --show "${def_file_path}")"

_create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
diff --git a/tests/nvme/005 b/tests/nvme/005
index f4d47b123ff3..e49de7d905ba 100755
--- a/tests/nvme/005
+++ b/tests/nvme/005
@@ -32,7 +32,7 @@ test() {
loop_dev="$(losetup -f --show "${def_file_path}")"

_create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

_nvme_connect_subsys "${nvme_trtype}" ${def_subsysnqn}
diff --git a/tests/nvme/006 b/tests/nvme/006
index f31633825a70..910204aaeb90 100755
--- a/tests/nvme/006
+++ b/tests/nvme/006
@@ -28,7 +28,7 @@ test() {
loop_dev="$(losetup -f --show "${def_file_path}")"

_create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/007 b/tests/nvme/007
index b6a4bc437103..db00bdcc2d08 100755
--- a/tests/nvme/007
+++ b/tests/nvme/007
@@ -24,7 +24,7 @@ test() {
truncate -s "${nvme_img_size}" "${def_file_path}"

_create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/008 b/tests/nvme/008
index a38926ef0051..752ab30a756b 100755
--- a/tests/nvme/008
+++ b/tests/nvme/008
@@ -29,7 +29,7 @@ test() {
loop_dev="$(losetup -f --show "${def_file_path}")"

_create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/009 b/tests/nvme/009
index 2c8ea7ead9b8..7debd837cc76 100755
--- a/tests/nvme/009
+++ b/tests/nvme/009
@@ -25,7 +25,7 @@ test() {
truncate -s "${nvme_img_size}" "${def_file_path}"

_create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/010 b/tests/nvme/010
index 81f7d2024ee6..cba711b29af8 100755
--- a/tests/nvme/010
+++ b/tests/nvme/010
@@ -29,7 +29,7 @@ test() {
loop_dev="$(losetup -f --show "${def_file_path}")"

_create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/011 b/tests/nvme/011
index e6f78867e283..ba2718d81bd9 100755
--- a/tests/nvme/011
+++ b/tests/nvme/011
@@ -26,7 +26,7 @@ test() {
truncate -s "${nvme_img_size}" "${def_file_path}"

_create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/012 b/tests/nvme/012
index 85549c25a1c6..629b5194435e 100755
--- a/tests/nvme/012
+++ b/tests/nvme/012
@@ -33,7 +33,7 @@ test() {
loop_dev="$(losetup -f --show "${def_file_path}")"

_create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/013 b/tests/nvme/013
index 355bc2e03557..ca51544b82d1 100755
--- a/tests/nvme/013
+++ b/tests/nvme/013
@@ -29,7 +29,7 @@ test() {
truncate -s "${nvme_img_size}" "${def_file_path}"

_create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/014 b/tests/nvme/014
index 44ae91e2210f..6d27300cfb30 100755
--- a/tests/nvme/014
+++ b/tests/nvme/014
@@ -32,7 +32,7 @@ test() {
loop_dev="$(losetup -f --show "${def_file_path}")"

_create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/015 b/tests/nvme/015
index 16e41ee65d42..1b3aa4aa36c2 100755
--- a/tests/nvme/015
+++ b/tests/nvme/015
@@ -29,7 +29,7 @@ test() {
truncate -s "${nvme_img_size}" "${def_file_path}"

_create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/017 b/tests/nvme/017
index 7cbf274c13b0..aa0a3fefae90 100755
--- a/tests/nvme/017
+++ b/tests/nvme/017
@@ -26,7 +26,7 @@ test() {
local genctr=1

_create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"

for ((i = 2; i <= iterations; i++)); do
_create_nvmet_ns "${def_subsysnqn}" "${i}" "${def_file_path}"
diff --git a/tests/nvme/018 b/tests/nvme/018
index d1d2082e62ac..b66056d43041 100755
--- a/tests/nvme/018
+++ b/tests/nvme/018
@@ -27,7 +27,7 @@ test() {
truncate -s "${nvme_img_size}" "${def_file_path}"

_create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/019 b/tests/nvme/019
index 2628dea55ac8..b456b38d038e 100755
--- a/tests/nvme/019
+++ b/tests/nvme/019
@@ -31,7 +31,7 @@ test() {
loop_dev="$(losetup -f --show "${def_file_path}")"

_create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/020 b/tests/nvme/020
index 4a4f3c12da30..ba88921d75af 100755
--- a/tests/nvme/020
+++ b/tests/nvme/020
@@ -27,7 +27,7 @@ test() {
truncate -s "${nvme_img_size}" "${def_file_path}"

_create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/021 b/tests/nvme/021
index 11f82d64f378..02ef9727ee59 100755
--- a/tests/nvme/021
+++ b/tests/nvme/021
@@ -26,7 +26,7 @@ test() {
truncate -s "${nvme_img_size}" "${def_file_path}"

_create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/022 b/tests/nvme/022
index 586f6cdd3448..74c12c3e0ba9 100755
--- a/tests/nvme/022
+++ b/tests/nvme/022
@@ -26,7 +26,7 @@ test() {
truncate -s "${nvme_img_size}" "${def_file_path}"

_create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/023 b/tests/nvme/023
index b13426cf5615..413b6afa6d14 100755
--- a/tests/nvme/023
+++ b/tests/nvme/023
@@ -29,7 +29,7 @@ test() {
loop_dev="$(losetup -f --show "${def_file_path}")"

_create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/024 b/tests/nvme/024
index b7c7b3f64321..1baf5487ae64 100755
--- a/tests/nvme/024
+++ b/tests/nvme/024
@@ -26,7 +26,7 @@ test() {
truncate -s "${nvme_img_size}" "${def_file_path}"

_create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/025 b/tests/nvme/025
index 04ceace5840b..9eecd4d4a604 100755
--- a/tests/nvme/025
+++ b/tests/nvme/025
@@ -26,7 +26,7 @@ test() {
truncate -s "${nvme_img_size}" "${def_file_path}"

_create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/026 b/tests/nvme/026
index a9dc7bc15db5..8a8bc58170e2 100755
--- a/tests/nvme/026
+++ b/tests/nvme/026
@@ -26,7 +26,7 @@ test() {
truncate -s "${nvme_img_size}" "${def_file_path}"

_create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/027 b/tests/nvme/027
index fda8c61405a5..723e721202be 100755
--- a/tests/nvme/027
+++ b/tests/nvme/027
@@ -26,7 +26,7 @@ test() {
truncate -s "${nvme_img_size}" "${def_file_path}"

_create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/028 b/tests/nvme/028
index 8e42ea37a634..d4e62e8cae1c 100755
--- a/tests/nvme/028
+++ b/tests/nvme/028
@@ -26,7 +26,7 @@ test() {
truncate -s "${nvme_img_size}" "${def_file_path}"

_create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/029 b/tests/nvme/029
index 7988faf5dd03..b113e387f1fa 100755
--- a/tests/nvme/029
+++ b/tests/nvme/029
@@ -62,7 +62,7 @@ test() {
loop_dev="$(losetup -f --show "${def_file_path}")"

_create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/041 b/tests/nvme/041
index 0a0700533b7b..cb2766619b0e 100755
--- a/tests/nvme/041
+++ b/tests/nvme/041
@@ -37,7 +37,7 @@ test() {
truncate -s "${nvme_img_size}" "${def_file_path}"

_create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "b92842df-a394-44b1-84a4-92ae7d112861"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
_create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}" "${hostkey}"
diff --git a/tests/nvme/047 b/tests/nvme/047
index 66032f679ae2..2b81f7ea9ffd 100755
--- a/tests/nvme/047
+++ b/tests/nvme/047
@@ -32,7 +32,7 @@ test() {
loop_dev="$(losetup -f --show "${def_file_path}")"

_create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

diff --git a/tests/nvme/048 b/tests/nvme/048
index 6a05feae9b82..19234a5b3791 100755
--- a/tests/nvme/048
+++ b/tests/nvme/048
@@ -92,7 +92,7 @@ test() {
truncate -s "${nvme_img_size}" "${def_file_path}"

_create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "b92842df-a394-44b1-84a4-92ae7d112861"
+ "${def_subsys_uuid}"
port="$(_create_nvmet_port "${nvme_trtype}")"

_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
--
2.41.0


2023-07-26 13:46:30

by Daniel Wagner

[permalink] [raw]
Subject: [PATCH blktests v1 06/11] nvme/rc: Add common file_path name define

Add common file_path name as global definition so that we can reuse it.

Signed-off-by: Daniel Wagner <[email protected]>
---
tests/nvme/rc | 1 +
1 file changed, 1 insertion(+)

diff --git a/tests/nvme/rc b/tests/nvme/rc
index c11848b59c49..9c802ddc872d 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -17,6 +17,7 @@ def_local_wwpn="0x20001100aa000002"
def_hostid="0f01fb42-9f7f-4856-b0b3-51e60b8de349"
def_hostnqn="nqn.2014-08.org.nvmexpress:uuid:${def_hostid}"
def_subsysnqn="blktests-subsystem-1"
+def_file_path="${TMPDIR}/img"
nvme_trtype=${nvme_trtype:-"loop"}
nvme_img_size=${nvme_img_size:-"1G"}
nvme_num_iter=${nvme_num_iter:-"1000"}
--
2.41.0


2023-07-26 14:01:18

by Daniel Wagner

[permalink] [raw]
Subject: [PATCH blktests v1 08/11] nvme/rc: Add common def_subsys_uuid define

Add common subsys uuid as global definition so that we can reuse it.

Signed-off-by: Daniel Wagner <[email protected]>
---
tests/nvme/rc | 1 +
1 file changed, 1 insertion(+)

diff --git a/tests/nvme/rc b/tests/nvme/rc
index 9c802ddc872d..7f5829a2e58d 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -17,6 +17,7 @@ def_local_wwpn="0x20001100aa000002"
def_hostid="0f01fb42-9f7f-4856-b0b3-51e60b8de349"
def_hostnqn="nqn.2014-08.org.nvmexpress:uuid:${def_hostid}"
def_subsysnqn="blktests-subsystem-1"
+def_subsys_uuid="91fdba0d-f87b-4c25-b80f-db7be1418b9e"
def_file_path="${TMPDIR}/img"
nvme_trtype=${nvme_trtype:-"loop"}
nvme_img_size=${nvme_img_size:-"1G"}
--
2.41.0


2023-07-28 09:08:00

by Shinichiro Kawasaki

[permalink] [raw]
Subject: Re: [PATCH blktests v1 00/11] Switch to allowed_host

On Jul 26, 2023 / 14:46, Daniel Wagner wrote:
> Max asked me to replace replace the 'nvme/rc: Avoid triggering host nvme-cli
> autoconnect' feature with using allowed_host on the target side [1]
>
> So while looking into this new feature, I first started to refactor existing
> code so that it looks a bit more consistent. I think there is even more
> potential to make it smaller, by introducing something similiar to
> _nvmet_passthru_target_setup() and _nvmet_passthru_target_cleanup() for non
> passthru tests. A lot of duplicated setup/cleanup code in many tests.

Thanks for this action :)

>
> Except the last two patches are just refactoring patches. So if we decide to use
> common target setup/cleanup helpers, I think we could add them before the last
> two patches, which would make the last patch way smaller.

I ran 'make check' and saw shellecheck complaints below. I added 'export' to the
variables then they disappeared.

tests/nvme/rc:19:1: warning: def_subsysnqn appears unused. Verify use (or export if used externally). [SC2034]
tests/nvme/rc:20:1: warning: def_file_path appears unused. Verify use (or export if used externally). [SC2034]
tests/nvme/rc:21:1: warning: def_file_path appears unused. Verify use (or export if used externally). [SC2034]

I also ran nvme tests with the export fixes and saw no regression. Looks good
from test run point of view.

2023-07-28 09:44:06

by Daniel Wagner

[permalink] [raw]
Subject: Re: [PATCH blktests v1 11/11] nvme: Add explicitly host to allow_host list

On Fri, Jul 28, 2023 at 08:15:45AM +0000, Shinichiro Kawasaki wrote:
> On Jul 26, 2023 / 14:46, Daniel Wagner wrote:
> > Only allow to connect to our setup target with the correct hostnqn.
> >
> > Thus we have to explicitly add the test hostnqn to the test subsysnqn
> > allow_host list.
>
> [...]
>
> > --- a/tests/nvme/030
> > +++ b/tests/nvme/030
> > @@ -28,6 +28,7 @@ test() {
> >
> > _create_nvmet_subsystem "${subsys}1" "$(losetup -f)"
> > _add_nvmet_subsys_to_port "${port}" "${subsys}1"
> > + _create_nvmet_host "${subsys}1" "${def_hostnqn}"
> >
> > genctr=$(_discovery_genctr)
> >
> > @@ -36,13 +37,13 @@ test() {
> >
> > genctr=$(_check_genctr "${genctr}" "adding a subsystem to a port")
> >
> > - echo 0 > "${NVMET_CFS}/subsystems/${subsys}2/attr_allow_any_host"
> > + _add_nvmet_allow_hosts "${subsys}2" "${def_hostnqn}"
> >
> > - genctr=$(_check_genctr "${genctr}" "clearing attr_allow_any_host")
> > + genctr=$(_check_genctr "${genctr}" "adding host to allow_hosts")
> >
> > - echo 1 > "${NVMET_CFS}/subsystems/${subsys}2/attr_allow_any_host"
> > + _remove_nvmet_allow_hosts "${subsys}2" "${def_hostnqn}"
> >
> > - genctr=$(_check_genctr "${genctr}" "setting attr_allow_any_host")
> > + genctr=$(_check_genctr "${genctr}" "removing host from allow_hosts")
> >
> > _remove_nvmet_subsystem_from_port "${port}" "${subsys}2"
> > _remove_nvmet_subsystem "${subsys}2"
>
> The hunk above looks different from other changes. Is it changing test
> content slightly to meet request by Max? If so, it would be good to note
> in the commit message.

I should have explained this change in the commit message. When we use
allowed_hosts, the attr_allow_any_host feature is disabled and thus has no side
effects like updating the genctr. This makes the test fail. I opted to use
_[add|remove]_nvmet_allow_hosts to trigger the same side effect. While at it, I
also updated the logging info.

2023-07-28 10:22:24

by Daniel Wagner

[permalink] [raw]
Subject: Re: [PATCH blktests v1 00/11] Switch to allowed_host

On Fri, Jul 28, 2023 at 08:20:55AM +0000, Shinichiro Kawasaki wrote:
> > Except the last two patches are just refactoring patches. So if we decide to use
> > common target setup/cleanup helpers, I think we could add them before the last
> > two patches, which would make the last patch way smaller.
>
> I ran 'make check' and saw shellecheck complaints below. I added 'export' to the
> variables then they disappeared.
>
> tests/nvme/rc:19:1: warning: def_subsysnqn appears unused. Verify use (or export if used externally). [SC2034]
> tests/nvme/rc:20:1: warning: def_file_path appears unused. Verify use (or export if used externally). [SC2034]
> tests/nvme/rc:21:1: warning: def_file_path appears unused. Verify use (or export if used externally). [SC2034]

These variables are not used in nvme/rc at the point I introduce them. Only in
the tests. I could add the nvmet setup/cleanup helpers with the variables which
would make those warnings go away. But these helpers would then add the end of
the series. Also not really good. I don't what is best here.

> I also ran nvme tests with the export fixes and saw no regression. Looks good
> from test run point of view.

Thanks!

BTW, I am off next week, so I don't think I send soon an update.