diff --git a/.gitignore b/.gitignore index bb36b97..3f61a44 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,7 @@ /nvme-cli-2.10.tar.gz /nvme-cli-2.10.2.tar.gz /nvme-cli-2.11.tar.gz +/nvme-cli-2.12.tar.gz +/nvme-cli-2.13.tar.gz +/nvme-cli-2.14.tar.gz +/nvme-cli-2.15.tar.gz diff --git a/nvme-cli-2.16-nvme_list_JSON_regression.patch b/nvme-cli-2.16-nvme_list_JSON_regression.patch new file mode 100644 index 0000000..658fca8 --- /dev/null +++ b/nvme-cli-2.16-nvme_list_JSON_regression.patch @@ -0,0 +1,173 @@ +From 80ad62ba75f1f1dd5b99c6f56769141b48344485 Mon Sep 17 00:00:00 2001 +From: Nilay Shroff +Date: Tue, 5 Aug 2025 15:50:50 +0530 +Subject: [PATCH] nvme-list: make verbose JSON output backward compatible + +The commit 64bed0a87a23 ("nvme-list: fix verbose JSON output for 'nvme +list' command") changed the JSON output format of the nvme list --verbose +command. While the new format is more structured, it introduced a +regression by breaking compatibility with tools and scripts relying on +the previous JSON schema. + +So to restore backward compatibility, we now leverage the existing +--output-format-version option. With this patch, +1. The default --output-format-version=1 retains the original (legacy) JSON +format for nvme list --verbose. +2. If the user explicitly sets --output-format-version=2 then the newer +JSON structure introduced by commit 64bed0a87a23 ("nvme-list: fix verbose +JSON output for 'nvme list' command") is used. + +This ensures that existing users and automation relying on the older format +do not break, while still supporting the newer schema for forward-looking +users. + +Fixes: 64bed0a87a23 ("nvme-list: fix verbose JSON output for 'nvme list' command") +Signed-off-by: Nilay Shroff +Link: https://patch.msgid.link/20250805102055.3375272-1-nilay@linux.ibm.com +Signed-off-by: Daniel Wagner +--- + nvme-print-json.c | 117 ++++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 113 insertions(+), 4 deletions(-) + +diff --git a/nvme-print-json.c b/nvme-print-json.c +index 11b6661624..829ba718e8 100644 +--- a/nvme-print-json.c ++++ b/nvme-print-json.c +@@ -4519,7 +4519,7 @@ static void json_print_detail_list(nvme_subsystem_t s, struct json_object *jss) + obj_add_obj(jss, "Controllers", jctrls); + } + +-static void json_detail_list(nvme_root_t t) ++static void json_detail_list_v2(nvme_root_t t) + { + struct json_object *r = json_create_object(); + struct json_object *jdev = json_create_array(); +@@ -4560,6 +4560,112 @@ static void json_detail_list(nvme_root_t t) + json_print(r); + } + ++static void json_detail_list(nvme_root_t t) ++{ ++ struct json_object *r = json_create_object(); ++ struct json_object *jdev = json_create_array(); ++ ++ nvme_host_t h; ++ nvme_subsystem_t s; ++ nvme_ctrl_t c; ++ nvme_path_t p; ++ nvme_ns_t n; ++ ++ nvme_for_each_host(t, h) { ++ struct json_object *hss = json_create_object(); ++ struct json_object *jsslist = json_create_array(); ++ const char *hostid; ++ ++ obj_add_str(hss, "HostNQN", nvme_host_get_hostnqn(h)); ++ hostid = nvme_host_get_hostid(h); ++ if (hostid) ++ obj_add_str(hss, "HostID", hostid); ++ ++ nvme_for_each_subsystem(h, s) { ++ struct json_object *jss = json_create_object(); ++ struct json_object *jctrls = json_create_array(); ++ struct json_object *jnss = json_create_array(); ++ ++ obj_add_str(jss, "Subsystem", nvme_subsystem_get_name(s)); ++ obj_add_str(jss, "SubsystemNQN", nvme_subsystem_get_nqn(s)); ++ ++ nvme_subsystem_for_each_ctrl(s, c) { ++ struct json_object *jctrl = json_create_object(); ++ struct json_object *jnss = json_create_array(); ++ struct json_object *jpaths = json_create_array(); ++ ++ obj_add_str(jctrl, "Controller", nvme_ctrl_get_name(c)); ++ obj_add_str(jctrl, "Cntlid", nvme_ctrl_get_cntlid(c)); ++ obj_add_str(jctrl, "SerialNumber", nvme_ctrl_get_serial(c)); ++ obj_add_str(jctrl, "ModelNumber", nvme_ctrl_get_model(c)); ++ obj_add_str(jctrl, "Firmware", nvme_ctrl_get_firmware(c)); ++ obj_add_str(jctrl, "Transport", nvme_ctrl_get_transport(c)); ++ obj_add_str(jctrl, "Address", nvme_ctrl_get_address(c)); ++ obj_add_str(jctrl, "Slot", nvme_ctrl_get_phy_slot(c)); ++ ++ nvme_ctrl_for_each_ns(c, n) { ++ struct json_object *jns = json_create_object(); ++ int lba = nvme_ns_get_lba_size(n); ++ uint64_t nsze = nvme_ns_get_lba_count(n) * lba; ++ uint64_t nuse = nvme_ns_get_lba_util(n) * lba; ++ ++ obj_add_str(jns, "NameSpace", nvme_ns_get_name(n)); ++ obj_add_str(jns, "Generic", nvme_ns_get_generic_name(n)); ++ obj_add_int(jns, "NSID", nvme_ns_get_nsid(n)); ++ obj_add_uint64(jns, "UsedBytes", nuse); ++ obj_add_uint64(jns, "MaximumLBA", nvme_ns_get_lba_count(n)); ++ obj_add_uint64(jns, "PhysicalSize", nsze); ++ obj_add_int(jns, "SectorSize", lba); ++ ++ array_add_obj(jnss, jns); ++ } ++ obj_add_obj(jctrl, "Namespaces", jnss); ++ ++ nvme_ctrl_for_each_path(c, p) { ++ struct json_object *jpath = json_create_object(); ++ ++ obj_add_str(jpath, "Path", nvme_path_get_name(p)); ++ obj_add_str(jpath, "ANAState", nvme_path_get_ana_state(p)); ++ ++ array_add_obj(jpaths, jpath); ++ } ++ obj_add_obj(jctrl, "Paths", jpaths); ++ ++ array_add_obj(jctrls, jctrl); ++ } ++ obj_add_obj(jss, "Controllers", jctrls); ++ ++ nvme_subsystem_for_each_ns(s, n) { ++ struct json_object *jns = json_create_object(); ++ ++ int lba = nvme_ns_get_lba_size(n); ++ uint64_t nsze = nvme_ns_get_lba_count(n) * lba; ++ uint64_t nuse = nvme_ns_get_lba_util(n) * lba; ++ ++ obj_add_str(jns, "NameSpace", nvme_ns_get_name(n)); ++ obj_add_str(jns, "Generic", nvme_ns_get_generic_name(n)); ++ obj_add_int(jns, "NSID", nvme_ns_get_nsid(n)); ++ obj_add_uint64(jns, "UsedBytes", nuse); ++ obj_add_uint64(jns, "MaximumLBA", nvme_ns_get_lba_count(n)); ++ obj_add_uint64(jns, "PhysicalSize", nsze); ++ obj_add_int(jns, "SectorSize", lba); ++ ++ array_add_obj(jnss, jns); ++ } ++ obj_add_obj(jss, "Namespaces", jnss); ++ ++ array_add_obj(jsslist, jss); ++ } ++ ++ obj_add_obj(hss, "Subsystems", jsslist); ++ array_add_obj(jdev, hss); ++ } ++ ++ obj_add_array(r, "Devices", jdev); ++ ++ json_print(r); ++} ++ + static struct json_object *json_list_item_obj(nvme_ns_t n) + { + struct json_object *r = json_create_object(); +@@ -4622,9 +4728,12 @@ static void json_list_item(nvme_ns_t n) + + static void json_print_list_items(nvme_root_t t) + { +- if (verbose_mode()) +- json_detail_list(t); +- else ++ if (json_print_ops.flags & VERBOSE) { ++ if (nvme_cfg.output_format_ver == 2) ++ json_detail_list_v2(t); ++ else ++ json_detail_list(t); ++ } else + json_simple_list(t); + } + diff --git a/nvme-cli-2.16-rename_71-nvme-hpe.rules.patch b/nvme-cli-2.16-rename_71-nvme-hpe.rules.patch new file mode 100644 index 0000000..7707737 --- /dev/null +++ b/nvme-cli-2.16-rename_71-nvme-hpe.rules.patch @@ -0,0 +1,32 @@ +From 1141d617dfb3f50783fe80edd49728b8035a955f Mon Sep 17 00:00:00 2001 +From: Daniel Wagner +Date: Fri, 25 Jul 2025 13:30:19 +0200 +Subject: [PATCH] udev: rename 71-nvme-hpe.rules to 71-nvmf-hpe.rules + +The rules file naming is inconsistent with the other rules. Use the +nvmf- prefix. + +Signed-off-by: Daniel Wagner +--- + meson.build | 2 +- + .../udev-rules/{71-nvme-hpe.rules.in => 71-nvmf-hpe.rules.in} | 0 + 2 files changed, 1 insertion(+), 1 deletion(-) + rename nvmf-autoconnect/udev-rules/{71-nvme-hpe.rules.in => 71-nvmf-hpe.rules.in} (100%) + +diff --git a/meson.build b/meson.build +index 1d57748605..3afd8ba3b1 100644 +--- a/meson.build ++++ b/meson.build +@@ -267,7 +267,7 @@ udev_files = [ + '65-persistent-net-nbft.rules', + '70-nvmf-autoconnect.rules', + '70-nvmf-keys.rules', +- '71-nvme-hpe.rules', ++ '71-nvmf-hpe.rules', + '71-nvmf-netapp.rules', + '71-nvmf-vastdata.rules', + ] +diff --git a/nvmf-autoconnect/udev-rules/71-nvme-hpe.rules.in b/nvmf-autoconnect/udev-rules/71-nvmf-hpe.rules.in +similarity index 100% +rename from nvmf-autoconnect/udev-rules/71-nvme-hpe.rules.in +rename to nvmf-autoconnect/udev-rules/71-nvmf-hpe.rules.in diff --git a/nvme-cli.spec b/nvme-cli.spec index 2642394..d1feac6 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -4,7 +4,7 @@ %global nmlibdir %{_prefix}/lib/NetworkManager Name: nvme-cli -Version: 2.11 +Version: 2.15 Release: 2%{?dist} Summary: NVMe management command line interface @@ -14,7 +14,12 @@ Source0: %{url}/archive/v%{version_no_tilde}/%{name}-%{version_no_tilde}. Source1: 99-nvme-nbft-connect.sh Source2: 99-nvme-nbft-no-ignore-carrier.conf -BuildRequires: meson >= 0.50.0 +# https://github.com/linux-nvme/nvme-cli/issues/2886 +Patch0: nvme-cli-2.16-nvme_list_JSON_regression.patch +# https://github.com/linux-nvme/nvme-cli/pull/2880 +Patch1: nvme-cli-2.16-rename_71-nvme-hpe.rules.patch + +BuildRequires: meson >= 0.53 BuildRequires: gcc gcc-c++ BuildRequires: systemd-devel BuildRequires: systemd-rpm-macros @@ -24,8 +29,8 @@ BuildRequires: openssl-devel BuildRequires: kernel-headers %endif -BuildRequires: libnvme-devel >= 1.11 -BuildRequires: json-c-devel >= 0.13 +BuildRequires: libnvme-devel >= 1.15 +BuildRequires: json-c-devel >= 0.14 BuildRequires: asciidoc BuildRequires: xmlto @@ -41,7 +46,7 @@ nvme-cli provides NVM-Express user space tooling for Linux. %build -%meson -Dudevrulesdir=%{_udevrulesdir} -Dsystemddir=%{_unitdir} -Dpdc-enabled=true -Ddocs=all -Ddocs-build=true -Dhtmldir=%{_pkgdocdir} +%meson -Dudevrulesdir=%{_udevrulesdir} -Dsystemddir=%{_unitdir} -Dpdc-enabled=false -Ddocs=all -Ddocs-build=true -Dhtmldir=%{_pkgdocdir} %meson_build @@ -86,6 +91,8 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %{_udevrulesdir}/70-nvmf-autoconnect.rules %{_udevrulesdir}/70-nvmf-keys.rules %{_udevrulesdir}/71-nvmf-netapp.rules +%{_udevrulesdir}/71-nvmf-vastdata.rules +%{_udevrulesdir}/71-nvmf-hpe.rules # Do not install the dracut rule yet. See rhbz 1742764 # /usr/lib/dracut/dracut.conf.d/70-nvmf-autoconnect.conf %{nmlibdir}/dispatcher.d/99-nvme-nbft-connect.sh @@ -93,6 +100,23 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Fri Aug 15 2025 Tomas Bzatek - 2.15-2 +- Fix nvme-list JSON output compatibility +- Rename 71-nvme-hpe.rules to 71-nvmf-hpe.rules + +* Fri Jul 25 2025 Tomas Bzatek - 2.15-1 +- Update to 2.15 + +* Wed Jul 09 2025 Tomas Bzatek - 2.14-1 +- Update to 2.14 +- Disable Persistent Discovery Controllers by default + +* Fri Apr 11 2025 Tomas Bzatek - 2.13-1 +- Update to 2.13 + +* Mon Mar 17 2025 Tomas Bzatek - 2.12-1 +- Update to 2.12 + * Fri Jan 17 2025 Fedora Release Engineering - 2.11-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild diff --git a/sources b/sources index 919e3b6..9336ddd 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (nvme-cli-2.11.tar.gz) = 33de20ad990a3b87fef46fa486832edde41907223aa6b8a47606e605b360745fd7e2054226bf93a59b2a09c6bc04d0b684e4b3bb27c3fc0e6110c64a558cadc0 +SHA512 (nvme-cli-2.15.tar.gz) = 6f4c9fe52883df5424ba28d8b66b00e61f4b6f7226d7385f026c1d3b8aeb473bdf637102d9cf7e049349c4f7e61eccbb33f7400cc09056f74be03a80b7d51c0d