nvme-cli & json vs blktests

Shinichiro Kawasaki shinichiro.kawasaki at wdc.com
Mon May 19 04:08:19 PDT 2025


On May 19, 2025 / 07:49, Christoph Hellwig wrote:
> Hi all,
> 
> I recently did a long overdue update of blktests on my main test
> machine, and a large part of the nvme tests started failing.  I
> eventually bisected this down to:
> 
> commit 444f0df9f0c537335f59c1721240212852656e5b
> Author: Hannes Reinecke <hare at suse.de>
> Date:   Wed Oct 30 15:51:45 2024 +0900
> 
>     nvme: check for controller device in _nvme_connect_subsys()
> 
> 
> which adds a requirements for json output from nvme connect, and
> just silently fails if not present.

I uninstalled json-c-devel package from my Fedora system, and built nvme-cli.
Then confirmed the slient fail. That is a painful pit-fall.

...

> 
> Can we get proper feature check for json support in blktests and maybe
> make the nvme-cli build a little less arcane?

As to blktests, I quickly created a patch below, and confirmed it informs that
nvme-cli is missing json output support. Will do some more testing and post as
a formal patch.

diff --git a/tests/nvme/rc b/tests/nvme/rc
index d86dc13..f5880ed 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -55,7 +55,7 @@ _set_nvmet_blkdev_type() {
 }
 
 _nvme_requires() {
-	_have_program nvme
+	_have_nvme_cli_with_json_support
 	_require_nvme_test_img_size 4m
 	case ${nvme_trtype} in
 	loop)
@@ -626,6 +626,14 @@ _have_systemd_tlshd_service() {
 	fi
 }
 
+_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")
+	fi
+}
+
 _have_libnvme_ver() {
 	local ver
 



More information about the Linux-nvme mailing list