Skip to content

Commit 3b2355a

Browse files
committed
common/nvme: introduce _have_nvme_cli_with_json_support()
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=". Reviewed-by: Chaitanya Kulkarni <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Daniel Wagner <[email protected]> Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
1 parent cf2c0f8 commit 3b2355a

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

common/nvme

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ _require_nvme_trtype_is_fabrics() {
6262
return 0
6363
}
6464

65+
_have_nvme_cli_with_json_support() {
66+
_have_program nvme || return $?
67+
68+
if ! nvme list --output-format=json &> /dev/null; then
69+
SKIP_REASONS+=("nvme-cli does not support json output format")
70+
return 1
71+
fi
72+
return 0
73+
}
74+
6575
_nvme_fcloop_add_rport() {
6676
local local_wwnn="$1"
6777
local local_wwpn="$2"
@@ -415,7 +425,7 @@ _nvme_connect_subsys() {
415425
if [[ ${concat} = true ]]; then
416426
ARGS+=(--concat)
417427
fi
418-
ARGS+=(-o json)
428+
ARGS+=(--output-format=json)
419429
connect=$(nvme connect "${ARGS[@]}" 2> /dev/null)
420430

421431
# Wait until device file and sysfs attributes get ready

0 commit comments

Comments
 (0)