* [PATCH blktests 1/2] common/nvme: introduce _have_nvme_cli_with_json_support()
2025-05-20 6:18 [PATCH blktests 0/2] nvme: check that nvme-cli supports json output format Shin'ichiro Kawasaki
@ 2025-05-20 6:18 ` Shin'ichiro Kawasaki
2025-05-20 19:18 ` Chaitanya Kulkarni
2025-05-20 6:18 ` [PATCH blktests 2/2] nvme/rc, md/001: check that nvme-cli supports json output format Shin'ichiro Kawasaki
` (3 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Shin'ichiro Kawasaki @ 2025-05-20 6:18 UTC (permalink / raw)
To: linux-nvme
Cc: Christoph Hellwig, Daniel Wagner, Hannes Reinecke,
Shin'ichiro Kawasaki
To check if the nvme command supports json output format, introduce the
helper function _have_nvme_cli_with_json_support(), which verifies the
option "--output-format=" works. While at it, replace the short option
"-o" in _nvme_connect_subsys() with the long option "--output-format=".
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
common/nvme | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/common/nvme b/common/nvme
index ac1bbe7..04d167b 100644
--- a/common/nvme
+++ b/common/nvme
@@ -62,6 +62,16 @@ _require_nvme_trtype_is_fabrics() {
return 0
}
+_have_nvme_cli_with_json_support() {
+ _have_program nvme || return $?
+
+ if ! nvme list --output-format=json &> /dev/null; then
+ SKIP_REASONS+=("nvme-cli does not support json output format")
+ return 1
+ fi
+ return 0
+}
+
_nvme_fcloop_add_rport() {
local local_wwnn="$1"
local local_wwpn="$2"
@@ -415,7 +425,7 @@ _nvme_connect_subsys() {
if [[ ${concat} = true ]]; then
ARGS+=(--concat)
fi
- ARGS+=(-o json)
+ ARGS+=(--output-format=json)
connect=$(nvme connect "${ARGS[@]}" 2> /dev/null)
# Wait until device file and sysfs attributes get ready
--
2.49.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH blktests 2/2] nvme/rc, md/001: check that nvme-cli supports json output format
2025-05-20 6:18 [PATCH blktests 0/2] nvme: check that nvme-cli supports json output format Shin'ichiro Kawasaki
2025-05-20 6:18 ` [PATCH blktests 1/2] common/nvme: introduce _have_nvme_cli_with_json_support() Shin'ichiro Kawasaki
@ 2025-05-20 6:18 ` Shin'ichiro Kawasaki
2025-05-20 19:18 ` Chaitanya Kulkarni
2025-05-20 7:10 ` [PATCH blktests 0/2] nvme: " Daniel Wagner
` (2 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Shin'ichiro Kawasaki @ 2025-05-20 6:18 UTC (permalink / raw)
To: linux-nvme
Cc: Christoph Hellwig, Daniel Wagner, Hannes Reinecke,
Shin'ichiro Kawasaki
When nvme-cli is built on a system without the json-c library, the nvme
command does not support the json output format. Consequently, the
"-o json" option, or in the long form "--output-format=json", of the
nvme command fails. It causes the helper function _nvme_connect_subsys()
to break. This leads to silent failures in many test cases in the nvme
test group as well as the test case md/001.
To inform blktests users this prerequisite, call the helper function
_have_nvme_cli_with_json_support(). As to the nvme test group, do the
check in group_requires() so that the check is done only once for all of
the test cases in the group. If the format is unsupported, the nvme test
group and the test case md/001 are skipped, and the reason to skip is
printed. This change makes the nvme command existence check in
_nvme_requires() redundant, then remove it.
Link: https://lore.kernel.org/linux-nvme/20250519054905.GA6156@lst.de/
Fixes: 444f0df9f0c5 ("nvme: check for controller device in _nvme_connect_subsys()")
Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
tests/md/001 | 1 +
tests/nvme/rc | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/md/001 b/tests/md/001
index f1d92c8..ca7c56a 100755
--- a/tests/md/001
+++ b/tests/md/001
@@ -26,6 +26,7 @@ requires() {
_have_driver dm-mod
_have_driver raid1
+ _have_nvme_cli_with_json_support
_require_nvme_trtype tcp
_have_brd
}
diff --git a/tests/nvme/rc b/tests/nvme/rc
index d86dc13..9dbd1ce 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -55,7 +55,6 @@ _set_nvmet_blkdev_type() {
}
_nvme_requires() {
- _have_program nvme
_require_nvme_test_img_size 4m
case ${nvme_trtype} in
loop)
@@ -123,6 +122,7 @@ group_setup() {
group_requires() {
_have_root
_NVMET_TRTYPES_is_valid
+ _have_nvme_cli_with_json_support
}
group_device_requires() {
--
2.49.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH blktests 2/2] nvme/rc, md/001: check that nvme-cli supports json output format
2025-05-20 6:18 ` [PATCH blktests 2/2] nvme/rc, md/001: check that nvme-cli supports json output format Shin'ichiro Kawasaki
@ 2025-05-20 19:18 ` Chaitanya Kulkarni
0 siblings, 0 replies; 8+ messages in thread
From: Chaitanya Kulkarni @ 2025-05-20 19:18 UTC (permalink / raw)
To: Shin'ichiro Kawasaki, linux-nvme@lists.infradead.org
Cc: Christoph Hellwig, Daniel Wagner, Hannes Reinecke
On 5/19/25 23:18, Shin'ichiro Kawasaki wrote:
> When nvme-cli is built on a system without the json-c library, the nvme
> command does not support the json output format. Consequently, the
> "-o json" option, or in the long form "--output-format=json", of the
> nvme command fails. It causes the helper function _nvme_connect_subsys()
> to break. This leads to silent failures in many test cases in the nvme
> test group as well as the test case md/001.
>
> To inform blktests users this prerequisite, call the helper function
> _have_nvme_cli_with_json_support(). As to the nvme test group, do the
> check in group_requires() so that the check is done only once for all of
> the test cases in the group. If the format is unsupported, the nvme test
> group and the test case md/001 are skipped, and the reason to skip is
> printed. This change makes the nvme command existence check in
> _nvme_requires() redundant, then remove it.
>
> Link:https://lore.kernel.org/linux-nvme/20250519054905.GA6156@lst.de/
> Fixes: 444f0df9f0c5 ("nvme: check for controller device in _nvme_connect_subsys()")
> Reported-by: Christoph Hellwig<hch@lst.de>
> Signed-off-by: Shin'ichiro Kawasaki<shinichiro.kawasaki@wdc.com>
Looks good.
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
-ck
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH blktests 0/2] nvme: check that nvme-cli supports json output format
2025-05-20 6:18 [PATCH blktests 0/2] nvme: check that nvme-cli supports json output format Shin'ichiro Kawasaki
2025-05-20 6:18 ` [PATCH blktests 1/2] common/nvme: introduce _have_nvme_cli_with_json_support() Shin'ichiro Kawasaki
2025-05-20 6:18 ` [PATCH blktests 2/2] nvme/rc, md/001: check that nvme-cli supports json output format Shin'ichiro Kawasaki
@ 2025-05-20 7:10 ` Daniel Wagner
2025-05-20 13:34 ` Christoph Hellwig
2025-05-28 9:27 ` Shinichiro Kawasaki
4 siblings, 0 replies; 8+ messages in thread
From: Daniel Wagner @ 2025-05-20 7:10 UTC (permalink / raw)
To: Shin'ichiro Kawasaki
Cc: linux-nvme, Christoph Hellwig, Daniel Wagner, Hannes Reinecke
Looks good to me.
For both patches:
Reviewed-by: Daniel Wagner <dwagner@suse.de>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH blktests 0/2] nvme: check that nvme-cli supports json output format
2025-05-20 6:18 [PATCH blktests 0/2] nvme: check that nvme-cli supports json output format Shin'ichiro Kawasaki
` (2 preceding siblings ...)
2025-05-20 7:10 ` [PATCH blktests 0/2] nvme: " Daniel Wagner
@ 2025-05-20 13:34 ` Christoph Hellwig
2025-05-28 9:27 ` Shinichiro Kawasaki
4 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2025-05-20 13:34 UTC (permalink / raw)
To: Shin'ichiro Kawasaki
Cc: linux-nvme, Christoph Hellwig, Daniel Wagner, Hannes Reinecke
The changes looks great:
Reviewed-by: Christoph Hellwig <hch@lst.de>
Although to me they would be easier to follow in one patch instead
of two.
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH blktests 0/2] nvme: check that nvme-cli supports json output format
2025-05-20 6:18 [PATCH blktests 0/2] nvme: check that nvme-cli supports json output format Shin'ichiro Kawasaki
` (3 preceding siblings ...)
2025-05-20 13:34 ` Christoph Hellwig
@ 2025-05-28 9:27 ` Shinichiro Kawasaki
4 siblings, 0 replies; 8+ messages in thread
From: Shinichiro Kawasaki @ 2025-05-28 9:27 UTC (permalink / raw)
To: linux-nvme@lists.infradead.org; +Cc: hch, Daniel Wagner, Hannes Reinecke
On May 20, 2025 / 15:18, Shin'ichiro Kawasaki wrote:
> The commit 444f0df9f0c5 ("nvme: check for controller device in
> _nvme_connect_subsys()") assumed that the nvme command always supports
> json output format. However, when nvme-cli is built on a system without
> the json-c library, the nvme command does not support the format. This
> leads to silent failures in many test cases in the nvme test group [1].
>
> This series address the problem. The first patch introduces a helper
> function to prepare for the fix. The second patch fixes the problem by
> checking that the nvme command supports the json format.
>
> [1] https://lore.kernel.org/linux-nvme/20250519054905.GA6156@lst.de/
FYI, I applied this series.
^ permalink raw reply [flat|nested] 8+ messages in thread