* [RFC blktests v2 00/03] Add support to run against real target
@ 2024-06-12 11:04 Daniel Wagner
2024-06-12 11:04 ` [RFC blktests v2 1/3] nvme/rc: introduce remote target support Daniel Wagner
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Daniel Wagner @ 2024-06-12 11:04 UTC (permalink / raw)
To: Shin'ichiro Kawasaki
Cc: Chaitanya Kulkarni, Hannes Reinecke, linux-block, linux-nvme,
Daniel Wagner
I've updated this series and added a simple example how to use it. I didn't
really know where to put it, so I added this part to new directorty called
'contrib'.
Don't know if we want to keep adding environment variables for this or if it
would be simpler to pass in a configuration file. The environemnt variable are
fairly simple to handle and it works. Adding a configuraiton file adds more code
to blktests.
changes:
v2:
- many of the preperation patches have been merged, drop them
- added a python script which implements the blktests API
- add some documentation how to use it
- changed the casing of the environment variables to upper case
v1:
- initial version
- https://lore.kernel.org/linux-nvme/20240318093856.22307-1-dwagner@suse.de/
Daniel Wagner (3):
nvme/rc: introduce remote target support
nvme/030: only run against kernel soft target
contrib: add remote target setup/cleanup script
Documentation/running-tests.md | 9 +++
contrib/nvme_target_control.py | 110 +++++++++++++++++++++++++++++++++
contrib/nvmet-subsys.jinja2 | 71 +++++++++++++++++++++
tests/nvme/030 | 1 +
tests/nvme/rc | 56 +++++++++++++++--
5 files changed, 243 insertions(+), 4 deletions(-)
create mode 100755 contrib/nvme_target_control.py
create mode 100644 contrib/nvmet-subsys.jinja2
--
2.45.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [RFC blktests v2 1/3] nvme/rc: introduce remote target support
2024-06-12 11:04 [RFC blktests v2 00/03] Add support to run against real target Daniel Wagner
@ 2024-06-12 11:04 ` Daniel Wagner
2024-06-14 5:09 ` Shinichiro Kawasaki
2024-06-12 11:04 ` [RFC blktests v2 2/3] nvme/030: only run against kernel soft target Daniel Wagner
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Daniel Wagner @ 2024-06-12 11:04 UTC (permalink / raw)
To: Shin'ichiro Kawasaki
Cc: Chaitanya Kulkarni, Hannes Reinecke, linux-block, linux-nvme,
Daniel Wagner
Most of the NVMEeoF tests are exercising the host code of the nvme
subsystem. There is no real reason not to run these against a real
target. We just have to skip the soft target setup and make it possible
to setup a remote target.
Because all tests use now the common setup/cleanup helpers we just need
to intercept this call and forward it to an external component.
As we already have various nvme variables to setup the target which we
should allow to overwrite. Also introduce a NVME_TARGET_CONTROL variable
which points to a script which gets executed whenever a targets needs to
be created/destroyed.
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
Documentation/running-tests.md | 9 +++++++
tests/nvme/rc | 48 +++++++++++++++++++++++++++++++---
2 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/Documentation/running-tests.md b/Documentation/running-tests.md
index 968702e76bb5..99dedaebfab0 100644
--- a/Documentation/running-tests.md
+++ b/Documentation/running-tests.md
@@ -120,6 +120,15 @@ The NVMe tests can be additionally parameterized via environment variables.
- NVME_NUM_ITER: 1000 (default)
The number of iterations a test should do. This parameter had an old name
'nvme_num_iter'. The old name is still usable, but not recommended.
+- NVME_TRADDR: transport address. Overwrites the default
+ transport address. See also NVME_TARGET_CONTROL.
+- NVME_HOST_TRADDR: host address. Overwrites the default
+ host address. See also NVME_TARGET_CONTROL.
+- NVME_TRSVID: transport service id. Overwrite the default
+ transport service ide. See also NVME_TARGET_CONTROL.
+- NVME_TARGET_CONTROL: When defined, the generic target setup/cleanup code will
+ be skipped and this script gets called. This makes it possible to run
+ the fabric nvme tests against a real target.
### Running nvme-rdma and SRP tests
diff --git a/tests/nvme/rc b/tests/nvme/rc
index c1ddf412033b..aaa64453fe16 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -7,9 +7,10 @@
. common/rc
. common/multipath-over-rdma
-def_traddr="127.0.0.1"
+def_traddr="${NVME_TRADDR:-127.0.0.1}"
+def_host_traddr="${NVME_HOST_TRADDDR:-}"
def_adrfam="ipv4"
-def_trsvcid="4420"
+def_trsvcid="${NVME_TRSVID:-4420}"
def_remote_wwnn="0x10001100aa000001"
def_remote_wwpn="0x20001100aa000001"
def_local_wwnn="0x10001100aa000002"
@@ -23,6 +24,7 @@ _check_conflict_and_set_default NVME_IMG_SIZE nvme_img_size 1G
_check_conflict_and_set_default NVME_NUM_ITER nvme_num_iter 1000
nvmet_blkdev_type=${nvmet_blkdev_type:-"device"}
NVMET_BLKDEV_TYPES=${NVMET_BLKDEV_TYPES:-"device file"}
+nvme_target_control="${NVME_TARGET_CONTROL:-}"
_NVMET_TRTYPES_is_valid() {
local type
@@ -359,6 +361,10 @@ _cleanup_nvmet() {
fi
done
+ if [[ -n "${nvme_target_control}" ]]; then
+ return
+ fi
+
for port in "${NVMET_CFS}"/ports/*; do
name=$(basename "${port}")
echo "WARNING: Test did not clean up port: ${name}"
@@ -403,11 +409,19 @@ _cleanup_nvmet() {
_setup_nvmet() {
_register_test_cleanup _cleanup_nvmet
+
+ if [[ -n "${nvme_target_control}" ]]; then
+ return
+ fi
+
modprobe -q nvmet
+
if [[ "${nvme_trtype}" != "loop" ]]; then
modprobe -q nvmet-"${nvme_trtype}"
fi
+
modprobe -q nvme-"${nvme_trtype}"
+
if [[ "${nvme_trtype}" == "rdma" ]]; then
start_soft_rdma
for i in $(rdma_network_interfaces)
@@ -425,6 +439,7 @@ _setup_nvmet() {
fi
done
fi
+
if [[ "${nvme_trtype}" = "fc" ]]; then
modprobe -q nvme-fcloop
_setup_fcloop "${def_local_wwnn}" "${def_local_wwpn}" \
@@ -873,11 +888,13 @@ _find_nvme_passthru_loop_dev() {
_nvmet_target_setup() {
local blkdev_type="${nvmet_blkdev_type}"
+ local subsys_uuid="${def_subsys_uuid}"
+ local subsysnqn="${def_subsysnqn}"
local blkdev
+ local ARGS=()
local ctrlkey=""
local hostkey=""
- local subsysnqn="${def_subsysnqn}"
- local subsys_uuid="${def_subsys_uuid}"
+ local blkdev
local port
while [[ $# -gt 0 ]]; do
@@ -909,6 +926,22 @@ _nvmet_target_setup() {
esac
done
+ if [[ -n "${hostkey}" ]]; then
+ ARGS+=(--hostkey "${hostkey}")
+ fi
+ if [[ -n "${ctrlkey}" ]]; then
+ ARGS+=(--ctrkey "${ctrlkey}")
+ fi
+
+ if [[ -n "${nvme_target_control}" ]]; then
+ eval "${nvme_target_control}" setup \
+ --subsysnqn "${subsysnqn}" \
+ --subsys-uuid "${subsys_uuid}" \
+ --hostnqn "${def_hostnqn}" \
+ "${ARGS[@]}" > /dev/null 2>&1
+ return
+ fi
+
truncate -s "${NVME_IMG_SIZE}" "$(_nvme_def_file_path)"
if [[ "${blkdev_type}" == "device" ]]; then
blkdev="$(losetup -f --show "$(_nvme_def_file_path)")"
@@ -948,6 +981,13 @@ _nvmet_target_cleanup() {
esac
done
+ if [[ -n "${nvme_target_control}" ]]; then
+ eval "${nvme_target_control}" cleanup \
+ --subsysnqn "${subsysnqn}" \
+ > /dev/null
+ return
+ fi
+
_get_nvmet_ports "${subsysnqn}" ports
for port in "${ports[@]}"; do
--
2.45.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [RFC blktests v2 2/3] nvme/030: only run against kernel soft target
2024-06-12 11:04 [RFC blktests v2 00/03] Add support to run against real target Daniel Wagner
2024-06-12 11:04 ` [RFC blktests v2 1/3] nvme/rc: introduce remote target support Daniel Wagner
@ 2024-06-12 11:04 ` Daniel Wagner
2024-06-14 5:11 ` Shinichiro Kawasaki
2024-06-12 11:04 ` [RFC blktests v2 3/3] contrib: add remote target setup/cleanup script Daniel Wagner
2024-06-14 5:05 ` [RFC blktests v2 00/03] Add support to run against real target Shinichiro Kawasaki
3 siblings, 1 reply; 8+ messages in thread
From: Daniel Wagner @ 2024-06-12 11:04 UTC (permalink / raw)
To: Shin'ichiro Kawasaki
Cc: Chaitanya Kulkarni, Hannes Reinecke, linux-block, linux-nvme,
Daniel Wagner
This tests is exercising the target code and not so much the host side.
The problem with nvme/030 is that it depends on interface to interact
with the target which is not covered by the standard. Thus we can't
run it against a real target. Just skip it when we run against a
real target.
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
tests/nvme/030 | 1 +
tests/nvme/rc | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/tests/nvme/030 b/tests/nvme/030
index b1ed8bc20908..672487734332 100755
--- a/tests/nvme/030
+++ b/tests/nvme/030
@@ -13,6 +13,7 @@ requires() {
_nvme_requires
_have_loop
_require_nvme_trtype_is_fabrics
+ _require_kernel_target
}
set_conditions() {
diff --git a/tests/nvme/rc b/tests/nvme/rc
index aaa64453fe16..4a2d107bd532 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -219,6 +219,14 @@ _require_kernel_nvme_fabrics_feature() {
return 0
}
+_require_kernel_target() {
+ if [[ -n "${nvme_target_control}" ]]; then
+ SKIP_REASONS+=("Linux kernel soft target not available")
+ return 1;
+ fi
+ return 0
+}
+
_test_dev_nvme_ctrl() {
echo "/dev/char/$(cat "${TEST_DEV_SYSFS}/device/dev")"
}
--
2.45.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [RFC blktests v2 3/3] contrib: add remote target setup/cleanup script
2024-06-12 11:04 [RFC blktests v2 00/03] Add support to run against real target Daniel Wagner
2024-06-12 11:04 ` [RFC blktests v2 1/3] nvme/rc: introduce remote target support Daniel Wagner
2024-06-12 11:04 ` [RFC blktests v2 2/3] nvme/030: only run against kernel soft target Daniel Wagner
@ 2024-06-12 11:04 ` Daniel Wagner
2024-06-12 12:21 ` Daniel Wagner
2024-06-14 5:05 ` [RFC blktests v2 00/03] Add support to run against real target Shinichiro Kawasaki
3 siblings, 1 reply; 8+ messages in thread
From: Daniel Wagner @ 2024-06-12 11:04 UTC (permalink / raw)
To: Shin'ichiro Kawasaki
Cc: Chaitanya Kulkarni, Hannes Reinecke, linux-block, linux-nvme,
Daniel Wagner
Use nvmetcli to setup/cleanup a remote soft target.
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
contrib/nvme_target_control.py | 110 +++++++++++++++++++++++++++++++++
contrib/nvmet-subsys.jinja2 | 71 +++++++++++++++++++++
2 files changed, 181 insertions(+)
create mode 100755 contrib/nvme_target_control.py
create mode 100644 contrib/nvmet-subsys.jinja2
diff --git a/contrib/nvme_target_control.py b/contrib/nvme_target_control.py
new file mode 100755
index 000000000000..97ed1c600dd2
--- /dev/null
+++ b/contrib/nvme_target_control.py
@@ -0,0 +1,110 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-3.0+
+
+# blktests calls this script to setup/teardown remote targets. blktests passes
+# all relevant information via the command line, e.g. --hostnqn. The interface
+# between blktests and this script is 'documentent' here in build_parser
+# function.
+#
+# This script uses nvmetcli to setup the remote target (it depends on the REST
+# API feature [1]). There is not technical need for nvmetcli to use but it makes
+# it simple to setup a remote Linux box. If you want to setup someting else
+# you should to replace this part.
+#
+# There are couple of global configuration options which need to be set.
+# Add ~/.config/blktests/nvme_target_control.toml file with something like:
+#
+# [main]
+# nvmetcli='/usr/bin/nvmetcli'
+# remote='http://nvmet.local:5000'
+#
+# And then start the nvmetcli server on the remote host.
+#
+# nvmetcli uses JSON configuration, thus this script creates a JSON configuration
+# using a jinja2 template. After this step we simple have to set the blktests
+# variable correctly and start blktests.
+#
+# $ host_ip4=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)
+# $ NVME_TRTYPE=tcp NVME_NVMET=nvmet.local NVME_HOST_TRADDR=${host_ip4} \
+# NVME_TARGET_CONTROL=~/blktests/contrib/nvme_target_control.py ./check nvme
+#
+# [1] https://github.com/hreinecke/nvmetcli/tree/restapi
+
+import os
+import tomllib
+import argparse
+import subprocess
+from jinja2 import Environment, FileSystemLoader
+
+
+XDG_CONFIG_HOME = os.environ.get("XDG_CONFIG_HOME")
+if not XDG_CONFIG_HOME:
+ XDG_CONFIG_HOME = os.environ.get('HOME') + '/.config'
+
+
+with open(f'{XDG_CONFIG_HOME}/blktests/nvme_target_control.toml', 'rb') as f:
+ config = tomllib.load(f)
+ nvmetcli = config['main']['nvmetcli']
+ remote = config['main']['remote']
+
+
+def gen_conf(conf):
+ environment = Environment(loader=FileSystemLoader('.'))
+ template = environment.get_template('nvmet-subsys.jinja2')
+ filename = f'{conf["subsysnqn"]}.json'
+ content = template.render(conf)
+ with open(filename, mode='w', encoding='utf-8') as outfile:
+ outfile.write(content)
+
+
+def target_setup(args):
+ conf = {
+ 'subsysnqn': args.subsysnqn,
+ 'subsys_uuid': args.subsys_uuid,
+ 'hostnqn': args.hostnqn,
+ 'allowed_hosts': args.hostnqn,
+ 'ctrlkey': args.ctrlkey,
+ 'hostkey': args.hostkey,
+ 'blkdev': '/dev/vdc'
+ }
+
+ gen_conf(conf)
+
+ subprocess.call(['python3', nvmetcli, '--remote=' + remote,
+ 'restore', args.subsysnqn + '.json'])
+
+
+def target_cleanup(args):
+ subprocess.call(['python3', nvmetcli, '--remote=' + remote,
+ 'clear', args.subsysnqn + '.json'])
+
+
+def build_parser():
+ parser = argparse.ArgumentParser()
+ sub = parser.add_subparsers(required=True)
+
+ setup = sub.add_parser('setup')
+ setup.add_argument('--subsysnqn', required=True)
+ setup.add_argument('--subsys-uuid', required=True)
+ setup.add_argument('--hostnqn', required=True)
+ setup.add_argument('--ctrlkey', default='')
+ setup.add_argument('--hostkey', default='')
+ setup.set_defaults(func=target_setup)
+
+ cleanup = sub.add_parser('cleanup')
+ cleanup.add_argument('--subsysnqn', required=True)
+ cleanup.set_defaults(func=target_cleanup)
+
+ return parser
+
+
+def main():
+ import sys
+
+ parser = build_parser()
+ args = parser.parse_args()
+ args.func(args)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/contrib/nvmet-subsys.jinja2 b/contrib/nvmet-subsys.jinja2
new file mode 100644
index 000000000000..a446fbd9b784
--- /dev/null
+++ b/contrib/nvmet-subsys.jinja2
@@ -0,0 +1,71 @@
+{
+ "hosts": [
+ {
+ "nqn": "{{ hostnqn }}"
+ }
+ ],
+ "ports": [
+ {
+ "addr": {
+ "adrfam": "ipv4",
+ "traddr": "0.0.0.0",
+ "treq": "not specified",
+ "trsvcid": "4420",
+ "trtype": "tcp",
+ "tsas": "none"
+ },
+ "ana_groups": [
+ {
+ "ana": {
+ "state": "optimized"
+ },
+ "grpid": 1
+ }
+ ],
+ "param": {
+ "inline_data_size": "16384",
+ "pi_enable": "0"
+ },
+ "portid": 0,
+ "referrals": [],
+ "subsystems": [
+ "{{ subsysnqn }}"
+ ]
+ }
+ ],
+ "subsystems": [
+ {
+ "allowed_hosts": [
+ "{{ allowed_hosts }}"
+ ],
+ "attr": {
+ "allow_any_host": "0",
+ "cntlid_max": "65519",
+ "cntlid_min": "1",
+ "firmware": "yada",
+ "ieee_oui": "0x000000",
+ "model": "Linux",
+ "pi_enable": "0",
+ "qid_max": "128",
+ "serial": "0c74361069d9db6c65ef",
+ "version": "1.3"
+ },
+ "namespaces": [
+ {
+ "ana": {
+ "grpid": "1"
+ },
+ "ana_grpid": 1,
+ "device": {
+ "nguid": "00000000-0000-0000-0000-000000000000",
+ "path": "{{ blkdev }}",
+ "uuid": "{{ subsys_uuid }}"
+ },
+ "enable": 1,
+ "nsid": 1
+ }
+ ],
+ "nqn": "{{ subsysnqn }}"
+ }
+ ]
+}
--
2.45.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [RFC blktests v2 3/3] contrib: add remote target setup/cleanup script
2024-06-12 11:04 ` [RFC blktests v2 3/3] contrib: add remote target setup/cleanup script Daniel Wagner
@ 2024-06-12 12:21 ` Daniel Wagner
0 siblings, 0 replies; 8+ messages in thread
From: Daniel Wagner @ 2024-06-12 12:21 UTC (permalink / raw)
To: Shin'ichiro Kawasaki
Cc: Chaitanya Kulkarni, Hannes Reinecke, linux-block, linux-nvme
On Wed, Jun 12, 2024 at 01:04:44PM GMT, Daniel Wagner wrote:
> +# blktests calls this script to setup/teardown remote targets. blktests passes
> +# all relevant information via the command line, e.g. --hostnqn. The interface
> +# between blktests and this script is 'documentent' here in build_parser
> +# function.
I just had an offline discussion with Hannes. This script is setting
up/tearing down the targets on demand. This is fine for a remote Linux
box the soft target running use case.
Hannes' idea/requirement that it should also support static setups. E.g.
the admin setups the real remote target and provides the ns uuids, which
test should run against (this is very similar to TESTS_DEVS). Thus the
tests should only operate on ns uuids and through this script blktests
can ask for the ns uuids.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC blktests v2 00/03] Add support to run against real target
2024-06-12 11:04 [RFC blktests v2 00/03] Add support to run against real target Daniel Wagner
` (2 preceding siblings ...)
2024-06-12 11:04 ` [RFC blktests v2 3/3] contrib: add remote target setup/cleanup script Daniel Wagner
@ 2024-06-14 5:05 ` Shinichiro Kawasaki
3 siblings, 0 replies; 8+ messages in thread
From: Shinichiro Kawasaki @ 2024-06-14 5:05 UTC (permalink / raw)
To: Daniel Wagner
Cc: Chaitanya Kulkarni, Hannes Reinecke, linux-block@vger.kernel.org,
linux-nvme@lists.infradead.org
Hi Daniel,
On Jun 12, 2024 / 13:04, Daniel Wagner wrote:
> I've updated this series and added a simple example how to use it. I didn't
> really know where to put it, so I added this part to new directorty called
> 'contrib'.
I'm fine with this. Some other helper scripts maybe go into the contrib
directory in the future.
>
> Don't know if we want to keep adding environment variables for this or if it
> would be simpler to pass in a configuration file. The environemnt variable are
> fairly simple to handle and it works. Adding a configuraiton file adds more code
> to blktests.
The first patch added 4 new environemnt variables. Unless you plan to add more,
I think it's fine with the environemnt variable approach.
Overall, the changes do not affect core part of blktests. This looks good to me.
I'm not sure if the NVME_TARGET_CONTROL script command line interface will be
stable or not (setup/cleanup, --subsysnqn, --subsys-uuid and --hostnqn options).
I wonder the disucssion with Hannes may affect it.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC blktests v2 1/3] nvme/rc: introduce remote target support
2024-06-12 11:04 ` [RFC blktests v2 1/3] nvme/rc: introduce remote target support Daniel Wagner
@ 2024-06-14 5:09 ` Shinichiro Kawasaki
0 siblings, 0 replies; 8+ messages in thread
From: Shinichiro Kawasaki @ 2024-06-14 5:09 UTC (permalink / raw)
To: Daniel Wagner
Cc: Chaitanya Kulkarni, Hannes Reinecke, linux-block@vger.kernel.org,
linux-nvme@lists.infradead.org
On Jun 12, 2024 / 13:04, Daniel Wagner wrote:
> Most of the NVMEeoF tests are exercising the host code of the nvme
> subsystem. There is no real reason not to run these against a real
> target. We just have to skip the soft target setup and make it possible
> to setup a remote target.
>
> Because all tests use now the common setup/cleanup helpers we just need
> to intercept this call and forward it to an external component.
>
> As we already have various nvme variables to setup the target which we
> should allow to overwrite. Also introduce a NVME_TARGET_CONTROL variable
> which points to a script which gets executed whenever a targets needs to
> be created/destroyed.
>
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
> Documentation/running-tests.md | 9 +++++++
> tests/nvme/rc | 48 +++++++++++++++++++++++++++++++---
> 2 files changed, 53 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/running-tests.md b/Documentation/running-tests.md
> index 968702e76bb5..99dedaebfab0 100644
> --- a/Documentation/running-tests.md
> +++ b/Documentation/running-tests.md
> @@ -120,6 +120,15 @@ The NVMe tests can be additionally parameterized via environment variables.
> - NVME_NUM_ITER: 1000 (default)
> The number of iterations a test should do. This parameter had an old name
> 'nvme_num_iter'. The old name is still usable, but not recommended.
> +- NVME_TRADDR: transport address. Overwrites the default
> + transport address. See also NVME_TARGET_CONTROL.
> +- NVME_HOST_TRADDR: host address. Overwrites the default
> + host address. See also NVME_TARGET_CONTROL.
> +- NVME_TRSVID: transport service id. Overwrite the default
> + transport service ide. See also NVME_TARGET_CONTROL.
> +- NVME_TARGET_CONTROL: When defined, the generic target setup/cleanup code will
> + be skipped and this script gets called. This makes it possible to run
> + the fabric nvme tests against a real target.
It might be helpful to add the lines below:
Refer _nvmet_target_setup() and _nvmet_target_cleanup() for the options
provided to NVME_TARGET_CONTROL.
>
> ### Running nvme-rdma and SRP tests
>
> diff --git a/tests/nvme/rc b/tests/nvme/rc
> index c1ddf412033b..aaa64453fe16 100644
> --- a/tests/nvme/rc
> +++ b/tests/nvme/rc
> @@ -7,9 +7,10 @@
> . common/rc
> . common/multipath-over-rdma
>
> -def_traddr="127.0.0.1"
> +def_traddr="${NVME_TRADDR:-127.0.0.1}"
> +def_host_traddr="${NVME_HOST_TRADDDR:-}"
> def_adrfam="ipv4"
> -def_trsvcid="4420"
> +def_trsvcid="${NVME_TRSVID:-4420}"
> def_remote_wwnn="0x10001100aa000001"
> def_remote_wwpn="0x20001100aa000001"
> def_local_wwnn="0x10001100aa000002"
> @@ -23,6 +24,7 @@ _check_conflict_and_set_default NVME_IMG_SIZE nvme_img_size 1G
> _check_conflict_and_set_default NVME_NUM_ITER nvme_num_iter 1000
> nvmet_blkdev_type=${nvmet_blkdev_type:-"device"}
> NVMET_BLKDEV_TYPES=${NVMET_BLKDEV_TYPES:-"device file"}
> +nvme_target_control="${NVME_TARGET_CONTROL:-}"
>
> _NVMET_TRTYPES_is_valid() {
> local type
> @@ -359,6 +361,10 @@ _cleanup_nvmet() {
> fi
> done
>
> + if [[ -n "${nvme_target_control}" ]]; then
> + return
> + fi
> +
> for port in "${NVMET_CFS}"/ports/*; do
> name=$(basename "${port}")
> echo "WARNING: Test did not clean up port: ${name}"
> @@ -403,11 +409,19 @@ _cleanup_nvmet() {
>
> _setup_nvmet() {
> _register_test_cleanup _cleanup_nvmet
> +
> + if [[ -n "${nvme_target_control}" ]]; then
> + return
> + fi
> +
> modprobe -q nvmet
> +
> if [[ "${nvme_trtype}" != "loop" ]]; then
> modprobe -q nvmet-"${nvme_trtype}"
> fi
> +
> modprobe -q nvme-"${nvme_trtype}"
> +
> if [[ "${nvme_trtype}" == "rdma" ]]; then
> start_soft_rdma
> for i in $(rdma_network_interfaces)
> @@ -425,6 +439,7 @@ _setup_nvmet() {
> fi
> done
> fi
> +
> if [[ "${nvme_trtype}" = "fc" ]]; then
> modprobe -q nvme-fcloop
> _setup_fcloop "${def_local_wwnn}" "${def_local_wwpn}" \
> @@ -873,11 +888,13 @@ _find_nvme_passthru_loop_dev() {
>
> _nvmet_target_setup() {
> local blkdev_type="${nvmet_blkdev_type}"
> + local subsys_uuid="${def_subsys_uuid}"
> + local subsysnqn="${def_subsysnqn}"
> local blkdev
> + local ARGS=()
> local ctrlkey=""
> local hostkey=""
> - local subsysnqn="${def_subsysnqn}"
> - local subsys_uuid="${def_subsys_uuid}"
> + local blkdev
> local port
>
> while [[ $# -gt 0 ]]; do
> @@ -909,6 +926,22 @@ _nvmet_target_setup() {
> esac
> done
>
> + if [[ -n "${hostkey}" ]]; then
> + ARGS+=(--hostkey "${hostkey}")
> + fi
> + if [[ -n "${ctrlkey}" ]]; then
> + ARGS+=(--ctrkey "${ctrlkey}")
> + fi
> +
> + if [[ -n "${nvme_target_control}" ]]; then
> + eval "${nvme_target_control}" setup \
> + --subsysnqn "${subsysnqn}" \
> + --subsys-uuid "${subsys_uuid}" \
> + --hostnqn "${def_hostnqn}" \
> + "${ARGS[@]}" > /dev/null 2>&1
Nit: the line above can be a bit simpler: "${ARGS[@]}" &> /dev/null
> + return
> + fi
> +
> truncate -s "${NVME_IMG_SIZE}" "$(_nvme_def_file_path)"
> if [[ "${blkdev_type}" == "device" ]]; then
> blkdev="$(losetup -f --show "$(_nvme_def_file_path)")"
> @@ -948,6 +981,13 @@ _nvmet_target_cleanup() {
> esac
> done
>
> + if [[ -n "${nvme_target_control}" ]]; then
> + eval "${nvme_target_control}" cleanup \
> + --subsysnqn "${subsysnqn}" \
> + > /dev/null
> + return
> + fi
> +
> _get_nvmet_ports "${subsysnqn}" ports
>
> for port in "${ports[@]}"; do
> --
> 2.45.2
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC blktests v2 2/3] nvme/030: only run against kernel soft target
2024-06-12 11:04 ` [RFC blktests v2 2/3] nvme/030: only run against kernel soft target Daniel Wagner
@ 2024-06-14 5:11 ` Shinichiro Kawasaki
0 siblings, 0 replies; 8+ messages in thread
From: Shinichiro Kawasaki @ 2024-06-14 5:11 UTC (permalink / raw)
To: Daniel Wagner
Cc: Chaitanya Kulkarni, Hannes Reinecke, linux-block@vger.kernel.org,
linux-nvme@lists.infradead.org
On Jun 12, 2024 / 13:04, Daniel Wagner wrote:
> This tests is exercising the target code and not so much the host side.
s/tests/test/
> The problem with nvme/030 is that it depends on interface to interact
> with the target which is not covered by the standard. Thus we can't
> run it against a real target. Just skip it when we run against a
> real target.
>
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
> tests/nvme/030 | 1 +
> tests/nvme/rc | 8 ++++++++
> 2 files changed, 9 insertions(+)
>
> diff --git a/tests/nvme/030 b/tests/nvme/030
> index b1ed8bc20908..672487734332 100755
> --- a/tests/nvme/030
> +++ b/tests/nvme/030
> @@ -13,6 +13,7 @@ requires() {
> _nvme_requires
> _have_loop
> _require_nvme_trtype_is_fabrics
> + _require_kernel_target
The function name sounds generic too much for me. How about
_require_kernel_nvme_target? (The current name reminds me SCSI target).
> }
>
> set_conditions() {
> diff --git a/tests/nvme/rc b/tests/nvme/rc
> index aaa64453fe16..4a2d107bd532 100644
> --- a/tests/nvme/rc
> +++ b/tests/nvme/rc
> @@ -219,6 +219,14 @@ _require_kernel_nvme_fabrics_feature() {
> return 0
> }
>
> +_require_kernel_target() {
> + if [[ -n "${nvme_target_control}" ]]; then
> + SKIP_REASONS+=("Linux kernel soft target not available")
> + return 1;
> + fi
> + return 0
> +}
> +
> _test_dev_nvme_ctrl() {
> echo "/dev/char/$(cat "${TEST_DEV_SYSFS}/device/dev")"
> }
> --
> 2.45.2
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-06-14 5:11 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-12 11:04 [RFC blktests v2 00/03] Add support to run against real target Daniel Wagner
2024-06-12 11:04 ` [RFC blktests v2 1/3] nvme/rc: introduce remote target support Daniel Wagner
2024-06-14 5:09 ` Shinichiro Kawasaki
2024-06-12 11:04 ` [RFC blktests v2 2/3] nvme/030: only run against kernel soft target Daniel Wagner
2024-06-14 5:11 ` Shinichiro Kawasaki
2024-06-12 11:04 ` [RFC blktests v2 3/3] contrib: add remote target setup/cleanup script Daniel Wagner
2024-06-12 12:21 ` Daniel Wagner
2024-06-14 5:05 ` [RFC blktests v2 00/03] Add support to run against real target Shinichiro Kawasaki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).