* [PATCH blktests v2 0/9] nvme: make NVME_TARGET_CONTROL work with remote targets
@ 2026-11-18 9:26 Daniel Wagner
2026-11-18 9:26 ` [PATCH blktests v2 1/9] nvme/047: look up the namespace again after reconnecting Daniel Wagner
` (10 more replies)
0 siblings, 11 replies; 15+ messages in thread
From: Daniel Wagner @ 2026-11-18 9:26 UTC (permalink / raw)
To: Shin'ichiro Kawasaki; +Cc: linux-block, linux-nvme, Daniel Wagner
Hi all,
this series makes running the nvme tests against a remote target with
NVME_TARGET_CONTROL actually work. The first six patches of v1 have been
applied, this is the rest. It applies on top of the series that makes
tests skip when a program they need is missing.
The first two patches are fixes: nvme/047 looks up the namespace again
after reconnecting, and the nvmet target picks free service IDs for its
ports. The third is a cleanup, nvme/042 and nvme/043 iterate over the
DH-HMAC-CHAP hashes by name.
The remaining patches let tests skip instead of failing when the remote
target lacks a feature they need, including the DH-HMAC-CHAP hashes and
DH groups the target doesn't support, add port and host key support for
remote targets, and add a NetApp ONTAP target as an example of a target
that can do less than nvmet.
Tested against nvmet in a second VM, which also exported other
subsystems on its own ports, and against a NetApp ONTAP array. All tests
that can run against a remote target pass, except nvme/077 against
nvmet, which checks attr_qid_max in the local nvmet configfs. Against
the array, nvme/061 and nvme/070 fail because it refuses the reconnect
after a subsystem is deleted and doesn't support Identify CNS 07h, and
nvme/068 because the host runs a 6.4 kernel. The tests that need the
kernel target still pass with the local target.
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
Changes in v2:
- Drop the six patches that were applied.
- Fix nvme/047 to look up the namespace again after reconnecting.
- Pick free service IDs for new nvmet ports.
- Pass the TLS option in the argument array instead of an unquoted
command substitution; quoting it would pass an empty argument without
TLS. (Shin'ichiro)
- Check the features with =~, with an SC2076 exception for the literal
match. (Shin'ichiro)
- List the DH-HMAC-CHAP algorithms a target supports, iterate over them
by name in nvme/042 and nvme/043 and skip the ones the target lacks.
- Put the fixes first, then the cleanup, then the features.
- Depend on the series that makes tests skip when a program is missing.
- Link to v1: https://patch.msgid.link/20261104-nvme-target-control-v1-0-b31b40537bb4@suse.de
---
Daniel Wagner (9):
nvme/047: look up the namespace again after reconnecting
contrib/nvme-target-control: pick a free service ID for new nvmet ports
nvme/042, nvme/043: iterate over the DH-HMAC-CHAP hashes by name
nvme: skip tests that need a feature the remote target lacks
contrib/nvme-target-control: list the DH-HMAC-CHAP algorithms
nvme: skip the DH-HMAC-CHAP algorithms the target doesn't support
common/nvme: support the ports of a remote target
nvme/rc: change the host keys on a remote target
contrib/nvme-target-control: add a NetApp ONTAP target
Documentation/running-tests.md | 49 ++-
common/nvme | 88 ++++-
contrib/nvme-target-control/README.md | 72 +++-
.../nvme_target_control/target.py | 19 +
.../nvme_target_control/targets/nvmet.py | 12 +-
.../nvme_target_control/targets/nvmet.sh | 7 +-
.../nvme_target_control/targets/ontap.py | 397 +++++++++++++++++++++
contrib/nvme-target-control/tests/test_ontap.py | 357 ++++++++++++++++++
.../tests/test_target_control.py | 4 +-
tests/nvme/031 | 1 +
tests/nvme/041 | 1 +
tests/nvme/042 | 12 +-
tests/nvme/042.out | 8 +-
tests/nvme/043 | 9 +-
tests/nvme/043.out | 6 +-
tests/nvme/044 | 1 +
tests/nvme/045 | 1 +
tests/nvme/047 | 2 +
tests/nvme/057 | 1 +
tests/nvme/062 | 1 +
tests/nvme/063 | 5 +-
tests/nvme/rc | 58 +++
22 files changed, 1069 insertions(+), 42 deletions(-)
---
base-commit: 79c32fb31b7bca6a4383b749030128683cf6b6b4
change-id: 20261104-nvme-target-control-f0b239e68b29
prerequisite-change-id: 20261117-skip-missing-deps-30b4084698c4:v1
prerequisite-patch-id: 9478a4106d922c8432a4d297dcb18ed68a9c8d61
prerequisite-patch-id: 635fcb82ae72c78b84ad593a58d82315a166724d
prerequisite-patch-id: 528ad89bda84f0b0d9cbc0d38b6e1384332f86cd
prerequisite-patch-id: 2758a16b44a326eea5113ff4967e6093ad42e71c
prerequisite-patch-id: 9acbf0ff52b0b46035e4635035662cd9d9309f77
Best regards,
--
Daniel Wagner <dwagner@suse.de>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH blktests v2 1/9] nvme/047: look up the namespace again after reconnecting
2026-11-18 9:26 [PATCH blktests v2 0/9] nvme: make NVME_TARGET_CONTROL work with remote targets Daniel Wagner
@ 2026-11-18 9:26 ` Daniel Wagner
2026-11-20 11:23 ` Hannes Reinecke
2026-11-18 9:26 ` [PATCH blktests v2 2/9] contrib/nvme-target-control: pick a free service ID for new nvmet ports Daniel Wagner
` (9 subsequent siblings)
10 siblings, 1 reply; 15+ messages in thread
From: Daniel Wagner @ 2026-11-18 9:26 UTC (permalink / raw)
To: Shin'ichiro Kawasaki; +Cc: linux-block, linux-nvme, Daniel Wagner
nvme/047 keeps using the namespace name from the first connect after
reconnecting. The name can change when other controllers come and go,
and fio then fails to open the device. Look it up again after the
second connect.
Fixes: 7497d8b45817 ("nvme/047: Test different queue types for fabrics transports")
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
tests/nvme/047 | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/nvme/047 b/tests/nvme/047
index 433090f2d6f2..2aeee2f0f1aa 100755
--- a/tests/nvme/047
+++ b/tests/nvme/047
@@ -42,6 +42,8 @@ test() {
_nvme_connect_subsys --nr-write-queues 1 --nr-poll-queues 1
+ ns=$(_find_nvme_ns "${def_subsys_uuid}")
+
_run_fio_rand_io --filename="/dev/${ns}" --size="${rand_io_size}"
_nvme_disconnect_subsys >> "$FULL" 2>&1
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH blktests v2 2/9] contrib/nvme-target-control: pick a free service ID for new nvmet ports
2026-11-18 9:26 [PATCH blktests v2 0/9] nvme: make NVME_TARGET_CONTROL work with remote targets Daniel Wagner
2026-11-18 9:26 ` [PATCH blktests v2 1/9] nvme/047: look up the namespace again after reconnecting Daniel Wagner
@ 2026-11-18 9:26 ` Daniel Wagner
2026-11-18 9:26 ` [PATCH blktests v2 3/9] nvme/042, nvme/043: iterate over the DH-HMAC-CHAP hashes by name Daniel Wagner
` (8 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Daniel Wagner @ 2026-11-18 9:26 UTC (permalink / raw)
To: Shin'ichiro Kawasaki; +Cc: linux-block, linux-nvme, Daniel Wagner
The nvmet target derives the service ID from the port ID. On a target
that already has ports this clashes with existing ports, and nvme/003
connects to a service ID nothing listens on. Use the lowest free
service ID starting at trsvid instead.
Fixes: 79c32fb31b7b ("contrib: make nvme-target-control a standalone project")
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
contrib/nvme-target-control/README.md | 13 +++++++------
.../nvme_target_control/targets/nvmet.sh | 7 ++++++-
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/contrib/nvme-target-control/README.md b/contrib/nvme-target-control/README.md
index dc421b00b788..9abd7f30932d 100644
--- a/contrib/nvme-target-control/README.md
+++ b/contrib/nvme-target-control/README.md
@@ -61,12 +61,13 @@ is set, the namespace is a loop device on an image file in
subsystem, the ports which don't export another subsystem, the hosts no
other subsystem allows, and the loop device and image file.
-A new port gets the lowest free nvmet port ID N, starting at 1, and listens
-on `traddr` at service ID `trsvid` + N - 1. The first port of a target
-without other ports listens on `trsvid`. The nvmet target implements all
-port commands: `add-ports`, `add-port`, `remove-port`, `list-ports`,
-`show-port` and `set-ana`, and `set-host`, which changes the DH-CHAP keys,
-hash and DH group of the host.
+A new port gets the lowest free nvmet port ID, starting at 1, and the
+lowest service ID from `trsvid` up which no other port uses: the first
+port listens on `traddr` at `trsvid` unless another port of the target
+does. The nvmet target implements all port commands: `add-ports`,
+`add-port`, `remove-port`, `list-ports`, `show-port` and `set-ana`, and
+`set-host`, which changes the DH-CHAP keys, hash and DH group of the
+host.
| Option | Meaning |
| --- | --- |
diff --git a/contrib/nvme-target-control/nvme_target_control/targets/nvmet.sh b/contrib/nvme-target-control/nvme_target_control/targets/nvmet.sh
index 33f383eb17f0..7d6e9cd40da0 100644
--- a/contrib/nvme-target-control/nvme_target_control/targets/nvmet.sh
+++ b/contrib/nvme-target-control/nvme_target_control/targets/nvmet.sh
@@ -59,6 +59,11 @@ add_port() {
while [ -e "${cfs}/ports/${port}" ]; do
port=$((port + 1))
done
+ # The target may have other ports, take the first free service ID.
+ while cat "${cfs}"/ports/*/addr_trsvcid 2> /dev/null |
+ grep -qx "${trsvcid}"; do
+ trsvcid=$((trsvcid + 1))
+ done
case "${traddr}" in
*:*) adrfam=ipv6 ;;
*) adrfam=ipv4 ;;
@@ -68,7 +73,7 @@ add_port() {
echo "${trtype}" > "${cfs}/ports/${port}/addr_trtype"
echo "${adrfam}" > "${cfs}/ports/${port}/addr_adrfam"
echo "${traddr}" > "${cfs}/ports/${port}/addr_traddr"
- echo $((trsvcid + port - 1)) > "${cfs}/ports/${port}/addr_trsvcid"
+ echo "${trsvcid}" > "${cfs}/ports/${port}/addr_trsvcid"
case "${tls}" in
none)
;;
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH blktests v2 3/9] nvme/042, nvme/043: iterate over the DH-HMAC-CHAP hashes by name
2026-11-18 9:26 [PATCH blktests v2 0/9] nvme: make NVME_TARGET_CONTROL work with remote targets Daniel Wagner
2026-11-18 9:26 ` [PATCH blktests v2 1/9] nvme/047: look up the namespace again after reconnecting Daniel Wagner
2026-11-18 9:26 ` [PATCH blktests v2 2/9] contrib/nvme-target-control: pick a free service ID for new nvmet ports Daniel Wagner
@ 2026-11-18 9:26 ` Daniel Wagner
2026-11-28 2:31 ` Shin'ichiro Kawasaki
2026-11-18 9:26 ` [PATCH blktests v2 4/9] nvme: skip tests that need a feature the remote target lacks Daniel Wagner
` (7 subsequent siblings)
10 siblings, 1 reply; 15+ messages in thread
From: Daniel Wagner @ 2026-11-18 9:26 UTC (permalink / raw)
To: Shin'ichiro Kawasaki; +Cc: linux-block, linux-nvme, Daniel Wagner
nvme/042 iterates over the numeric hash IDs nvme-cli takes, nvme/043
over the hash names of the nvmet configfs. Add a --hash option to
_nvme_gen_kxchap_secret which takes the hash name, and use the plain
names in both tests, and in nvme/063.
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
common/nvme | 18 ++++++++++++++++++
tests/nvme/042 | 10 +++++-----
tests/nvme/042.out | 8 ++++----
tests/nvme/043 | 6 +++---
tests/nvme/043.out | 6 +++---
tests/nvme/063 | 4 ++--
6 files changed, 35 insertions(+), 17 deletions(-)
diff --git a/common/nvme b/common/nvme
index dfe85b6e281f..6fba3890b6ce 100644
--- a/common/nvme
+++ b/common/nvme
@@ -168,9 +168,27 @@ _nvme_run() {
nvme $(_nvme_cmd "$current") "$@"
}
+# Generate a DH-HMAC-CHAP secret. --hash=HASH transforms the secret with HASH:
+# none, sha256, sha384 or sha512. The other arguments go to nvme-cli.
_nvme_gen_kxchap_secret() {
+ local -a secret_args=()
+ local -A hmac_ids=([none]=0 [sha256]=1 [sha384]=2 [sha512]=3)
+
_nvme_cli_detect_version
+ while (($#)); do
+ case "$1" in
+ --hash=*)
+ secret_args+=("--hmac=${hmac_ids[${1#--hash=}]}")
+ ;;
+ *)
+ secret_args+=("$1")
+ ;;
+ esac
+ shift
+ done
+ set -- "${secret_args[@]}"
+
if ((!_is_nvme_cli_pre_v3)); then
local -a kxchap_args=()
diff --git a/tests/nvme/042 b/tests/nvme/042
index bddbd1bbfc28..7c558e287805 100755
--- a/tests/nvme/042
+++ b/tests/nvme/042
@@ -27,18 +27,18 @@ test() {
_setup_nvmet
- local hmac
+ local hash
local key_len
local hostkey
local ctrldev
_nvmet_target_setup --blkdev file
- for hmac in 0 1 2 3; do
- echo "Testing hmac ${hmac}"
- hostkey="$(_nvme_gen_kxchap_secret --hmac=${hmac} 2> /dev/null)"
+ for hash in none sha256 sha384 sha512; do
+ echo "Testing hash ${hash}"
+ hostkey="$(_nvme_gen_kxchap_secret --hash="${hash}" 2> /dev/null)"
if [ -z "$hostkey" ] ; then
- echo "couldn't generate host key for hmac ${hmac}"
+ echo "couldn't generate host key for hash ${hash}"
return 1
fi
_set_nvmet_hostkey "${def_hostnqn}" "${hostkey}"
diff --git a/tests/nvme/042.out b/tests/nvme/042.out
index 1c3fc6130696..9a9fc697b4f5 100644
--- a/tests/nvme/042.out
+++ b/tests/nvme/042.out
@@ -1,8 +1,8 @@
Running nvme/042
-Testing hmac 0
-Testing hmac 1
-Testing hmac 2
-Testing hmac 3
+Testing hash none
+Testing hash sha256
+Testing hash sha384
+Testing hash sha512
Testing key length 32
Testing key length 48
Testing key length 64
diff --git a/tests/nvme/043 b/tests/nvme/043
index ac25610a402b..f85916c842fe 100755
--- a/tests/nvme/043
+++ b/tests/nvme/043
@@ -41,18 +41,18 @@ test() {
_nvmet_target_setup --blkdev file --hostkey "${hostkey}"
- for hash in "hmac(sha256)" "hmac(sha384)" "hmac(sha512)" ; do
+ for hash in sha256 sha384 sha512; do
echo "Testing hash ${hash}"
- _set_nvmet_hash "${def_hostnqn}" "${hash}"
+ _set_nvmet_hash "${def_hostnqn}" "hmac(${hash})"
_nvme_connect_subsys --dhchap-secret "${hostkey}"
_nvme_disconnect_subsys
done
- for dhgroup in "ffdhe2048" "ffdhe3072" "ffdhe4096" "ffdhe6144" "ffdhe8192" ; do
+ for dhgroup in ffdhe2048 ffdhe3072 ffdhe4096 ffdhe6144 ffdhe8192; do
echo "Testing DH group ${dhgroup}"
diff --git a/tests/nvme/043.out b/tests/nvme/043.out
index f3f55a4449b6..c99949489070 100644
--- a/tests/nvme/043.out
+++ b/tests/nvme/043.out
@@ -1,7 +1,7 @@
Running nvme/043
-Testing hash hmac(sha256)
-Testing hash hmac(sha384)
-Testing hash hmac(sha512)
+Testing hash sha256
+Testing hash sha384
+Testing hash sha512
Testing DH group ffdhe2048
Testing DH group ffdhe3072
Testing DH group ffdhe4096
diff --git a/tests/nvme/063 b/tests/nvme/063
index feb07bf3a06c..ff8e0ab90026 100755
--- a/tests/nvme/063
+++ b/tests/nvme/063
@@ -34,7 +34,7 @@ test() {
_systemctl_start tlshd
- hostkey=$(_nvme_gen_kxchap_secret --hmac 1 2> /dev/null)
+ hostkey=$(_nvme_gen_kxchap_secret --hash=sha256 2> /dev/null)
if [ -z "$hostkey" ] ; then
echo "key generation failed"
_systemctl_stop
@@ -76,7 +76,7 @@ test() {
_nvme_disconnect_subsys
- hostkey=$(_nvme_gen_kxchap_secret --hmac 2 2> /dev/null)
+ hostkey=$(_nvme_gen_kxchap_secret --hash=sha384 2> /dev/null)
if [ -z "$hostkey" ] ; then
echo "key generation failed"
_systemctl_stop
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH blktests v2 4/9] nvme: skip tests that need a feature the remote target lacks
2026-11-18 9:26 [PATCH blktests v2 0/9] nvme: make NVME_TARGET_CONTROL work with remote targets Daniel Wagner
` (2 preceding siblings ...)
2026-11-18 9:26 ` [PATCH blktests v2 3/9] nvme/042, nvme/043: iterate over the DH-HMAC-CHAP hashes by name Daniel Wagner
@ 2026-11-18 9:26 ` Daniel Wagner
2026-11-18 9:26 ` [PATCH blktests v2 5/9] contrib/nvme-target-control: list the DH-HMAC-CHAP algorithms Daniel Wagner
` (6 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Daniel Wagner @ 2026-11-18 9:26 UTC (permalink / raw)
To: Shin'ichiro Kawasaki; +Cc: linux-block, linux-nvme, Daniel Wagner
A remote target does not have to implement the optional commands, e.g. a
storage array has fixed ports and manages the ANA state itself. Tests
that use a missing command fail instead of being skipped.
Add a _require_nvme_target_control_feature helper that checks the output
of "config --show-features", and use it in the tests that need ports,
ANA, host keys or TLS. No target lists tls yet, as blktests can't pass
a TLS key to the script.
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
Documentation/running-tests.md | 5 +++++
tests/nvme/031 | 1 +
tests/nvme/042 | 1 +
tests/nvme/043 | 1 +
tests/nvme/044 | 1 +
tests/nvme/045 | 1 +
tests/nvme/057 | 1 +
tests/nvme/062 | 1 +
tests/nvme/063 | 1 +
tests/nvme/rc | 19 +++++++++++++++++++
10 files changed, 32 insertions(+)
diff --git a/Documentation/running-tests.md b/Documentation/running-tests.md
index 095d6aa4e18e..b66bdf9cb2e8 100644
--- a/Documentation/running-tests.md
+++ b/Documentation/running-tests.md
@@ -248,6 +248,7 @@ The blktests expects that the script interface implements following
--show-trsvid
--show-subsys-uuid
--show-subsysnqn
+ --show-features
setup:
--subsysnqn SUBSYSNQN
@@ -259,6 +260,10 @@ The blktests expects that the script interface implements following
cleanup:
--subsysnqn SUBSYSNQN
+config --show-features prints the optional commands the script supports,
+e.g. add-port, set-ana or set-host, and tls if the target can set up TLS.
+blktests skips the tests which need a feature the list lacks.
+
contrib/nvme-target-control implements this interface. It configures a Linux
nvmet target over ssh and can be extended for other targets, see
contrib/nvme-target-control/README.md.
diff --git a/tests/nvme/031 b/tests/nvme/031
index cd69e8ef13ac..b12e24489740 100755
--- a/tests/nvme/031
+++ b/tests/nvme/031
@@ -21,6 +21,7 @@ requires() {
_nvme_requires
_have_loop
_require_nvme_trtype_is_fabrics
+ _require_nvme_target_control_feature add-port remove-port
}
set_conditions() {
diff --git a/tests/nvme/042 b/tests/nvme/042
index 7c558e287805..e771cb6ca4aa 100755
--- a/tests/nvme/042
+++ b/tests/nvme/042
@@ -16,6 +16,7 @@ requires() {
_require_kernel_nvme_fabrics_feature dhchap_ctrl_secret
_require_nvme_trtype_is_fabrics
_require_nvme_cli_auth
+ _require_nvme_target_control_feature set-host
}
set_conditions() {
diff --git a/tests/nvme/043 b/tests/nvme/043
index f85916c842fe..eb8f8b035f6d 100755
--- a/tests/nvme/043
+++ b/tests/nvme/043
@@ -17,6 +17,7 @@ requires() {
_require_nvme_trtype_is_fabrics
_require_nvme_cli_auth
_have_crypto_algorithm dh-generic
+ _require_nvme_target_control_feature set-host
}
set_conditions() {
diff --git a/tests/nvme/044 b/tests/nvme/044
index 1d9202143cf4..c1a48f1e3d86 100755
--- a/tests/nvme/044
+++ b/tests/nvme/044
@@ -17,6 +17,7 @@ requires() {
_require_nvme_trtype_is_fabrics
_require_nvme_cli_auth
_have_crypto_algorithm dh-generic
+ _require_nvme_target_control_feature set-host
}
set_conditions() {
diff --git a/tests/nvme/045 b/tests/nvme/045
index 78a1c607e9c6..14f4949e198e 100755
--- a/tests/nvme/045
+++ b/tests/nvme/045
@@ -18,6 +18,7 @@ requires() {
_require_nvme_trtype_is_fabrics
_require_nvme_cli_auth
_have_crypto_algorithm dh-generic
+ _require_nvme_target_control_feature set-host
}
set_conditions() {
diff --git a/tests/nvme/057 b/tests/nvme/057
index 0a5cfa4df1a8..6c45af8b5ed9 100755
--- a/tests/nvme/057
+++ b/tests/nvme/057
@@ -13,6 +13,7 @@ requires() {
_have_loop
_have_fio
_require_nvme_trtype_is_fabrics
+ _require_nvme_target_control_feature list-ports show-port set-ana
}
set_conditions() {
diff --git a/tests/nvme/062 b/tests/nvme/062
index eabe2d99bdcc..4402b848ecee 100755
--- a/tests/nvme/062
+++ b/tests/nvme/062
@@ -18,6 +18,7 @@ requires() {
_require_nvme_cli_tls
_have_libnvme_ver 1 11
_have_systemd_tlshd_service
+ _require_nvme_target_control_feature tls
}
set_conditions() {
diff --git a/tests/nvme/063 b/tests/nvme/063
index ff8e0ab90026..20aabd91ca80 100755
--- a/tests/nvme/063
+++ b/tests/nvme/063
@@ -19,6 +19,7 @@ requires() {
_require_nvme_trtype tcp
_require_nvme_cli_auth
_have_systemd_tlshd_service
+ _require_nvme_target_control_feature set-host tls
}
set_conditions() {
diff --git a/tests/nvme/rc b/tests/nvme/rc
index 8abd14eeb112..41811c033069 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -155,6 +155,25 @@ _require_remote_nvme_target() {
return 0
}
+# Skip the test if the NVME_TARGET_CONTROL target lacks one of the features,
+# the optional commands and e.g. tls, see Documentation/running-tests.md.
+_require_nvme_target_control_feature() {
+ local features feature
+
+ if [[ -z "${nvme_target_control}" ]]; then
+ return 0
+ fi
+ features=" $("${nvme_target_control}" config --show-features) "
+ for feature in "$@"; do
+ # shellcheck disable=SC2076 # match the feature literally
+ if [[ ! "${features}" =~ " ${feature} " ]]; then
+ SKIP_REASONS+=("NVME_TARGET_CONTROL target does not support ${feature}")
+ return 1
+ fi
+ done
+ return 0
+}
+
_test_dev_nvme_ctrl() {
echo "/dev/char/$(cat "${TEST_DEV_SYSFS}/device/dev")"
}
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH blktests v2 5/9] contrib/nvme-target-control: list the DH-HMAC-CHAP algorithms
2026-11-18 9:26 [PATCH blktests v2 0/9] nvme: make NVME_TARGET_CONTROL work with remote targets Daniel Wagner
` (3 preceding siblings ...)
2026-11-18 9:26 ` [PATCH blktests v2 4/9] nvme: skip tests that need a feature the remote target lacks Daniel Wagner
@ 2026-11-18 9:26 ` Daniel Wagner
2026-11-18 9:26 ` [PATCH blktests v2 6/9] nvme: skip the DH-HMAC-CHAP algorithms the target doesn't support Daniel Wagner
` (5 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Daniel Wagner @ 2026-11-18 9:26 UTC (permalink / raw)
To: Shin'ichiro Kawasaki; +Cc: linux-block, linux-nvme, Daniel Wagner
Not all targets support all DH-HMAC-CHAP hashes and DH groups, e.g.
ONTAP doesn't support SHA-384. List the ones a target supports as
features, e.g. dhchap-sha384 or dhchap-ffdhe2048, so that the tests can
check for them. The nvmet target lists all of them.
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
contrib/nvme-target-control/README.md | 11 +++++++----
.../nvme-target-control/nvme_target_control/target.py | 18 ++++++++++++++++++
.../nvme_target_control/targets/nvmet.py | 12 +++++++++++-
.../nvme-target-control/tests/test_target_control.py | 4 +++-
4 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/contrib/nvme-target-control/README.md b/contrib/nvme-target-control/README.md
index 9abd7f30932d..8afbfc0be322 100644
--- a/contrib/nvme-target-control/README.md
+++ b/contrib/nvme-target-control/README.md
@@ -118,10 +118,13 @@ channel is a subclass of `Channel` which returns the command running
The port commands and `set-host` are optional. A target implements them
by overriding `add_ports`, `add_port`, `remove_port`, `list_ports`,
`show_port`, `set_ana` and `set_host`. `config --show-features` lists the
-ones it overrides, followed by the class attribute `extra_features`, e.g.
-`tls`. blktests skips the tests which need a feature the target doesn't
-list. Without `list-ports` and `show-port`, blktests connects to `traddr`
-and `trsvid`.
+ones it overrides, followed by the class attribute `extra_features`: the
+DH-HMAC-CHAP hashes and DH groups the target supports, e.g.
+`dhchap-sha256` or `dhchap-ffdhe2048` (`dhchap_features()` builds them),
+and `tls` if it sets up TLS. blktests skips the tests which need a
+feature the target doesn't list, and the steps of nvme/042 and nvme/043
+which use an algorithm the target doesn't list. Without `list-ports` and
+`show-port`, blktests connects to `traddr` and `trsvid`.
## Development
diff --git a/contrib/nvme-target-control/nvme_target_control/target.py b/contrib/nvme-target-control/nvme_target_control/target.py
index d648826e0386..1b3576bffbbf 100644
--- a/contrib/nvme-target-control/nvme_target_control/target.py
+++ b/contrib/nvme-target-control/nvme_target_control/target.py
@@ -11,6 +11,7 @@ API, can be added as 'package.module:Class' in the [target] 'type' option.
import socket
from abc import ABC, abstractmethod
+from collections.abc import Iterable
from dataclasses import dataclass
from pathlib import Path
from typing import Any, ClassVar
@@ -23,6 +24,23 @@ DEF_SUBSYSNQN = 'blktests-subsystem-1'
DEF_SUBSYS_UUID = '91fdba0d-f87b-4c25-b80f-db7be1418b9e'
DEF_TRSVCID = '4420'
+# The DH-HMAC-CHAP hashes and DH groups, named as in the nvmet configfs
+# without hmac() around the hash
+DHCHAP_HASHES = ('sha256', 'sha384', 'sha512')
+DHCHAP_DHGROUPS = (
+ 'null',
+ 'ffdhe2048',
+ 'ffdhe3072',
+ 'ffdhe4096',
+ 'ffdhe6144',
+ 'ffdhe8192',
+)
+
+
+def dhchap_features(algorithms: Iterable[str]) -> tuple[str, ...]:
+ """Return the features for the DH-HMAC-CHAP hashes and DH groups."""
+ return tuple(f'dhchap-{alg}' for alg in algorithms)
+
@dataclass(frozen=True)
class Subsystem:
diff --git a/contrib/nvme-target-control/nvme_target_control/targets/nvmet.py b/contrib/nvme-target-control/nvme_target_control/targets/nvmet.py
index f5f2e8cc2a62..468417f2ca7e 100644
--- a/contrib/nvme-target-control/nvme_target_control/targets/nvmet.py
+++ b/contrib/nvme-target-control/nvme_target_control/targets/nvmet.py
@@ -24,7 +24,15 @@ from pathlib import Path
from typing import Any
from .. import channel
-from ..target import Port, Subsystem, Target, resolve
+from ..target import (
+ DHCHAP_DHGROUPS,
+ DHCHAP_HASHES,
+ Port,
+ Subsystem,
+ Target,
+ dhchap_features,
+ resolve,
+)
SCRIPT = Path(__file__).resolve().parent / 'nvmet.sh'
@@ -40,6 +48,8 @@ HOST_ATTRS = {
class NvmetTarget(Target):
"""Linux nvmet target."""
+ extra_features = dhchap_features(DHCHAP_HASHES + DHCHAP_DHGROUPS)
+
def __init__(self, config: dict[str, Any]) -> None:
super().__init__(config)
self.channel = channel.create(config)
diff --git a/contrib/nvme-target-control/tests/test_target_control.py b/contrib/nvme-target-control/tests/test_target_control.py
index 730d6c8a9b69..c6d8933b6212 100644
--- a/contrib/nvme-target-control/tests/test_target_control.py
+++ b/contrib/nvme-target-control/tests/test_target_control.py
@@ -160,7 +160,9 @@ type = "fake_array:RecordingTarget"
self.assertEqual(
self.show('features'),
'add-ports add-port remove-port list-ports show-port set-ana '
- 'set-host',
+ 'set-host dhchap-sha256 dhchap-sha384 dhchap-sha512 dhchap-null '
+ 'dhchap-ffdhe2048 dhchap-ffdhe3072 dhchap-ffdhe4096 '
+ 'dhchap-ffdhe6144 dhchap-ffdhe8192',
)
self.config.write_text(PLUGIN)
self.assertEqual(self.show('features'), '')
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH blktests v2 6/9] nvme: skip the DH-HMAC-CHAP algorithms the target doesn't support
2026-11-18 9:26 [PATCH blktests v2 0/9] nvme: make NVME_TARGET_CONTROL work with remote targets Daniel Wagner
` (4 preceding siblings ...)
2026-11-18 9:26 ` [PATCH blktests v2 5/9] contrib/nvme-target-control: list the DH-HMAC-CHAP algorithms Daniel Wagner
@ 2026-11-18 9:26 ` Daniel Wagner
2026-11-28 2:30 ` Shin'ichiro Kawasaki
2026-11-18 9:26 ` [PATCH blktests v2 7/9] common/nvme: support the ports of a remote target Daniel Wagner
` (4 subsequent siblings)
10 siblings, 1 reply; 15+ messages in thread
From: Daniel Wagner @ 2026-11-18 9:26 UTC (permalink / raw)
To: Shin'ichiro Kawasaki; +Cc: linux-block, linux-nvme, Daniel Wagner
The authentication tests fail against a target that can't do
DH-HMAC-CHAP, and nvme/042 and nvme/043 fail on every hash or DH group
the target doesn't support.
Skip the authentication tests if the target doesn't list dhchap-sha256,
the hash every DH-HMAC-CHAP target supports, and skip just the steps of
nvme/042 and nvme/043 for the other algorithms the target doesn't list.
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
Documentation/running-tests.md | 7 +++++--
tests/nvme/041 | 1 +
tests/nvme/042 | 3 ++-
tests/nvme/043 | 4 +++-
tests/nvme/044 | 2 +-
tests/nvme/045 | 2 +-
tests/nvme/063 | 2 +-
tests/nvme/rc | 31 +++++++++++++++++++++++++------
8 files changed, 39 insertions(+), 13 deletions(-)
diff --git a/Documentation/running-tests.md b/Documentation/running-tests.md
index b66bdf9cb2e8..d556f1d3b7cc 100644
--- a/Documentation/running-tests.md
+++ b/Documentation/running-tests.md
@@ -261,8 +261,11 @@ The blktests expects that the script interface implements following
--subsysnqn SUBSYSNQN
config --show-features prints the optional commands the script supports,
-e.g. add-port, set-ana or set-host, and tls if the target can set up TLS.
-blktests skips the tests which need a feature the list lacks.
+e.g. add-port, set-ana or set-host, the DH-HMAC-CHAP hashes and DH groups
+the target supports, e.g. dhchap-sha256 or dhchap-ffdhe2048, and tls if
+the target can set up TLS. blktests skips the tests which need a feature
+the list lacks: the authentication tests without dhchap-sha256, and
+nvme/042 and nvme/043 only the steps for the other missing algorithms.
contrib/nvme-target-control implements this interface. It configures a Linux
nvmet target over ssh and can be extended for other targets, see
diff --git a/tests/nvme/041 b/tests/nvme/041
index 9c3d9aaf4e12..2571c851be4d 100755
--- a/tests/nvme/041
+++ b/tests/nvme/041
@@ -16,6 +16,7 @@ requires() {
_require_kernel_nvme_fabrics_feature dhchap_ctrl_secret
_require_nvme_trtype_is_fabrics
_require_nvme_cli_auth
+ _require_nvme_target_control_feature dhchap-sha256
}
set_conditions() {
diff --git a/tests/nvme/042 b/tests/nvme/042
index e771cb6ca4aa..f9019e9640c4 100755
--- a/tests/nvme/042
+++ b/tests/nvme/042
@@ -16,7 +16,7 @@ requires() {
_require_kernel_nvme_fabrics_feature dhchap_ctrl_secret
_require_nvme_trtype_is_fabrics
_require_nvme_cli_auth
- _require_nvme_target_control_feature set-host
+ _require_nvme_target_control_feature set-host dhchap-sha256
}
set_conditions() {
@@ -37,6 +37,7 @@ test() {
for hash in none sha256 sha384 sha512; do
echo "Testing hash ${hash}"
+ _have_nvme_target_dhchap "${hash}" || continue
hostkey="$(_nvme_gen_kxchap_secret --hash="${hash}" 2> /dev/null)"
if [ -z "$hostkey" ] ; then
echo "couldn't generate host key for hash ${hash}"
diff --git a/tests/nvme/043 b/tests/nvme/043
index eb8f8b035f6d..695edaab9741 100755
--- a/tests/nvme/043
+++ b/tests/nvme/043
@@ -17,7 +17,7 @@ requires() {
_require_nvme_trtype_is_fabrics
_require_nvme_cli_auth
_have_crypto_algorithm dh-generic
- _require_nvme_target_control_feature set-host
+ _require_nvme_target_control_feature set-host dhchap-sha256
}
set_conditions() {
@@ -45,6 +45,7 @@ test() {
for hash in sha256 sha384 sha512; do
echo "Testing hash ${hash}"
+ _have_nvme_target_dhchap "${hash}" || continue
_set_nvmet_hash "${def_hostnqn}" "hmac(${hash})"
@@ -56,6 +57,7 @@ test() {
for dhgroup in ffdhe2048 ffdhe3072 ffdhe4096 ffdhe6144 ffdhe8192; do
echo "Testing DH group ${dhgroup}"
+ _have_nvme_target_dhchap "${dhgroup}" || continue
_set_nvmet_dhgroup "${def_hostnqn}" "${dhgroup}"
diff --git a/tests/nvme/044 b/tests/nvme/044
index c1a48f1e3d86..01a153e1f2a0 100755
--- a/tests/nvme/044
+++ b/tests/nvme/044
@@ -17,7 +17,7 @@ requires() {
_require_nvme_trtype_is_fabrics
_require_nvme_cli_auth
_have_crypto_algorithm dh-generic
- _require_nvme_target_control_feature set-host
+ _require_nvme_target_control_feature set-host dhchap-sha256
}
set_conditions() {
diff --git a/tests/nvme/045 b/tests/nvme/045
index 14f4949e198e..52d04ce40860 100755
--- a/tests/nvme/045
+++ b/tests/nvme/045
@@ -18,7 +18,7 @@ requires() {
_require_nvme_trtype_is_fabrics
_require_nvme_cli_auth
_have_crypto_algorithm dh-generic
- _require_nvme_target_control_feature set-host
+ _require_nvme_target_control_feature set-host dhchap-sha256
}
set_conditions() {
diff --git a/tests/nvme/063 b/tests/nvme/063
index 20aabd91ca80..578cb8799a6d 100755
--- a/tests/nvme/063
+++ b/tests/nvme/063
@@ -19,7 +19,7 @@ requires() {
_require_nvme_trtype tcp
_require_nvme_cli_auth
_have_systemd_tlshd_service
- _require_nvme_target_control_feature set-host tls
+ _require_nvme_target_control_feature set-host tls dhchap-sha256
}
set_conditions() {
diff --git a/tests/nvme/rc b/tests/nvme/rc
index 41811c033069..0d74c427313c 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -155,18 +155,37 @@ _require_remote_nvme_target() {
return 0
}
-# Skip the test if the NVME_TARGET_CONTROL target lacks one of the features,
-# the optional commands and e.g. tls, see Documentation/running-tests.md.
-_require_nvme_target_control_feature() {
- local features feature
+# Check if the NVME_TARGET_CONTROL target lists the feature, one of the
+# optional commands or e.g. tls, see Documentation/running-tests.md. The
+# local target has all of them.
+_have_nvme_target_control_feature() {
+ local features
if [[ -z "${nvme_target_control}" ]]; then
return 0
fi
features=" $("${nvme_target_control}" config --show-features) "
+ # shellcheck disable=SC2076 # match the feature literally
+ [[ "${features}" =~ " $1 " ]]
+}
+
+# Check if the target supports the DH-HMAC-CHAP hash or DH group, e.g. sha384
+# or ffdhe2048, and log it if it doesn't. Every target which can do
+# DH-HMAC-CHAP supports sha256, a secret with hash none needs no support.
+_have_nvme_target_dhchap() {
+ if [[ "$1" == none ]] || _have_nvme_target_control_feature "dhchap-$1"; then
+ return 0
+ fi
+ echo "Target lacks $1, skipped" >> "$FULL"
+ return 1
+}
+
+# Skip the test if the NVME_TARGET_CONTROL target lacks one of the features.
+_require_nvme_target_control_feature() {
+ local feature
+
for feature in "$@"; do
- # shellcheck disable=SC2076 # match the feature literally
- if [[ ! "${features}" =~ " ${feature} " ]]; then
+ if ! _have_nvme_target_control_feature "${feature}"; then
SKIP_REASONS+=("NVME_TARGET_CONTROL target does not support ${feature}")
return 1
fi
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH blktests v2 7/9] common/nvme: support the ports of a remote target
2026-11-18 9:26 [PATCH blktests v2 0/9] nvme: make NVME_TARGET_CONTROL work with remote targets Daniel Wagner
` (5 preceding siblings ...)
2026-11-18 9:26 ` [PATCH blktests v2 6/9] nvme: skip the DH-HMAC-CHAP algorithms the target doesn't support Daniel Wagner
@ 2026-11-18 9:26 ` Daniel Wagner
2026-11-18 9:26 ` [PATCH blktests v2 8/9] nvme/rc: change the host keys on " Daniel Wagner
` (3 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Daniel Wagner @ 2026-11-18 9:26 UTC (permalink / raw)
To: Shin'ichiro Kawasaki; +Cc: linux-block, linux-nvme, Daniel Wagner
The port helpers always use the local nvmet configfs, so tests that use
more than one port don't work with a remote target. Use the port
commands of the target control script instead and document them.
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
Documentation/running-tests.md | 29 +++++++++++++++++
common/nvme | 70 +++++++++++++++++++++++++++++++++++-------
2 files changed, 88 insertions(+), 11 deletions(-)
diff --git a/Documentation/running-tests.md b/Documentation/running-tests.md
index d556f1d3b7cc..8300d9aa4842 100644
--- a/Documentation/running-tests.md
+++ b/Documentation/running-tests.md
@@ -256,6 +256,8 @@ The blktests expects that the script interface implements following
--hostnqn HOSTNQN
--ctrlkey CTRLKEY
--hostkey HOSTKEY
+ --ports NR_PORTS
+ --tls | --force-tls
cleanup:
--subsysnqn SUBSYSNQN
@@ -267,6 +269,33 @@ the target can set up TLS. blktests skips the tests which need a feature
the list lacks: the authentication tests without dhchap-sha256, and
nvme/042 and nvme/043 only the steps for the other missing algorithms.
+The tests which use more than one port, or add and remove ports, also need
+the port commands. A port is named by an ID the script picks:
+
+add-ports: export the subsystem on NR_PORTS more ports, print their IDs
+ --subsysnqn SUBSYSNQN
+ --ports NR_PORTS
+ --tls | --force-tls
+
+add-port: create a port which exports no subsystem, print its ID
+ --tls | --force-tls
+
+remove-port:
+ --port PORT
+
+list-ports: print the IDs of the ports which export the subsystem
+ --subsysnqn SUBSYSNQN
+
+show-port: print the transport type, address and service ID of the port
+ --port PORT
+
+set-ana: set the state of an ANA group on the port
+ --port PORT
+ --grpid GRPID
+ --state STATE
+
+If list-ports prints nothing, blktests connects to the address config shows.
+
contrib/nvme-target-control implements this interface. It configures a Linux
nvmet target over ssh and can be extended for other targets, see
contrib/nvme-target-control/README.md.
diff --git a/common/nvme b/common/nvme
index 6fba3890b6ce..2590b6343a27 100644
--- a/common/nvme
+++ b/common/nvme
@@ -906,20 +906,21 @@ _nvme_connect_subsys() {
esac
done
+ if [[ -z "${port}" ]]; then
+ local ports
+
+ _get_nvmet_ports "${subsysnqn}" ports
+ port="${ports[0]##*/}"
+ fi
if [[ -n "${nvme_target_control}" && -z "${port}" ]]; then
+ # The target doesn't list ports, e.g. it is configured already.
ARGS+=(--transport "$(${nvme_target_control} config --show-trtype)")
ARGS+=(--traddr "${def_traddr}")
ARGS+=(--trsvcid "${def_trsvcid}")
else
if [[ -z "${port}" ]]; then
- local ports
-
- _get_nvmet_ports "${subsysnqn}" ports
- port="${ports[0]##*/}"
- if [[ -z "${port}" ]]; then
- echo "WARNING: no port found"
- return 1
- fi
+ echo "WARNING: no port found"
+ return 1
fi
_get_nvmet_port_params "${port}" ARGS
fi
@@ -1097,6 +1098,20 @@ _fc_host_traddr() {
printf "nn-%s:pn-%s" "$(_host_wwnn $port)" "$(_host_wwpn $port)"
}
+# Add the nvme-target-control option for the TLS mode of a port to an array.
+_nvme_target_control_tls() {
+ local -n tls_args="$2"
+
+ case "$1" in
+ not-required)
+ tls_args+=(--tls)
+ ;;
+ required)
+ tls_args+=(--force-tls)
+ ;;
+ esac
+}
+
_create_nvmet_port() {
local tls="${1:-none}"
local host_port="${2:-0}"
@@ -1106,6 +1121,14 @@ _create_nvmet_port() {
local trsvcid="${def_trsvcid}"
local portcfs
+ if [[ -n "${nvme_target_control}" ]]; then
+ local -a ARGS
+
+ _nvme_target_control_tls "${tls}" ARGS
+ "${nvme_target_control}" add-port "${ARGS[@]}"
+ return
+ fi
+
local port
for ((port = 0; ; port++)); do
if [[ ! -e "${NVMET_CFS}/ports/${port}" ]]; then
@@ -1175,6 +1198,12 @@ _setup_nvmet_port_ana() {
local cfsport="${NVMET_CFS}/ports/${port}"
local anaport="${cfsport}/ana_groups/${anagrpid}"
+ if [[ -n "${nvme_target_control}" ]]; then
+ "${nvme_target_control}" set-ana --port "${port}" \
+ --grpid "${anagrpid}" --state "${anastate}"
+ return
+ fi
+
if [[ ! -d "${anaport}" ]] ; then
if [[ "${anagrpid}" -eq 1 ]]; then
echo "FAIL target setup failed, ANA not supported"
@@ -1191,6 +1220,11 @@ _remove_nvmet_port() {
local cfsport="${NVMET_CFS}/ports/${port}"
local a
+ if [[ -n "${nvme_target_control}" ]]; then
+ "${nvme_target_control}" remove-port --port "${port}"
+ return
+ fi
+
if [[ "${nvme_trtype}" == "fc" ]]; then
_nvme_fcloop_del_tport "$(_remote_wwnn "$port")" \
"$(_remote_wwpn "$port")"
@@ -1464,6 +1498,13 @@ _get_nvmet_ports() {
local -n nvmet_ports="$2"
local cfs_path="${NVMET_CFS}/ports"
+ if [[ -n "${nvme_target_control}" ]]; then
+ mapfile -t -O "${#nvmet_ports[@]}" nvmet_ports < <(
+ "${nvme_target_control}" list-ports \
+ --subsysnqn "${nvmet_subsysnqn}")
+ return
+ fi
+
for port in "${cfs_path}/"*; do
if [[ -e "${port}/subsystems/${nvmet_subsysnqn}" ]]; then
nvmet_ports+=("${port##*/}")
@@ -1491,7 +1532,12 @@ _get_nvmet_port_params() {
local trsvcid="${def_trsvcid}"
# When port is specified, get port dependent parameter values
- if [[ $port != none ]]; then
+ if [[ $port != none && -n "${nvme_target_control}" ]]; then
+ read -r trtype traddr trsvcid < <(
+ "${nvme_target_control}" show-port --port "${port}")
+ [[ -n "${trsvcid}" ]] || exit 1
+ args+=(--traddr "${traddr}")
+ elif [[ $port != none ]]; then
[[ -d "${cfs_path}" ]] || exit 1
trtype=$(cat "${cfs_path}/addr_trtype")
traddr=$(cat "${cfs_path}/addr_traddr")
@@ -1638,11 +1684,13 @@ _nvmet_target_setup() {
if [[ -n "${ctrlkey}" ]]; then
ARGS+=(--ctrlkey "${ctrlkey}")
fi
+ _nvme_target_control_tls "${tls}" ARGS
"${nvme_target_control}" setup \
--subsysnqn "${subsysnqn}" \
--subsys-uuid "${subsys_uuid:-$def_subsys_uuid}" \
--hostnqn "${def_hostnqn}" \
+ --ports "${num_ports}" \
"${ARGS[@]}" &> /dev/null
p=0
while (( p < num_ports )); do
@@ -1736,20 +1784,20 @@ _nvmet_target_add_ports() {
if [[ -n "${ctrlkey}" ]]; then
ARGS+=(--ctrlkey "${ctrlkey}")
fi
+ _nvme_target_control_tls "${tls}" ARGS
"${nvme_target_control}" add-ports \
--ports "${num_ports}" \
--subsysnqn "${subsysnqn}" \
--subsys-uuid "${subsys_uuid:-$def_subsys_uuid}" \
--hostnqn "${def_hostnqn}" \
- "${ARGS[@]}" &> /dev/null
+ "${ARGS[@]}" > /dev/null
p=0
while (( p < num_ports )); do
# Set ports_to_hosts so that _get_fc_host_port() can return the correct host port
ports_to_hosts+=("${host_port}")
p=$(( p + 1 ))
done
- echo "'${nvme_target_control} add-ports' is a stub"
return
fi
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH blktests v2 8/9] nvme/rc: change the host keys on a remote target
2026-11-18 9:26 [PATCH blktests v2 0/9] nvme: make NVME_TARGET_CONTROL work with remote targets Daniel Wagner
` (6 preceding siblings ...)
2026-11-18 9:26 ` [PATCH blktests v2 7/9] common/nvme: support the ports of a remote target Daniel Wagner
@ 2026-11-18 9:26 ` Daniel Wagner
2026-11-18 9:26 ` [PATCH blktests v2 9/9] contrib/nvme-target-control: add a NetApp ONTAP target Daniel Wagner
` (2 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Daniel Wagner @ 2026-11-18 9:26 UTC (permalink / raw)
To: Shin'ichiro Kawasaki; +Cc: linux-block, linux-nvme, Daniel Wagner
The helpers that change the DH-CHAP settings of the host write to the
local nvmet configfs, so a remote target never sees the new values. Use
the set-host command of the target control script instead and document
it.
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
Documentation/running-tests.md | 9 +++++++++
tests/nvme/rc | 20 ++++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/Documentation/running-tests.md b/Documentation/running-tests.md
index 8300d9aa4842..149b3656d7c8 100644
--- a/Documentation/running-tests.md
+++ b/Documentation/running-tests.md
@@ -296,6 +296,15 @@ set-ana: set the state of an ANA group on the port
If list-ports prints nothing, blktests connects to the address config shows.
+The authentication tests change the DH-CHAP attributes of the host:
+
+set-host:
+ --hostnqn HOSTNQN
+ --hostkey HOSTKEY
+ --ctrlkey CTRLKEY
+ --hash HASH
+ --dhgroup DHGROUP
+
contrib/nvme-target-control implements this interface. It configures a Linux
nvmet target over ssh and can be extended for other targets, see
contrib/nvme-target-control/README.md.
diff --git a/tests/nvme/rc b/tests/nvme/rc
index 0d74c427313c..47710efc5096 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -285,6 +285,11 @@ _set_nvmet_hostkey() {
local nvmet_hostkey="$2"
local cfs_path="${NVMET_CFS}/hosts/${nvmet_hostnqn}"
+ if [[ -n "${nvme_target_control}" ]]; then
+ "${nvme_target_control}" set-host --hostnqn "${nvmet_hostnqn}" \
+ --hostkey "${nvmet_hostkey}"
+ return
+ fi
_set_attr "${nvmet_hostkey}" "${cfs_path}/dhchap_key"
}
@@ -293,6 +298,11 @@ _set_nvmet_ctrlkey() {
local nvmet_ctrlkey="$2"
local cfs_path="${NVMET_CFS}/hosts/${nvmet_hostnqn}"
+ if [[ -n "${nvme_target_control}" ]]; then
+ "${nvme_target_control}" set-host --hostnqn "${nvmet_hostnqn}" \
+ --ctrlkey "${nvmet_ctrlkey}"
+ return
+ fi
_set_attr "${nvmet_ctrlkey}" "${cfs_path}/dhchap_ctrl_key"
}
@@ -301,6 +311,11 @@ _set_nvmet_hash() {
local nvmet_hash="$2"
local cfs_path="${NVMET_CFS}/hosts/${nvmet_hostnqn}"
+ if [[ -n "${nvme_target_control}" ]]; then
+ "${nvme_target_control}" set-host --hostnqn "${nvmet_hostnqn}" \
+ --hash "${nvmet_hash}"
+ return
+ fi
_set_attr "${nvmet_hash}" "${cfs_path}/dhchap_hash"
}
@@ -309,6 +324,11 @@ _set_nvmet_dhgroup() {
local nvmet_dhgroup="$2"
local cfs_path="${NVMET_CFS}/hosts/${nvmet_hostnqn}"
+ if [[ -n "${nvme_target_control}" ]]; then
+ "${nvme_target_control}" set-host --hostnqn "${nvmet_hostnqn}" \
+ --dhgroup "${nvmet_dhgroup}"
+ return
+ fi
_set_attr "${nvmet_dhgroup}" "${cfs_path}/dhchap_dhgroup"
}
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH blktests v2 9/9] contrib/nvme-target-control: add a NetApp ONTAP target
2026-11-18 9:26 [PATCH blktests v2 0/9] nvme: make NVME_TARGET_CONTROL work with remote targets Daniel Wagner
` (7 preceding siblings ...)
2026-11-18 9:26 ` [PATCH blktests v2 8/9] nvme/rc: change the host keys on " Daniel Wagner
@ 2026-11-18 9:26 ` Daniel Wagner
2026-11-20 11:25 ` [PATCH blktests v2 0/9] nvme: make NVME_TARGET_CONTROL work with remote targets Hannes Reinecke
2026-11-28 2:34 ` Shin'ichiro Kawasaki
10 siblings, 0 replies; 15+ messages in thread
From: Daniel Wagner @ 2026-11-18 9:26 UTC (permalink / raw)
To: Shin'ichiro Kawasaki; +Cc: linux-block, linux-nvme, Daniel Wagner
Add a target that configures a NetApp ONTAP storage virtual machine
through its REST API. It implements list-ports, show-port and set-host,
and shows how a target that can do less than nvmet works with the tests.
README.md documents the configuration and the limitations.
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
Documentation/running-tests.md | 3 +-
contrib/nvme-target-control/README.md | 48 +++
.../nvme_target_control/target.py | 1 +
.../nvme_target_control/targets/ontap.py | 397 +++++++++++++++++++++
contrib/nvme-target-control/tests/test_ontap.py | 357 ++++++++++++++++++
5 files changed, 805 insertions(+), 1 deletion(-)
diff --git a/Documentation/running-tests.md b/Documentation/running-tests.md
index 149b3656d7c8..6ce406a61423 100644
--- a/Documentation/running-tests.md
+++ b/Documentation/running-tests.md
@@ -306,5 +306,6 @@ If list-ports prints nothing, blktests connects to the address config shows.
--dhgroup DHGROUP
contrib/nvme-target-control implements this interface. It configures a Linux
-nvmet target over ssh and can be extended for other targets, see
+nvmet target over ssh or a NetApp ONTAP storage virtual machine through its
+REST API, and can be extended for other targets, see
contrib/nvme-target-control/README.md.
diff --git a/contrib/nvme-target-control/README.md b/contrib/nvme-target-control/README.md
index 8afbfc0be322..9111cb50db54 100644
--- a/contrib/nvme-target-control/README.md
+++ b/contrib/nvme-target-control/README.md
@@ -49,6 +49,7 @@ nothing, to run against a target which is configured already.
| Type | Target |
| --- | --- |
| `nvmet` (default) | Linux nvmet target, configured through configfs |
+| `ontap` | NetApp ONTAP storage virtual machine, through the REST API |
| `package.module:Class` | A `Target` subclass outside this package |
### nvmet
@@ -81,6 +82,53 @@ The target needs sshd, configfs, losetup and the nvmet modules for the
transport. The ssh destination may be an alias from the ssh config, `traddr`
is then its `HostName`.
+### ontap
+
+Configures a storage virtual machine (SVM) of a NetApp ONTAP cluster through
+the ONTAP REST API. blktests connects over NVMe/TCP to the LIFs of the SVM:
+
+ [target]
+ type = "ontap"
+ host = "192.0.2.100"
+ user = "admin"
+ password_file = "/root/.config/blktests/ontap-password"
+ svm = "svm1"
+ aggregate = "aggr1"
+
+The first time blktests asks for the subsystem UUID, the target creates the
+volume and the namespace `/vol/VOLUME/ns1` unless they exist. The volume
+gets no snapshots: the tests rewrite the namespace, snapshots would fill
+the volume. Setup creates the subsystem, allows the host and maps the
+namespace to it. Cleanup deletes the subsystem. The volume and namespace
+stay for the next run. The target caches the namespace UUID, the SVM UUID
+and the LIFs in `cache_dir`, and the DH-HMAC-CHAP secrets of the hosts,
+which ONTAP doesn't return.
+
+ONTAP derives the subsystem NQN from the subsystem name: `config
+--show-subsysnqn` shows the NQN of the subsystem `blktests`. The tests which
+use other NQNs need the NQN prefix of the SVM. The ports are the NVMe/TCP
+LIFs, numbered 1 to N by LIF name, each subsystem is reachable on all of
+them. The target implements `list-ports`, `show-port` and `set-host`.
+ONTAP can't modify the DH-HMAC-CHAP settings of a host: `set-host` removes
+the host and adds it again, which drops its connections. ONTAP manages the
+ANA states and doesn't support SHA-384. The target doesn't set up TLS.
+
+| Option | Meaning |
+| --- | --- |
+| `host` | cluster management address |
+| `user` | ONTAP user |
+| `password_file` | password of `user` in the first line, mode 0600 |
+| `svm` | the SVM |
+| `aggregate` | aggregate for the volume, needed if it doesn't exist |
+| `volume` | volume of the namespace, default `blktests` |
+| `volume_size` | size of a new volume, default `4G` |
+| `ns_size` | size of a new namespace, default `2G` |
+| `verify_tls` | verify the certificate of `host`, default true |
+| `cache_dir` | default `~/.cache/nvme-target-control` |
+
+The user needs the rights to manage volumes, namespaces and NVMe
+subsystems of the SVM.
+
## Adding a target
A target is a subclass of `nvme_target_control.target.Target`. It gets the
diff --git a/contrib/nvme-target-control/nvme_target_control/target.py b/contrib/nvme-target-control/nvme_target_control/target.py
index 1b3576bffbbf..1661b822e2aa 100644
--- a/contrib/nvme-target-control/nvme_target_control/target.py
+++ b/contrib/nvme-target-control/nvme_target_control/target.py
@@ -228,6 +228,7 @@ OPTIONAL_COMMANDS = {
TARGETS = {
'nvmet': 'nvme_target_control.targets.nvmet:NvmetTarget',
+ 'ontap': 'nvme_target_control.targets.ontap:OntapTarget',
}
diff --git a/contrib/nvme-target-control/nvme_target_control/targets/ontap.py b/contrib/nvme-target-control/nvme_target_control/targets/ontap.py
new file mode 100644
index 000000000000..a39c2e7ca0c0
--- /dev/null
+++ b/contrib/nvme-target-control/nvme_target_control/targets/ontap.py
@@ -0,0 +1,397 @@
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (c) 2026 SUSE LLC and contributors
+"""NetApp ONTAP storage virtual machine (SVM), through the ONTAP REST API.
+
+blktests connects over NVMe/TCP to the LIFs of the SVM. [target] options:
+
+ host cluster management address
+ user ONTAP user
+ password_file file with the password of user in the first line
+ svm the SVM
+ aggregate aggregate for the volume, needed if it doesn't exist
+ volume volume of the namespace, default 'blktests'
+ volume_size size of the volume if it is created, default 4G
+ ns_size size of the namespace if it is created, default 2G
+ verify_tls verify the certificate of host, default true
+ cache_dir default ~/.cache/nvme-target-control
+
+The first time blktests asks for the subsystem UUID, the target creates the
+volume, without snapshots, and the namespace /vol/VOLUME/ns1 unless they
+exist, and caches the namespace UUID, the SVM UUID and the LIFs. Setup
+creates an NVMe subsystem, allows the host and maps the namespace to it.
+Cleanup deletes the subsystem. The volume and namespace stay.
+
+ONTAP derives the subsystem NQN from the subsystem name and the SVM.
+'config --show-subsysnqn' shows the NQN of the subsystem 'blktests'. Other
+NQNs only work with the NQN prefix of the SVM.
+
+The ports are the NVMe/TCP LIFs, numbered 1..N by LIF name. Every
+subsystem is reachable on all of them. Ports can't be added or removed and
+ONTAP manages the ANA states. ONTAP can't modify the DH-HMAC-CHAP settings
+of a host: set-host removes the host and adds it again, which drops its
+connections. The target doesn't set up TLS.
+"""
+
+import base64
+import json
+import ssl
+import time
+import urllib.error
+import urllib.parse
+import urllib.request
+from pathlib import Path
+from typing import Any
+
+from ..target import Port, Subsystem, Target, dhchap_features
+
+NQN_PREFIX = 'nqn.1992-08.com.netapp:sn.{}:subsystem.'
+DEF_SUBSYSTEM = 'blktests'
+
+# The names blktests uses for the DH-HMAC-CHAP hash and DH group, and the
+# ones ONTAP uses. ONTAP doesn't support SHA-384.
+HASHES = {
+ 'hmac(sha256)': 'sha_256',
+ 'hmac(sha512)': 'sha_512',
+}
+DHGROUPS = {
+ 'null': 'none',
+ 'ffdhe2048': '2048_bit',
+ 'ffdhe3072': '3072_bit',
+ 'ffdhe4096': '4096_bit',
+ 'ffdhe6144': '6144_bit',
+ 'ffdhe8192': '8192_bit',
+}
+
+
+class OntapError(OSError):
+ """An ONTAP REST request failed, status is its HTTP status."""
+
+ def __init__(self, message: str, status: int = 0) -> None:
+ super().__init__(message)
+ self.status = status
+
+
+class OntapTarget(Target):
+ """NetApp ONTAP storage virtual machine with NVMe/TCP LIFs."""
+
+ extra_features = dhchap_features(
+ [h.removeprefix('hmac(').removesuffix(')') for h in HASHES]
+ + list(DHGROUPS)
+ )
+
+ def __init__(self, config: dict[str, Any]) -> None:
+ super().__init__(config)
+ self.svm = str(config['svm'])
+ self.volume = str(config.get('volume', 'blktests'))
+ self.ns_path = f'/vol/{self.volume}/ns1'
+ cache = Path(
+ config.get('cache_dir', '~/.cache/nvme-target-control')
+ ).expanduser()
+ self.cache_file = cache / f'ontap-{config["host"]}-{self.svm}.json'
+ # The DH-HMAC-CHAP settings of the hosts, by subsystem name: ONTAP
+ # doesn't return the secrets, set_host needs them.
+ self.hosts_file = self.cache_file.with_suffix('.hosts.json')
+
+ # REST
+
+ def _request(
+ self,
+ method: str,
+ path: str,
+ body: dict[str, Any] | None = None,
+ query: dict[str, str] | None = None,
+ ) -> dict[str, Any]:
+ url = f'https://{self.config["host"]}/api{path}'
+ if query:
+ url += '?' + urllib.parse.urlencode(query)
+ password = (
+ Path(self.config['password_file']).read_text().split('\n')[0]
+ )
+ auth = f'{self.config["user"]}:{password}'.encode()
+ req = urllib.request.Request(
+ url,
+ method=method,
+ data=json.dumps(body).encode() if body is not None else None,
+ headers={
+ 'Authorization': 'Basic ' + base64.b64encode(auth).decode(),
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json',
+ },
+ )
+ ctx = (
+ None
+ if self.config.get('verify_tls', True)
+ else ssl._create_unverified_context()
+ )
+ try:
+ with urllib.request.urlopen(req, context=ctx, timeout=60) as r:
+ data = r.read()
+ status = r.status
+ except urllib.error.HTTPError as e:
+ with e:
+ text = e.read().decode(errors='replace')
+ raise OntapError(
+ f'{method} {path}: {e.code} {text}', e.code
+ ) from None
+ result: dict[str, Any] = json.loads(data) if data else {}
+ if status == 202 and 'job' in result:
+ self._wait_job(result['job']['uuid'])
+ return result
+
+ def _wait_job(self, uuid: str) -> None:
+ for _ in range(300):
+ job = self._request('GET', f'/cluster/jobs/{uuid}')
+ if job['state'] == 'success':
+ return
+ if job['state'] == 'failure':
+ raise OntapError(f'job {uuid}: {job.get("message")}')
+ time.sleep(1)
+ raise OntapError(f'job {uuid} did not finish')
+
+ def _records(
+ self, path: str, query: dict[str, str]
+ ) -> list[dict[str, Any]]:
+ records: list[dict[str, Any]] = self._request(
+ 'GET', path, query={'svm.name': self.svm, **query}
+ ).get('records', [])
+ return records
+
+ # Values blktests asks for many times per test: cached
+
+ def _cache(self) -> dict[str, Any]:
+ try:
+ cache: dict[str, Any] = json.loads(self.cache_file.read_text())
+ return cache
+ except (OSError, ValueError):
+ pass
+ svm = self._request('GET', '/svm/svms', query={'name': self.svm})
+ lifs = self._records(
+ '/network/ip/interfaces',
+ {'services': 'data_nvme_tcp', 'fields': 'name,ip.address'},
+ )
+ cache = {
+ 'svm_uuid': svm['records'][0]['uuid'],
+ 'lifs': [
+ lif['ip']['address']
+ for lif in sorted(lifs, key=lambda lif: str(lif['name']))
+ ],
+ 'ns_uuid': self._namespace_uuid(),
+ }
+ self.cache_file.parent.mkdir(parents=True, exist_ok=True)
+ self.cache_file.write_text(json.dumps(cache))
+ return cache
+
+ def _namespace_uuid(self) -> str:
+ """Return the UUID of the namespace, create it first if needed."""
+ ns = self._records(
+ '/storage/namespaces', {'name': self.ns_path, 'fields': 'uuid'}
+ )
+ if ns:
+ return str(ns[0]['uuid'])
+ if not self._records('/storage/volumes', {'name': self.volume}):
+ self._request(
+ 'POST',
+ '/storage/volumes',
+ {
+ 'name': self.volume,
+ 'svm': {'name': self.svm},
+ 'aggregates': [{'name': self.config['aggregate']}],
+ 'size': self.config.get('volume_size', '4G'),
+ # The tests rewrite the namespace: snapshots of it
+ # would fill the volume and fail the writes
+ 'snapshot_policy': {'name': 'none'},
+ 'space': {'snapshot': {'reserve_percent': 0}},
+ },
+ )
+ self._request(
+ 'POST',
+ '/storage/namespaces',
+ {
+ 'svm': {'name': self.svm},
+ 'name': self.ns_path,
+ 'os_type': 'linux',
+ 'space': {'size': self.config.get('ns_size', '2G')},
+ },
+ )
+ return self._namespace_uuid()
+
+ def traddr(self) -> str:
+ return str(self._cache()['lifs'][0])
+
+ def subsysnqn(self) -> str:
+ return self._nqn_prefix() + DEF_SUBSYSTEM
+
+ def subsys_uuid(self) -> str:
+ return str(self._cache()['ns_uuid'])
+
+ def _nqn_prefix(self) -> str:
+ return NQN_PREFIX.format(self._cache()['svm_uuid'].replace('-', ''))
+
+ def _name(self, subsysnqn: str) -> str:
+ """Return the subsystem name ONTAP derives subsysnqn from."""
+ prefix = self._nqn_prefix()
+ if not subsysnqn.startswith(prefix):
+ raise OntapError(
+ f'{subsysnqn}: ONTAP subsystem NQNs start with {prefix}'
+ )
+ return subsysnqn[len(prefix) :]
+
+ # Subsystems
+
+ def _subsystem(self, name: str) -> dict[str, Any] | None:
+ subsys = self._records('/protocols/nvme/subsystems', {'name': name})
+ return subsys[0] if subsys else None
+
+ def _delete_subsystem(self, uuid: str) -> None:
+ self._request(
+ 'DELETE',
+ f'/protocols/nvme/subsystems/{uuid}',
+ query={
+ 'allow_delete_while_mapped': 'true',
+ 'allow_delete_with_hosts': 'true',
+ },
+ )
+
+ def setup(
+ self, subsys: Subsystem, nr_ports: int = 1, tls: str = 'none'
+ ) -> None:
+ if tls != 'none':
+ raise NotImplementedError('OntapTarget does not set up TLS')
+ name = self._name(subsys.nqn)
+ # A subsystem left by an aborted run would keep the namespace
+ stale = self._records(
+ '/protocols/nvme/subsystem-maps',
+ {
+ 'namespace.name': self.ns_path,
+ 'fields': 'subsystem.name,subsystem.uuid',
+ },
+ )
+ for m in stale:
+ if not m['subsystem']['name'].startswith(DEF_SUBSYSTEM):
+ raise OntapError(
+ f'{self.ns_path} is mapped to {m["subsystem"]["name"]}'
+ )
+ self._delete_subsystem(m['subsystem']['uuid'])
+
+ chap = {}
+ if subsys.hostkey:
+ chap['host_secret_key'] = subsys.hostkey
+ if subsys.ctrlkey:
+ chap['controller_secret_key'] = subsys.ctrlkey
+ self._request(
+ 'POST',
+ '/protocols/nvme/subsystems',
+ {
+ 'svm': {'name': self.svm},
+ 'name': name,
+ 'os_type': 'linux',
+ 'hosts': [self._host(subsys.hostnqn, chap)],
+ },
+ )
+ hosts = self._hosts()
+ hosts[name] = {subsys.hostnqn: chap}
+ self._save_hosts(hosts)
+ self._request(
+ 'POST',
+ '/protocols/nvme/subsystem-maps',
+ {
+ 'svm': {'name': self.svm},
+ 'subsystem': {'name': name},
+ 'namespace': {'name': self.ns_path},
+ },
+ )
+
+ def cleanup(self, subsysnqn: str) -> None:
+ name = self._name(subsysnqn)
+ subsys = self._subsystem(name)
+ if subsys:
+ self._delete_subsystem(subsys['uuid'])
+ hosts = self._hosts()
+ if hosts.pop(name, None) is not None:
+ self._save_hosts(hosts)
+
+ # Hosts
+
+ @staticmethod
+ def _host(hostnqn: str, chap: dict[str, str]) -> dict[str, Any]:
+ for field in ('host_secret_key', 'controller_secret_key'):
+ # DHHC-1:02: is a secret transformed with SHA-384
+ if chap.get(field, '').startswith('DHHC-1:02:'):
+ raise OntapError('ONTAP does not support SHA-384 secrets')
+ host: dict[str, Any] = {'nqn': hostnqn}
+ if chap:
+ host['dh_hmac_chap'] = chap
+ return host
+
+ def _hosts(self) -> dict[str, dict[str, dict[str, str]]]:
+ try:
+ hosts: dict[str, dict[str, dict[str, str]]] = json.loads(
+ self.hosts_file.read_text()
+ )
+ return hosts
+ except (OSError, ValueError):
+ return {}
+
+ def _save_hosts(self, hosts: dict[str, dict[str, dict[str, str]]]) -> None:
+ self.hosts_file.parent.mkdir(parents=True, exist_ok=True)
+ # The file holds secrets
+ self.hosts_file.touch(mode=0o600)
+ self.hosts_file.write_text(json.dumps(hosts))
+
+ def set_host(self, hostnqn: str, attrs: dict[str, str]) -> None:
+ """Change the DH-HMAC-CHAP settings of the host.
+
+ ONTAP can't modify them: remove the host from the subsystems setup
+ created and add it again. This drops the connections of the host
+ to these subsystems; the host reconnects.
+ """
+ fields = {
+ 'hostkey': ('host_secret_key', None),
+ 'ctrlkey': ('controller_secret_key', None),
+ 'hash': ('hash_function', HASHES),
+ 'dhgroup': ('group_size', DHGROUPS),
+ }
+ hosts = self._hosts()
+ for name, subsys_hosts in hosts.items():
+ if hostnqn not in subsys_hosts:
+ continue
+ # Change a copy: the host keeps its settings if one is invalid
+ chap = dict(subsys_hosts[hostnqn])
+ for attr, value in attrs.items():
+ field, names = fields[attr]
+ if not value:
+ chap.pop(field, None)
+ elif names is None:
+ chap[field] = value
+ elif value in names:
+ chap[field] = names[value]
+ else:
+ raise OntapError(f'ONTAP does not support {attr} {value}')
+ host = self._host(hostnqn, chap)
+ subsys_hosts[hostnqn] = chap
+ subsys = self._subsystem(name)
+ if not subsys:
+ continue
+ path = f'/protocols/nvme/subsystems/{subsys["uuid"]}/hosts'
+ quoted = urllib.parse.quote(hostnqn, safe='')
+ try:
+ self._request('DELETE', f'{path}/{quoted}')
+ except OntapError as e:
+ # Gone if an earlier set-host failed to add it again
+ if e.status != 404:
+ raise
+ self._request('POST', path, host)
+ self._save_hosts(hosts)
+
+ # Ports: the LIFs
+
+ def list_ports(self, subsysnqn: str) -> list[str]:
+ if not self._subsystem(self._name(subsysnqn)):
+ return []
+ return [str(i) for i in range(1, len(self._cache()['lifs']) + 1)]
+
+ def show_port(self, port: str) -> Port:
+ lifs = self._cache()['lifs']
+ if not port.isdigit() or not 1 <= int(port) <= len(lifs):
+ raise OntapError(f'no port {port}')
+ return Port('tcp', lifs[int(port) - 1], self.value('trsvid'))
diff --git a/contrib/nvme-target-control/tests/test_ontap.py b/contrib/nvme-target-control/tests/test_ontap.py
new file mode 100644
index 000000000000..e202b3e16fbe
--- /dev/null
+++ b/contrib/nvme-target-control/tests/test_ontap.py
@@ -0,0 +1,357 @@
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (c) 2026 SUSE LLC and contributors
+"""Tests for the ONTAP target, against a fake ONTAP REST API."""
+
+import base64
+import io
+import json
+import sys
+import tempfile
+import unittest
+import urllib.error
+import urllib.parse
+import urllib.request
+import uuid
+from pathlib import Path
+from typing import Any
+from unittest import mock
+
+sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
+
+from nvme_target_control import target
+from nvme_target_control.target import Subsystem
+from nvme_target_control.targets import ontap
+
+SVM_UUID = 'd714f2f5-ab77-11ed-af12-00a0988fb732'
+PREFIX = 'nqn.1992-08.com.netapp:sn.d714f2f5ab7711edaf1200a0988fb732'
+NQN = PREFIX + ':subsystem.blktests'
+HOSTNQN = 'nqn.2014-08.org.nvmexpress:uuid:57c34e91'
+KEY = 'DHHC-1:01:aGVsbG8gd29ybGQgaGVsbG8gd29ybGQgaGVsbG8hISEhTr8=:'
+KEY2 = 'DHHC-1:00:YW5vdGhlciBrZXkgYW5vdGhlciBrZXkgYW5vdGhlciEhIUV8=:'
+
+
+class Response(io.BytesIO):
+ def __init__(self, status: int, body: dict[str, Any] | None) -> None:
+ super().__init__(
+ json.dumps(body).encode() if body is not None else b''
+ )
+ self.status = status
+
+
+def records(r: list[dict[str, Any]]) -> tuple[int, dict[str, Any]]:
+ """A collection GET reply."""
+ return 200, {'records': r, 'num_records': len(r)}
+
+
+class FakeOntap:
+ """The REST resources the ONTAP target uses, in memory."""
+
+ def __init__(self) -> None:
+ self.requests: list[tuple[str, str, dict[str, Any] | None]] = []
+ self.auth: list[str] = []
+ self.contexts: list[Any] = []
+ self.lifs = [
+ {'name': 'lif-b', 'ip': {'address': '192.0.2.2'}},
+ {'name': 'lif-a', 'ip': {'address': '192.0.2.1'}},
+ ]
+ self.volumes: dict[str, dict[str, Any]] = {}
+ self.namespaces: dict[str, str] = {}
+ self.subsystems: dict[str, dict[str, Any]] = {}
+ self.maps: dict[str, str] = {} # namespace name -> subsystem name
+ self.job_state = 'success'
+
+ def urlopen(
+ self,
+ req: urllib.request.Request,
+ context: Any = None,
+ timeout: int = 0,
+ ) -> Response:
+ url = urllib.parse.urlsplit(req.full_url)
+ query = dict(urllib.parse.parse_qsl(url.query))
+ body = (
+ json.loads(req.data) # type: ignore[arg-type]
+ if req.data
+ else None
+ )
+ method = req.get_method()
+ path = urllib.parse.unquote(url.path.removeprefix('/api'))
+ self.requests.append((method, path, body))
+ self.auth.append(req.get_header('Authorization') or '')
+ self.contexts.append(context)
+ status, result = self.handle(method, path, query, body)
+ if status >= 400:
+ raise urllib.error.HTTPError(
+ req.full_url,
+ status,
+ 'error',
+ {}, # type: ignore[arg-type]
+ io.BytesIO(json.dumps(result).encode()),
+ )
+ return Response(status, result)
+
+ def handle(
+ self,
+ method: str,
+ path: str,
+ query: dict[str, str],
+ body: dict[str, Any] | None,
+ ) -> tuple[int, dict[str, Any] | None]:
+ if (method, path) == ('GET', '/svm/svms'):
+ return records([{'uuid': SVM_UUID, 'name': query['name']}])
+ if (method, path) == ('GET', '/network/ip/interfaces'):
+ return records(self.lifs)
+ if path == '/storage/volumes':
+ if method == 'POST':
+ assert body is not None
+ self.volumes[body['name']] = body
+ return 202, {'job': {'uuid': 'job-1'}}
+ vols = [{'name': query['name']}] * (query['name'] in self.volumes)
+ return records(vols)
+ if path.startswith('/cluster/jobs/'):
+ return 200, {'state': self.job_state, 'message': 'no space'}
+ if path == '/storage/namespaces':
+ if method == 'POST':
+ assert body is not None
+ self.namespaces[body['name']] = str(uuid.uuid4())
+ return 201, None
+ name = query['name']
+ if name not in self.namespaces:
+ return records([])
+ return records([{'uuid': self.namespaces[name]}])
+ if path == '/protocols/nvme/subsystem-maps':
+ if method == 'POST':
+ assert body is not None
+ self.maps[body['namespace']['name']] = body['subsystem'][
+ 'name'
+ ]
+ return 201, None
+ subsys = self.maps.get(query['namespace.name'])
+ if subsys is None:
+ return records([])
+ uid = self.subsystems[subsys]['uuid']
+ return records([{'subsystem': {'name': subsys, 'uuid': uid}}])
+ if path == '/protocols/nvme/subsystems':
+ if method == 'POST':
+ assert body is not None
+ self.subsystems[body['name']] = {
+ 'uuid': str(uuid.uuid4()),
+ 'hosts': {h['nqn']: h for h in body['hosts']},
+ }
+ return 201, None
+ name = query['name']
+ if name not in self.subsystems:
+ return records([])
+ return records([{'name': name, **self.subsystems[name]}])
+ parts = path.split('/')
+ found = [
+ n for n, s in self.subsystems.items() if s['uuid'] == parts[4]
+ ]
+ if not found:
+ return 404, {'error': {'message': 'no subsystem'}}
+ subsys = found[0]
+ hosts = self.subsystems[subsys]['hosts']
+ if method == 'DELETE' and len(parts) == 5:
+ del self.subsystems[subsys]
+ self.maps = {k: v for k, v in self.maps.items() if v != subsys}
+ return 200, None
+ if method == 'DELETE':
+ if parts[6] not in hosts:
+ return 404, {'error': {'message': 'no host'}}
+ del hosts[parts[6]]
+ return 200, None
+ assert body is not None
+ hosts[body['nqn']] = body
+ return 201, None
+
+
+class OntapTestCase(unittest.TestCase):
+ def setUp(self) -> None:
+ tmp = tempfile.TemporaryDirectory()
+ self.addCleanup(tmp.cleanup)
+ self.tmp = Path(tmp.name)
+ (self.tmp / 'password').write_text('secret\n')
+ self.fake = FakeOntap()
+ patch = mock.patch.object(urllib.request, 'urlopen', self.fake.urlopen)
+ patch.start()
+ self.addCleanup(patch.stop)
+
+ def target(self, **config: Any) -> ontap.OntapTarget:
+ cfg = {
+ 'type': 'ontap',
+ 'host': '192.0.2.100',
+ 'user': 'admin',
+ 'password_file': str(self.tmp / 'password'),
+ 'svm': 'svm1',
+ 'aggregate': 'aggr1',
+ 'cache_dir': str(self.tmp / 'cache'),
+ **config,
+ }
+ tgt = target.create(cfg)
+ assert isinstance(tgt, ontap.OntapTarget)
+ return tgt
+
+ def subsys(self, **keys: str) -> Subsystem:
+ tgt = self.target()
+ return Subsystem(NQN, tgt.value('subsys_uuid'), HOSTNQN, **keys)
+
+
+class TestOntapConfig(OntapTestCase):
+ def test_values(self) -> None:
+ tgt = self.target()
+ self.assertEqual(tgt.value('traddr'), '192.0.2.1')
+ self.assertEqual(tgt.value('trsvid'), '4420')
+ self.assertEqual(tgt.value('subsysnqn'), NQN)
+ self.assertEqual(
+ tgt.value('subsys_uuid'), self.fake.namespaces['/vol/blktests/ns1']
+ )
+ self.assertEqual(
+ tgt.features(),
+ [
+ 'list-ports',
+ 'show-port',
+ 'set-host',
+ 'dhchap-sha256',
+ 'dhchap-sha512',
+ 'dhchap-null',
+ 'dhchap-ffdhe2048',
+ 'dhchap-ffdhe3072',
+ 'dhchap-ffdhe4096',
+ 'dhchap-ffdhe6144',
+ 'dhchap-ffdhe8192',
+ ],
+ )
+
+ def test_creates_volume_without_snapshots(self) -> None:
+ self.target(volume='bt', ns_size='1G').value('subsys_uuid')
+ vol = self.fake.volumes['bt']
+ self.assertEqual(vol['aggregates'], [{'name': 'aggr1'}])
+ self.assertEqual(vol['snapshot_policy'], {'name': 'none'})
+ self.assertEqual(vol['space'], {'snapshot': {'reserve_percent': 0}})
+ self.assertIn('/vol/bt/ns1', self.fake.namespaces)
+
+ def test_cached(self) -> None:
+ self.target().value('subsys_uuid')
+ nr = len(self.fake.requests)
+ tgt = self.target()
+ for name in ['traddr', 'subsysnqn', 'subsys_uuid']:
+ tgt.value(name)
+ self.assertEqual(len(self.fake.requests), nr)
+
+ def test_request(self) -> None:
+ self.target(verify_tls=False).value('traddr')
+ auth = base64.b64encode(b'admin:secret').decode()
+ self.assertEqual(set(self.fake.auth), {'Basic ' + auth})
+ self.assertTrue(all(c is not None for c in self.fake.contexts))
+ self.fake.contexts.clear()
+ self.target(cache_dir=str(self.tmp / 'c2')).value('traddr')
+ self.assertTrue(all(c is None for c in self.fake.contexts))
+
+ def test_job_failure(self) -> None:
+ self.fake.job_state = 'failure'
+ with self.assertRaisesRegex(ontap.OntapError, 'no space'):
+ self.target().value('subsys_uuid')
+
+
+class TestOntapSubsystems(OntapTestCase):
+ def test_setup_cleanup(self) -> None:
+ tgt = self.target()
+ tgt.setup(self.subsys(hostkey=KEY, ctrlkey=KEY2), 4)
+ subsys = self.fake.subsystems['blktests']
+ self.assertEqual(
+ subsys['hosts'][HOSTNQN]['dh_hmac_chap'],
+ {'host_secret_key': KEY, 'controller_secret_key': KEY2},
+ )
+ self.assertEqual(self.fake.maps, {'/vol/blktests/ns1': 'blktests'})
+ self.assertEqual(tgt.list_ports(NQN), ['1', '2'])
+ self.assertEqual(
+ tgt.show_port('2'), target.Port('tcp', '192.0.2.2', '4420')
+ )
+ self.assertEqual(tgt.hosts_file.stat().st_mode & 0o777, 0o600)
+
+ tgt.cleanup(NQN)
+ self.assertEqual((self.fake.subsystems, self.fake.maps), ({}, {}))
+ self.assertEqual(tgt.list_ports(NQN), [])
+ self.assertEqual(json.loads(tgt.hosts_file.read_text()), {})
+
+ def test_stale_subsystem(self) -> None:
+ tgt = self.target()
+ tgt.setup(self.subsys())
+ tgt.setup(self.subsys())
+ self.assertEqual(list(self.fake.subsystems), ['blktests'])
+ self.fake.maps['/vol/blktests/ns1'] = 'other'
+ self.fake.subsystems['other'] = {'uuid': 'u', 'hosts': {}}
+ with self.assertRaisesRegex(ontap.OntapError, 'mapped to other'):
+ tgt.setup(self.subsys())
+
+ def test_unsupported(self) -> None:
+ tgt = self.target()
+ with self.assertRaisesRegex(ontap.OntapError, 'start with'):
+ tgt.setup(Subsystem('nqn.foo', 'u', HOSTNQN))
+ with self.assertRaises(NotImplementedError):
+ tgt.setup(self.subsys(), tls='required')
+ with self.assertRaisesRegex(ontap.OntapError, 'no port 3'):
+ tgt.show_port('3')
+ with self.assertRaises(NotImplementedError):
+ tgt.set_ana('1', 1, 'optimized')
+
+
+class TestOntapSetHost(OntapTestCase):
+ def chap(self) -> dict[str, str]:
+ hosts = self.fake.subsystems['blktests']['hosts']
+ chap: dict[str, str] = hosts[HOSTNQN]['dh_hmac_chap']
+ return chap
+
+ def test_set_host(self) -> None:
+ tgt = self.target()
+ tgt.setup(self.subsys(hostkey=KEY))
+ tgt.set_host(HOSTNQN, {'hash': 'hmac(sha512)', 'dhgroup': 'ffdhe8192'})
+ self.assertEqual(
+ self.chap(),
+ {
+ 'host_secret_key': KEY,
+ 'hash_function': 'sha_512',
+ 'group_size': '8192_bit',
+ },
+ )
+ # A new target, as for the next command, knows the secrets
+ self.target().set_host(HOSTNQN, {'hostkey': KEY2, 'ctrlkey': KEY})
+ self.assertEqual(self.chap()['host_secret_key'], KEY2)
+ self.assertEqual(self.chap()['controller_secret_key'], KEY)
+ deletes = [r for r in self.fake.requests if r[0] == 'DELETE']
+ self.assertEqual(len(deletes), 2)
+
+ def test_unsupported_hash(self) -> None:
+ tgt = self.target()
+ tgt.setup(self.subsys(hostkey=KEY))
+ with self.assertRaisesRegex(ontap.OntapError, 'hmac.sha384'):
+ tgt.set_host(HOSTNQN, {'hash': 'hmac(sha384)'})
+
+ def test_sha384_secret(self) -> None:
+ tgt = self.target()
+ with self.assertRaisesRegex(ontap.OntapError, 'SHA-384 secrets'):
+ tgt.setup(self.subsys(hostkey='DHHC-1:02:abc:'))
+ tgt.setup(self.subsys(hostkey=KEY))
+ with self.assertRaisesRegex(ontap.OntapError, 'SHA-384 secrets'):
+ tgt.set_host(HOSTNQN, {'ctrlkey': 'DHHC-1:02:abc:'})
+ # The host is still allowed with the old key
+ self.assertEqual(self.chap(), {'host_secret_key': KEY})
+
+ def test_host_already_removed(self) -> None:
+ tgt = self.target()
+ tgt.setup(self.subsys(hostkey=KEY))
+ del self.fake.subsystems['blktests']['hosts'][HOSTNQN]
+ tgt.set_host(HOSTNQN, {'hostkey': KEY2})
+ self.assertEqual(self.chap(), {'host_secret_key': KEY2})
+
+ def test_http_error(self) -> None:
+ tgt = self.target()
+ tgt.setup(self.subsys())
+ self.fake.subsystems['blktests']['uuid'] = 'gone'
+ self.fake.subsystems['x'] = {'uuid': 'other', 'hosts': {}}
+ with self.assertRaises(ontap.OntapError) as e:
+ tgt._delete_subsystem('missing')
+ self.assertEqual(e.exception.status, 404)
+
+
+if __name__ == '__main__':
+ unittest.main()
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH blktests v2 1/9] nvme/047: look up the namespace again after reconnecting
2026-11-18 9:26 ` [PATCH blktests v2 1/9] nvme/047: look up the namespace again after reconnecting Daniel Wagner
@ 2026-11-20 11:23 ` Hannes Reinecke
0 siblings, 0 replies; 15+ messages in thread
From: Hannes Reinecke @ 2026-11-20 11:23 UTC (permalink / raw)
To: Daniel Wagner, Shin'ichiro Kawasaki; +Cc: linux-block, linux-nvme
On 11/18/26 10:26 AM, Daniel Wagner wrote:
> nvme/047 keeps using the namespace name from the first connect after
> reconnecting. The name can change when other controllers come and go,
> and fio then fails to open the device. Look it up again after the
> second connect.
>
> Fixes: 7497d8b45817 ("nvme/047: Test different queue types for fabrics transports")
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
> tests/nvme/047 | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/tests/nvme/047 b/tests/nvme/047
> index 433090f2d6f2..2aeee2f0f1aa 100755
> --- a/tests/nvme/047
> +++ b/tests/nvme/047
> @@ -42,6 +42,8 @@ test() {
>
> _nvme_connect_subsys --nr-write-queues 1 --nr-poll-queues 1
>
> + ns=$(_find_nvme_ns "${def_subsys_uuid}")
> +
> _run_fio_rand_io --filename="/dev/${ns}" --size="${rand_io_size}"
>
> _nvme_disconnect_subsys >> "$FULL" 2>&1
>
What's a bit awkward is this 'subsys_uuid'; one is confused why we
would set the subsystem UUID as the UUID of the namespace.
Eg what would happen if we were using (or wanting to specify) more
than one namespace?
Can't we rename it to 'ns_uuid' to make the scope clear?
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH blktests v2 0/9] nvme: make NVME_TARGET_CONTROL work with remote targets
2026-11-18 9:26 [PATCH blktests v2 0/9] nvme: make NVME_TARGET_CONTROL work with remote targets Daniel Wagner
` (8 preceding siblings ...)
2026-11-18 9:26 ` [PATCH blktests v2 9/9] contrib/nvme-target-control: add a NetApp ONTAP target Daniel Wagner
@ 2026-11-20 11:25 ` Hannes Reinecke
2026-11-28 2:34 ` Shin'ichiro Kawasaki
10 siblings, 0 replies; 15+ messages in thread
From: Hannes Reinecke @ 2026-11-20 11:25 UTC (permalink / raw)
To: Daniel Wagner, Shin'ichiro Kawasaki; +Cc: linux-block, linux-nvme
On 11/18/26 10:26 AM, Daniel Wagner wrote:
> Hi all,
>
> this series makes running the nvme tests against a remote target with
> NVME_TARGET_CONTROL actually work. The first six patches of v1 have been
> applied, this is the rest. It applies on top of the series that makes
> tests skip when a program they need is missing.
>
> The first two patches are fixes: nvme/047 looks up the namespace again
> after reconnecting, and the nvmet target picks free service IDs for its
> ports. The third is a cleanup, nvme/042 and nvme/043 iterate over the
> DH-HMAC-CHAP hashes by name.
>
> The remaining patches let tests skip instead of failing when the remote
> target lacks a feature they need, including the DH-HMAC-CHAP hashes and
> DH groups the target doesn't support, add port and host key support for
> remote targets, and add a NetApp ONTAP target as an example of a target
> that can do less than nvmet.
>
> Tested against nvmet in a second VM, which also exported other
> subsystems on its own ports, and against a NetApp ONTAP array. All tests
> that can run against a remote target pass, except nvme/077 against
> nvmet, which checks attr_qid_max in the local nvmet configfs. Against
> the array, nvme/061 and nvme/070 fail because it refuses the reconnect
> after a subsystem is deleted and doesn't support Identify CNS 07h, and
> nvme/068 because the host runs a 6.4 kernel. The tests that need the
> kernel target still pass with the local target.
>
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
> Changes in v2:
> - Drop the six patches that were applied.
> - Fix nvme/047 to look up the namespace again after reconnecting.
> - Pick free service IDs for new nvmet ports.
> - Pass the TLS option in the argument array instead of an unquoted
> command substitution; quoting it would pass an empty argument without
> TLS. (Shin'ichiro)
> - Check the features with =~, with an SC2076 exception for the literal
> match. (Shin'ichiro)
> - List the DH-HMAC-CHAP algorithms a target supports, iterate over them
> by name in nvme/042 and nvme/043 and skip the ones the target lacks.
> - Put the fixes first, then the cleanup, then the features.
> - Depend on the series that makes tests skip when a program is missing.
> - Link to v1: https://patch.msgid.link/20261104-nvme-target-control-v1-0-b31b40537bb4@suse.de
>
> ---
> Daniel Wagner (9):
> nvme/047: look up the namespace again after reconnecting
> contrib/nvme-target-control: pick a free service ID for new nvmet ports
> nvme/042, nvme/043: iterate over the DH-HMAC-CHAP hashes by name
> nvme: skip tests that need a feature the remote target lacks
> contrib/nvme-target-control: list the DH-HMAC-CHAP algorithms
> nvme: skip the DH-HMAC-CHAP algorithms the target doesn't support
> common/nvme: support the ports of a remote target
> nvme/rc: change the host keys on a remote target
> contrib/nvme-target-control: add a NetApp ONTAP target
>
> Documentation/running-tests.md | 49 ++-
> common/nvme | 88 ++++-
> contrib/nvme-target-control/README.md | 72 +++-
> .../nvme_target_control/target.py | 19 +
> .../nvme_target_control/targets/nvmet.py | 12 +-
> .../nvme_target_control/targets/nvmet.sh | 7 +-
> .../nvme_target_control/targets/ontap.py | 397 +++++++++++++++++++++
> contrib/nvme-target-control/tests/test_ontap.py | 357 ++++++++++++++++++
> .../tests/test_target_control.py | 4 +-
> tests/nvme/031 | 1 +
> tests/nvme/041 | 1 +
> tests/nvme/042 | 12 +-
> tests/nvme/042.out | 8 +-
> tests/nvme/043 | 9 +-
> tests/nvme/043.out | 6 +-
> tests/nvme/044 | 1 +
> tests/nvme/045 | 1 +
> tests/nvme/047 | 2 +
> tests/nvme/057 | 1 +
> tests/nvme/062 | 1 +
> tests/nvme/063 | 5 +-
> tests/nvme/rc | 58 +++
> 22 files changed, 1069 insertions(+), 42 deletions(-)
> ---
> base-commit: 79c32fb31b7bca6a4383b749030128683cf6b6b4
> change-id: 20261104-nvme-target-control-f0b239e68b29
> prerequisite-change-id: 20261117-skip-missing-deps-30b4084698c4:v1
> prerequisite-patch-id: 9478a4106d922c8432a4d297dcb18ed68a9c8d61
> prerequisite-patch-id: 635fcb82ae72c78b84ad593a58d82315a166724d
> prerequisite-patch-id: 528ad89bda84f0b0d9cbc0d38b6e1384332f86cd
> prerequisite-patch-id: 2758a16b44a326eea5113ff4967e6093ad42e71c
> prerequisite-patch-id: 9acbf0ff52b0b46035e4635035662cd9d9309f77
>
> Best regards,
> --
> Daniel Wagner <dwagner@suse.de>
>
>
Very nice, thank you!
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH blktests v2 6/9] nvme: skip the DH-HMAC-CHAP algorithms the target doesn't support
2026-11-18 9:26 ` [PATCH blktests v2 6/9] nvme: skip the DH-HMAC-CHAP algorithms the target doesn't support Daniel Wagner
@ 2026-11-28 2:30 ` Shin'ichiro Kawasaki
0 siblings, 0 replies; 15+ messages in thread
From: Shin'ichiro Kawasaki @ 2026-11-28 2:30 UTC (permalink / raw)
To: Daniel Wagner; +Cc: linux-block, linux-nvme
On Nov 18, 2026 / 10:26, Daniel Wagner wrote:
> The authentication tests fail against a target that can't do
> DH-HMAC-CHAP, and nvme/042 and nvme/043 fail on every hash or DH group
> the target doesn't support.
>
> Skip the authentication tests if the target doesn't list dhchap-sha256,
> the hash every DH-HMAC-CHAP target supports, and skip just the steps of
> nvme/042 and nvme/043 for the other algorithms the target doesn't list.
>
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
> Documentation/running-tests.md | 7 +++++--
> tests/nvme/041 | 1 +
> tests/nvme/042 | 3 ++-
> tests/nvme/043 | 4 +++-
> tests/nvme/044 | 2 +-
> tests/nvme/045 | 2 +-
> tests/nvme/063 | 2 +-
> tests/nvme/rc | 31 +++++++++++++++++++++++++------
> 8 files changed, 39 insertions(+), 13 deletions(-)
The commit message mentions the test cases nvme/042 and nvme/043 only, but
this patch touches more test cases listed above. I guess all those test cases
are modified for the same reason, right? If so, I can edit the commit message
when I apply this patch.
>
> diff --git a/Documentation/running-tests.md b/Documentation/running-tests.md
> index b66bdf9cb2e8..d556f1d3b7cc 100644
> --- a/Documentation/running-tests.md
> +++ b/Documentation/running-tests.md
> @@ -261,8 +261,11 @@ The blktests expects that the script interface implements following
> --subsysnqn SUBSYSNQN
>
> config --show-features prints the optional commands the script supports,
> -e.g. add-port, set-ana or set-host, and tls if the target can set up TLS.
> -blktests skips the tests which need a feature the list lacks.
> +e.g. add-port, set-ana or set-host, the DH-HMAC-CHAP hashes and DH groups
> +the target supports, e.g. dhchap-sha256 or dhchap-ffdhe2048, and tls if
> +the target can set up TLS. blktests skips the tests which need a feature
> +the list lacks: the authentication tests without dhchap-sha256, and
> +nvme/042 and nvme/043 only the steps for the other missing algorithms.
>
> contrib/nvme-target-control implements this interface. It configures a Linux
> nvmet target over ssh and can be extended for other targets, see
> diff --git a/tests/nvme/041 b/tests/nvme/041
> index 9c3d9aaf4e12..2571c851be4d 100755
> --- a/tests/nvme/041
> +++ b/tests/nvme/041
> @@ -16,6 +16,7 @@ requires() {
> _require_kernel_nvme_fabrics_feature dhchap_ctrl_secret
> _require_nvme_trtype_is_fabrics
> _require_nvme_cli_auth
> + _require_nvme_target_control_feature dhchap-sha256
> }
>
> set_conditions() {
> diff --git a/tests/nvme/042 b/tests/nvme/042
> index e771cb6ca4aa..f9019e9640c4 100755
> --- a/tests/nvme/042
> +++ b/tests/nvme/042
> @@ -16,7 +16,7 @@ requires() {
> _require_kernel_nvme_fabrics_feature dhchap_ctrl_secret
> _require_nvme_trtype_is_fabrics
> _require_nvme_cli_auth
> - _require_nvme_target_control_feature set-host
> + _require_nvme_target_control_feature set-host dhchap-sha256
> }
>
> set_conditions() {
> @@ -37,6 +37,7 @@ test() {
>
> for hash in none sha256 sha384 sha512; do
> echo "Testing hash ${hash}"
> + _have_nvme_target_dhchap "${hash}" || continue
> hostkey="$(_nvme_gen_kxchap_secret --hash="${hash}" 2> /dev/null)"
> if [ -z "$hostkey" ] ; then
> echo "couldn't generate host key for hash ${hash}"
> diff --git a/tests/nvme/043 b/tests/nvme/043
> index eb8f8b035f6d..695edaab9741 100755
> --- a/tests/nvme/043
> +++ b/tests/nvme/043
> @@ -17,7 +17,7 @@ requires() {
> _require_nvme_trtype_is_fabrics
> _require_nvme_cli_auth
> _have_crypto_algorithm dh-generic
> - _require_nvme_target_control_feature set-host
> + _require_nvme_target_control_feature set-host dhchap-sha256
> }
>
> set_conditions() {
> @@ -45,6 +45,7 @@ test() {
> for hash in sha256 sha384 sha512; do
>
> echo "Testing hash ${hash}"
> + _have_nvme_target_dhchap "${hash}" || continue
>
> _set_nvmet_hash "${def_hostnqn}" "hmac(${hash})"
>
> @@ -56,6 +57,7 @@ test() {
> for dhgroup in ffdhe2048 ffdhe3072 ffdhe4096 ffdhe6144 ffdhe8192; do
>
> echo "Testing DH group ${dhgroup}"
> + _have_nvme_target_dhchap "${dhgroup}" || continue
>
> _set_nvmet_dhgroup "${def_hostnqn}" "${dhgroup}"
>
> diff --git a/tests/nvme/044 b/tests/nvme/044
> index c1a48f1e3d86..01a153e1f2a0 100755
> --- a/tests/nvme/044
> +++ b/tests/nvme/044
> @@ -17,7 +17,7 @@ requires() {
> _require_nvme_trtype_is_fabrics
> _require_nvme_cli_auth
> _have_crypto_algorithm dh-generic
> - _require_nvme_target_control_feature set-host
> + _require_nvme_target_control_feature set-host dhchap-sha256
> }
>
> set_conditions() {
> diff --git a/tests/nvme/045 b/tests/nvme/045
> index 14f4949e198e..52d04ce40860 100755
> --- a/tests/nvme/045
> +++ b/tests/nvme/045
> @@ -18,7 +18,7 @@ requires() {
> _require_nvme_trtype_is_fabrics
> _require_nvme_cli_auth
> _have_crypto_algorithm dh-generic
> - _require_nvme_target_control_feature set-host
> + _require_nvme_target_control_feature set-host dhchap-sha256
> }
>
> set_conditions() {
> diff --git a/tests/nvme/063 b/tests/nvme/063
> index 20aabd91ca80..578cb8799a6d 100755
> --- a/tests/nvme/063
> +++ b/tests/nvme/063
> @@ -19,7 +19,7 @@ requires() {
> _require_nvme_trtype tcp
> _require_nvme_cli_auth
> _have_systemd_tlshd_service
> - _require_nvme_target_control_feature set-host tls
> + _require_nvme_target_control_feature set-host tls dhchap-sha256
> }
>
> set_conditions() {
> diff --git a/tests/nvme/rc b/tests/nvme/rc
> index 41811c033069..0d74c427313c 100644
> --- a/tests/nvme/rc
> +++ b/tests/nvme/rc
> @@ -155,18 +155,37 @@ _require_remote_nvme_target() {
> return 0
> }
>
> -# Skip the test if the NVME_TARGET_CONTROL target lacks one of the features,
> -# the optional commands and e.g. tls, see Documentation/running-tests.md.
> -_require_nvme_target_control_feature() {
> - local features feature
> +# Check if the NVME_TARGET_CONTROL target lists the feature, one of the
> +# optional commands or e.g. tls, see Documentation/running-tests.md. The
> +# local target has all of them.
> +_have_nvme_target_control_feature() {
> + local features
>
> if [[ -z "${nvme_target_control}" ]]; then
> return 0
> fi
> features=" $("${nvme_target_control}" config --show-features) "
> + # shellcheck disable=SC2076 # match the feature literally
> + [[ "${features}" =~ " $1 " ]]
> +}
Nit: I think the shellcehck exception above can be avoided by a local variable.
I will add another follow-up commit as below. Just in case you think wrong,
please let me know.
diff --git a/tests/nvme/rc b/tests/nvme/rc
index e4fa9e0..879eb40 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -159,14 +159,14 @@ _require_remote_nvme_target() {
# optional commands or e.g. tls, see Documentation/running-tests.md. The
# local target has all of them.
_have_nvme_target_control_feature() {
- local features
+ local features feature
if [[ -z "${nvme_target_control}" ]]; then
return 0
fi
features=" $("${nvme_target_control}" config --show-features) "
- # shellcheck disable=SC2076 # match the feature literally
- [[ "${features}" =~ " $1 " ]]
+ feature=" $1 "
+ [[ "${features}" =~ $feature ]]
}
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH blktests v2 3/9] nvme/042, nvme/043: iterate over the DH-HMAC-CHAP hashes by name
2026-11-18 9:26 ` [PATCH blktests v2 3/9] nvme/042, nvme/043: iterate over the DH-HMAC-CHAP hashes by name Daniel Wagner
@ 2026-11-28 2:31 ` Shin'ichiro Kawasaki
0 siblings, 0 replies; 15+ messages in thread
From: Shin'ichiro Kawasaki @ 2026-11-28 2:31 UTC (permalink / raw)
To: Daniel Wagner; +Cc: linux-block, linux-nvme
On Nov 18, 2026 / 10:26, Daniel Wagner wrote:
> nvme/042 iterates over the numeric hash IDs nvme-cli takes, nvme/043
> over the hash names of the nvmet configfs. Add a --hash option to
> _nvme_gen_kxchap_secret which takes the hash name, and use the plain
> names in both tests, and in nvme/063.
>
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
> common/nvme | 18 ++++++++++++++++++
> tests/nvme/042 | 10 +++++-----
> tests/nvme/042.out | 8 ++++----
> tests/nvme/043 | 6 +++---
> tests/nvme/043.out | 6 +++---
> tests/nvme/063 | 4 ++--
> 6 files changed, 35 insertions(+), 17 deletions(-)
This patch touches nvme/063 also. When I apply this patch, I will
modify the commit title to include nvme/063.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH blktests v2 0/9] nvme: make NVME_TARGET_CONTROL work with remote targets
2026-11-18 9:26 [PATCH blktests v2 0/9] nvme: make NVME_TARGET_CONTROL work with remote targets Daniel Wagner
` (9 preceding siblings ...)
2026-11-20 11:25 ` [PATCH blktests v2 0/9] nvme: make NVME_TARGET_CONTROL work with remote targets Hannes Reinecke
@ 2026-11-28 2:34 ` Shin'ichiro Kawasaki
10 siblings, 0 replies; 15+ messages in thread
From: Shin'ichiro Kawasaki @ 2026-11-28 2:34 UTC (permalink / raw)
To: Daniel Wagner; +Cc: linux-block, linux-nvme
On Nov 18, 2026 / 10:26, Daniel Wagner wrote:
> Hi all,
>
> this series makes running the nvme tests against a remote target with
> NVME_TARGET_CONTROL actually work. The first six patches of v1 have been
> applied, this is the rest. It applies on top of the series that makes
> tests skip when a program they need is missing.
>
> The first two patches are fixes: nvme/047 looks up the namespace again
> after reconnecting, and the nvmet target picks free service IDs for its
> ports. The third is a cleanup, nvme/042 and nvme/043 iterate over the
> DH-HMAC-CHAP hashes by name.
>
> The remaining patches let tests skip instead of failing when the remote
> target lacks a feature they need, including the DH-HMAC-CHAP hashes and
> DH groups the target doesn't support, add port and host key support for
> remote targets, and add a NetApp ONTAP target as an example of a target
> that can do less than nvmet.
>
> Tested against nvmet in a second VM, which also exported other
> subsystems on its own ports, and against a NetApp ONTAP array. All tests
> that can run against a remote target pass, except nvme/077 against
> nvmet, which checks attr_qid_max in the local nvmet configfs. Against
> the array, nvme/061 and nvme/070 fail because it refuses the reconnect
> after a subsystem is deleted and doesn't support Identify CNS 07h, and
> nvme/068 because the host runs a 6.4 kernel. The tests that need the
> kernel target still pass with the local target.
>
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
Daniel, thank you for the series. I think this series is almost ready to apply.
Hannes made one comment on the 1st patch. I see the point, but IMO, it can be
put out of the scope of the series.
I made a few minor comments. Let me wait a few more days to wait for some more
comments before I apply this series with some commit message edits and with a
follow-up commit.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2026-11-28 2:35 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 9:26 [PATCH blktests v2 0/9] nvme: make NVME_TARGET_CONTROL work with remote targets Daniel Wagner
2026-11-18 9:26 ` [PATCH blktests v2 1/9] nvme/047: look up the namespace again after reconnecting Daniel Wagner
2026-11-20 11:23 ` Hannes Reinecke
2026-11-18 9:26 ` [PATCH blktests v2 2/9] contrib/nvme-target-control: pick a free service ID for new nvmet ports Daniel Wagner
2026-11-18 9:26 ` [PATCH blktests v2 3/9] nvme/042, nvme/043: iterate over the DH-HMAC-CHAP hashes by name Daniel Wagner
2026-11-28 2:31 ` Shin'ichiro Kawasaki
2026-11-18 9:26 ` [PATCH blktests v2 4/9] nvme: skip tests that need a feature the remote target lacks Daniel Wagner
2026-11-18 9:26 ` [PATCH blktests v2 5/9] contrib/nvme-target-control: list the DH-HMAC-CHAP algorithms Daniel Wagner
2026-11-18 9:26 ` [PATCH blktests v2 6/9] nvme: skip the DH-HMAC-CHAP algorithms the target doesn't support Daniel Wagner
2026-11-28 2:30 ` Shin'ichiro Kawasaki
2026-11-18 9:26 ` [PATCH blktests v2 7/9] common/nvme: support the ports of a remote target Daniel Wagner
2026-11-18 9:26 ` [PATCH blktests v2 8/9] nvme/rc: change the host keys on " Daniel Wagner
2026-11-18 9:26 ` [PATCH blktests v2 9/9] contrib/nvme-target-control: add a NetApp ONTAP target Daniel Wagner
2026-11-20 11:25 ` [PATCH blktests v2 0/9] nvme: make NVME_TARGET_CONTROL work with remote targets Hannes Reinecke
2026-11-28 2:34 ` Shin'ichiro Kawasaki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox