Skip to content

plugins: move the top-level commands into plugins - #4447

Merged
igaw merged 41 commits into
linux-nvme:masterfrom
dwsuse:modularize
Nov 19, 2026
Merged

igaw merged 41 commits into
linux-nvme:masterfrom
dwsuse:modularize

Conversation

@dwsuse

@dwsuse dwsuse commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Move all top-level commands out of the nvme binary into plugins. This continues #4420 and #4445: nvme itself keeps only the infrastructure (option parsing, plugin loader, output and JSON handling, global config, privsep). Every command lives in a plugin, which nvme loads when the command is used.

Layout

The series first moves the plugins of nvme itself, the ones marked .core = true, into plugins/cmds-<plugin>, apart from the vendor plugins. They set plugin_name, so their names on the command line and the values of -Dplugins don't change. Modules are named after the directory of their plugin, e.g. cmds-id.so for nvme id and sandisk.so for nvme sndk; a generated table maps plugin names to modules. The ocp tests move along into tests/cli/cmds_ocp and tests/e2e/plugins/cmds_ocp (Python packages can't have a -). The new plugins for the top-level commands follow the same pattern (plugins/cmds-io, ...), so nothing has to move twice.

It also fixes the RPMBS output of rpmb info on big-endian hosts, which the new output test pins.

How it works

A plugin lists its top-level commands and aliases in its meson.build (plugin_commands, plugin_command_aliases), and the build generates a command index from these lists. When nvme doesn't know a top-level command, it looks it up in the index, loads that plugin and looks again. Abbreviations resolve as before, and an ambiguous prefix loads nothing. A test checks the index against the commands the plugins register. Built-in builds (static, Windows, fuzz) don't need the index.

The plugins

Plugin Commands
cmds-deprecated the deprecated top-level aliases
cmds-io read, write, compare, dsm, copy, flush, verify, write-zeroes, write-uncor, get-lba-status, capacity-mgmt
cmds-admin format, sanitize, sanitize-ns, device-self-test, reset, subsystem-reset, ns-rescan, virt-mgmt, lockdown
cmds-regs show-regs, get-reg, set-reg, get-property, set-property
cmds-passthru admin-passthru, io-passthru
cmds-list list, list-subsys, show-topology, top
cmds-fabrics discover, connect, connect-all, disconnect, disconnect-all, dim, gen-hostnqn, show-hostnqn
feat (plugins/cmds-feat) also get-feature and set-feature
log (plugins/cmds-log) also get-log

The printers and helpers each group uses move along. The resv report, directive and RPMBS printers move into resv, dir and id.

Shared code makes its plugin a provider, as before:

  • feat provides the feature decoders to log and ocp.
  • cmds-list provides the list row printer to zns.
  • cmds-fabrics provides the fabrics helpers to config.
  • id provides the RPMBS printer to rpmb.

Size

Release build, stripped:

master this PR change
nvme 586,320 214,824 −63.4 %
nvme, zstd -19 216,318 87,876 −59.4 %
loaded for id-ctrl 722,704 351,216 −51.4 %
loaded for smart-log 782,696 415,456 −46.9 %
nvme + all plugins 2,779,424 2,884,632 +3.8 % (zstd +0.9 %)

initramfs

An initramfs needs the plugins of the commands it runs: dracut's nvmf module runs connect-all, nbft show and list-subsys, so it needs cmds-fabrics.so, cmds-nbft.so and cmds-list.so. I'll add that to dracut-ng/dracut#2825; a boot test with this branch and that change passes the NVMe/TCP and NBFT boot scenarios.

Testing

  • Output: help and command metadata of all 489 commands, nvme --help and the resolution of all 1263 command prefixes are identical to master. Each group's output was compared byte for byte against master in all formats, with and without NVME_SANDBOX=1, on seeded random device data and fake sysfs trees.
  • Builds: each commit builds and passes the tests on its own. The full suite passes in the plugin and built-in builds, without json-c, static, with the Windows cross build and on FreeBSD.
  • Lab: a real NVMe/TCP discover/connect/disconnect works.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The command-modules test guard allows valid subset builds without zns, but an unconditionally run test requires zns.so, causing the suite to fail.

1 open issue
What changed in this PR

This continues #4420 and #4445 by moving top-level commands and their printers into plugins, leaving the nvme binary focused on shared infrastructure.

Changes:

  • Organizes core plugins under plugins/cmds-* and supports on-demand loading of top-level commands through a command index.
  • Moves command-specific printers and helpers into their owning plugins, with explicit provider dependencies.
  • Expands output, sandbox, and module-loading tests; fixes RPMBS byte order on big-endian hosts and documents initramfs requirements.
File Description
tests/​unit/​py/​meson.build Adds command-index validation and updates schema paths.
tests/​unit/​c/​test-regs.c Updates the register header include.
tests/​unit/​c/​test-iostat.c Uses the relocated I/O statistics header.
tests/​unit/​c/​meson.build Builds tests from relocated plugin sources.
tests/​fuzz/​meson.build Updates the I/O statistics source path.
tests/​fuzz/​fuzz-iostat.c Uses the relocated statistics header.
tests/​e2e/​plugins/​ocp/​ocp_telemetry_layout.py Updates a source-path reference in documentation.
tests/​e2e/​plugins/​ocp/​ocp_c4_layout.py Updates a source-path comment.
tests/​e2e/​plugins/​ocp/​ocp_c0_layout.py Updates source-path comments and documentation.
tests/​cli/​nvme_zns_test.py Skips get-log coverage when unavailable.
tests/​cli/​nvme_sed_test.py Updates the plugin path in documentation.
tests/​cli/​nvme_rpmb_test.py Adds RPMBS output and sandbox checks.
tests/​cli/​nvme_resv_test.py Adds reservation-report sandbox checks.
tests/​cli/​nvme_registers_test.py Adds binary output and sandbox checks.
tests/​cli/​nvme_privsep_test.py Checks privilege handling for module commands.
tests/​cli/​nvme_print_test.py Extends printer coverage to RPMBS and LBA status.
tests/​cli/​nvme_pif_sts_test.py Updates the implementation path in documentation.
tests/​cli/​nvme_mock.py Exposes get-log availability to tests.
tests/​cli/​nvme_keys_test.py Probes deprecated-command availability directly.
tests/​cli/​nvme_io_test.py Adds LBA-status output and sandbox coverage.
tests/​cli/​nvme_fuzz_record_test.py Handles builds without get-log.
tests/​cli/​nvme_features_test.py Tests feature-printer dry-run behavior.
tests/​cli/​nvme_fdp_test.py Skips get-log tests when unavailable.
tests/​cli/​nvme_dir_receive_test.py Adds directive-printer sandbox checks.
tests/​cli/​meson.build Registers module tests and get-log availability.
src/​plugin.h Defines help-group ordering for plugin commands.
src/​plugin-loader.h Declares the command-index interface.
src/​plugin-loader.c Exposes the generated command index.
src/​nvme.c Defines group order and initializes empty command lists.
src/​nvme-resources.h Defines shared topology resource tables.
src/​nvme-resources.c Implements shared topology resource management.
src/​nvme-print-stdout.h Removes plugin-owned printer declarations.
src/​nvme-print-stdout-log.c Removes the relocated discovery printer.
src/​nvme-print-stdout-id.c Removes the relocated RPMBS printer.
src/​nvme-print-json.h Removes the plugin-owned feature declaration.
src/​nvme-print-binary.c Removes command-specific binary printers.
src/​nvme-cmds-common.h Removes structures now owned by plugins.
src/​meson.build Removes command sources from the core binary.
plugins/​zns/​meson.build Removes the old ZNS build definition.
plugins/​wdc/​wdc-nvme.c Uses the relocated identify interface.
plugins/​utils/​meson.build Removes the old utilities build definition.
plugins/​solidigm/​solidigm-nvme.c Updates identify and OCP includes.
plugins/​solidigm/​solidigm-log-page-dir.c Updates log and OCP includes.
plugins/​solidigm/​solidigm-internal-logs.c Uses the relocated log-printer interface.
plugins/​shannon/​shannon-nvme.c Uses the relocated identify interface.
plugins/​sed/​meson.build Removes the old SED build definition.
plugins/​security/​meson.build Removes the old security build definition.
plugins/​rpmb/​meson.build Removes the old RPMB build definition.
plugins/​resv/​meson.build Removes the old reservation build definition.
plugins/​registry/​meson.build Removes the old registry build definition.
plugins/​ocp/​meson.build Removes the old OCP build definition.
plugins/​nvme-mi/​meson.build Removes the old NVMe-MI build definition.
plugins/​nvidia/​nvidia-nvme.c Uses the relocated identify interface.
plugins/​ns/​meson.build Removes the old namespace build definition.
plugins/​micron/​micron-nvme.c Uses the relocated identify interface.
plugins/​memblaze/​memblaze-nvme.c Replaces a feature-helper call with its constant label.
plugins/​mangoboost/​mangoboost-nvme.c Uses the relocated identify interface.
plugins/​log/​meson.build Removes the old log build definition.
plugins/​lm/​meson.build Removes the old live-migration build definition.
plugins/​intel/​intel-nvme.c Uses the relocated identify interface.
plugins/​id/​meson.build Removes the old identify build definition.
plugins/​ibm/​ibm-nvme.c Uses the relocated log-printer interface.
plugins/​huawei/​huawei-nvme.c Uses the relocated identify interface.
plugins/​fw/​meson.build Removes the old firmware build definition.
plugins/​feat/​meson.build Removes the old feature build definition.
plugins/​fdp/​meson.build Removes the old FDP build definition.
plugins/​dell/​dell-nvme.c Uses the relocated identify interface.
plugins/​cmds-zns/​zns.c Includes the list-provider printer interface.
plugins/​cmds-zns/​zns-print.h Relocates the ZNS printer interface.
plugins/​cmds-zns/​zns-print.c Relocates ZNS printer dispatch.
plugins/​cmds-zns/​zns-print-binary.c Relocates ZNS binary printers.
plugins/​cmds-zns/​meson.build Preserves the ZNS name and declares its list dependency.
plugins/​cmds-utils/​utils.c Relocates utilities command registration.
plugins/​cmds-utils/​meson.build Builds utilities under the new layout.
plugins/​cmds-utils/​command-metadata.h Relocates the command-metadata interface.
plugins/​cmds-sed/​sedopal_cmd.h Relocates the SED command interface.
plugins/​cmds-sed/​meson.build Preserves the SED plugin name.
plugins/​cmds-security/​meson.build Preserves the security plugin name.
plugins/​cmds-rpmb/​rpmb.c Uses the identify provider and corrects RPMBS byte order.
plugins/​cmds-rpmb/​meson.build Declares the identify-provider dependency.
plugins/​cmds-resv/​resv-print.h Defines the reservation printer interface.
plugins/​cmds-resv/​resv-print.c Dispatches reservation printers through the sandbox.
plugins/​cmds-resv/​resv-print-stdout.c Moves reservation text output into the plugin.
plugins/​cmds-resv/​resv-print-json.c Moves reservation JSON output into the plugin.
plugins/​cmds-resv/​resv-print-binary.c Moves reservation binary output into the plugin.
plugins/​cmds-resv/​resv-plugin.c Includes the local printer interface.
plugins/​cmds-resv/​meson.build Builds reservation commands and printers together.
plugins/​cmds-regs/​regs-print.h Defines register printer operations and styles.
plugins/​cmds-regs/​regs-print.c Dispatches register printers through the sandbox.
plugins/​cmds-regs/​regs-print-stdout.c Moves register text output into the plugin.
plugins/​cmds-regs/​regs-print-json.c Moves register JSON output into the plugin.
plugins/​cmds-regs/​regs-print-binary.c Moves register binary output into the plugin.
plugins/​cmds-regs/​nvme-regs.h Relocates register definitions and interfaces.
plugins/​cmds-regs/​meson.build Builds and indexes register commands.
plugins/​cmds-regs/​cmds-regs-plugin.c Registers commands through plugin initialization.
plugins/​cmds-regs/​bitfields.h Relocates the bitfield interface.
plugins/​cmds-regs/​bitfields.c Relocates bitfield formatting.
plugins/​cmds-registry/​meson.build Builds registry under its existing plugin name.
plugins/​cmds-passthru/​meson.build Builds and indexes passthrough commands.
plugins/​cmds-passthru/​cmds-passthru-plugin.c Localizes configuration and adds plugin initialization.
plugins/​cmds-ocp/​ocp-utils.h Relocates the OCP utility interface.
plugins/​cmds-ocp/​ocp-utils.c Relocates OCP utility implementations.
plugins/​cmds-ocp/​ocp-types.h Relocates OCP type definitions.
plugins/​cmds-ocp/​ocp-print.h Relocates the OCP printer interface.
plugins/​cmds-ocp/​ocp-print-stdout.c Updates the log-provider include.
plugins/​cmds-ocp/​ocp-print-json.c Updates the log-provider include.
plugins/​cmds-ocp/​ocp-print-binary.c Relocates OCP binary printers.
plugins/​cmds-ocp/​ocp-nvme.c Includes the feature-provider interface.
plugins/​cmds-ocp/​ocp-hardware-component-log.h Relocates hardware-log definitions.
plugins/​cmds-ocp/​ocp-fw-activation-history.h Relocates firmware-history definitions.
plugins/​cmds-ocp/​ocp-fw-activation-history.c Relocates the firmware-history command.
plugins/​cmds-ocp/​ocp-clear-features.h Relocates feature-command declarations.
plugins/​cmds-ocp/​ocp-clear-features.c Includes the feature-provider interface.
plugins/​cmds-ocp/​meson.build Declares log and feature dependencies.
plugins/​cmds-nvme-mi/​meson.build Preserves the NVMe-MI plugin name.
plugins/​cmds-ns/​meson.build Builds namespace commands in the new layout.
plugins/​cmds-nbft/​meson.build Builds NBFT commands in the new layout.
plugins/​cmds-log/​meson.build Adds get-log and the feature-provider dependency.
plugins/​cmds-log/​log-print-stdout.c Includes feature decoding from its provider.
plugins/​cmds-log/​log-print-json.c Includes feature decoding from its provider.
plugins/​cmds-log/​log-plugin.c Registers the top-level get-log command.
plugins/​cmds-log/​get-log.h Declares get-log registration.
plugins/​cmds-log/​get-log.c Moves get-log and loads decoder plugins.
plugins/​cmds-lm/​meson.build Preserves the live-migration plugin name.
plugins/​cmds-lm/​lm-print.h Relocates the live-migration printer interface.
plugins/​cmds-lm/​lm-print.c Relocates live-migration printer dispatch.
plugins/​cmds-lm/​lm-print-binary.c Relocates live-migration binary output.
plugins/​cmds-list/​nvme-iostat.h Relocates the I/O statistics interface.
plugins/​cmds-list/​meson.build Builds enumeration commands and optional top support.
plugins/​cmds-list/​dashboard.h Relocates the dashboard interface.
plugins/​cmds-list/​cmds-list-print.h Defines topology printers and the shared row printer.
plugins/​cmds-list/​cmds-list-print-stdout-top.c Uses the plugin-local printer interface.
plugins/​cmds-list/​cmds-list-plugin.c Registers enumeration commands as a plugin.
plugins/​cmds-keys/​meson.build Preserves the keys plugin name.
plugins/​cmds-io/​meson.build Builds and indexes I/O commands.
plugins/​cmds-io/​cmds-io-print.h Defines the LBA-status printer interface.
plugins/​cmds-io/​cmds-io-print.c Dispatches LBA-status output through the sandbox.
plugins/​cmds-io/​cmds-io-print-stdout.c Moves LBA-status text output into the plugin.
plugins/​cmds-io/​cmds-io-print-json.c Moves LBA-status JSON output into the plugin.
plugins/​cmds-io/​cmds-io-print-binary.c Moves LBA-status binary output into the plugin.
plugins/​cmds-io/​cmds-io-plugin.c Registers I/O commands as a plugin.
plugins/​cmds-io-mgmt/​meson.build Preserves the I/O-management plugin name.
plugins/​cmds-id/​nvme-models.h Relocates the model-name interface.
plugins/​cmds-id/​meson.build Builds identify sources in the new layout.
plugins/​cmds-id/​id.h Exposes RPMBS printing to consumers.
plugins/​cmds-id/​id-print.h Adds the RPMBS printer operation.
plugins/​cmds-id/​id-print.c Dispatches RPMBS output through identify printers.
plugins/​cmds-id/​id-print-stdout.c Incorporates RPMBS text decoding.
plugins/​cmds-id/​id-print-json.c Incorporates RPMBS JSON decoding.
plugins/​cmds-id/​id-print-binary.c Relocates identify binary printers.
plugins/​cmds-fw/​meson.build Preserves the firmware plugin name.
plugins/​cmds-feat/​meson.build Builds feature printers and indexes top-level commands.
plugins/​cmds-feat/​feat-print.h Exposes feature printers and shared decoding helpers.
plugins/​cmds-feat/​feat-print-binary.c Moves feature binary output into the plugin.
plugins/​cmds-feat/​feat-nvme.c Registers top-level feature commands.
plugins/​cmds-feat/​feat-cmds.h Exposes the top-level feature command table.
plugins/​cmds-feat/​feat-cmds.c Localizes feature configuration and command ownership.
plugins/​cmds-fdp/​meson.build Preserves the FDP plugin name.
plugins/​cmds-fdp/​fdp-print.h Relocates the FDP printer interface.
plugins/​cmds-fdp/​fdp-print.c Relocates FDP dispatch and decoder registration.
plugins/​cmds-fdp/​fdp-print-binary.c Relocates FDP binary printers.
plugins/​cmds-fabrics/​pre-os.h Relocates the pre-OS connection interface.
plugins/​cmds-fabrics/​meson.build Builds fabrics helpers, printers, and indexed commands.
plugins/​cmds-fabrics/​fabrics.c Uses plugin-owned discovery and configuration printers.
plugins/​cmds-fabrics/​fabrics-print.h Defines fabrics printer operations.
plugins/​cmds-fabrics/​fabrics-print.c Adds printer dispatch and discovery decoder registration.
plugins/​cmds-fabrics/​fabrics-print-binary.c Moves discovery binary output into the plugin.
plugins/​cmds-fabrics/​config-convert.h Relocates configuration-conversion interfaces.
plugins/​cmds-fabrics/​cmds-fabrics-plugin.c Registers fabrics commands and the discovery decoder.
plugins/​cmds-exclusion/​meson.build Preserves the exclusion plugin name.
plugins/​cmds-dir/​meson.build Builds directive commands with their printers.
plugins/​cmds-dir/​dir-print.h Defines directive printers and stream-count helpers.
plugins/​cmds-dir/​dir-print.c Dispatches directive output through the sandbox.
plugins/​cmds-dir/​dir-print-binary.c Moves directive binary output into the plugin.
plugins/​cmds-dir/​dir-plugin.c Includes the local directive printer interface.
plugins/​cmds-deprecated/​meson.build Indexes deprecated commands and aliases.
plugins/​cmds-deprecated/​deprecated-plugin.c Registers deprecated commands through plugin initialization.
plugins/​cmds-config/​meson.build Declares the fabrics-provider dependency.
plugins/​cmds-config/​config-nvme.c Uses relocated fabrics interfaces.
plugins/​cmds-config/​config-create.h Relocates configuration-creation declarations.
plugins/​cmds-config/​config-create.c Uses the fabrics-provider header.
plugins/​cmds-admin/​meson.build Builds and indexes administration commands.
plugins/​cmds-admin/​cmds-admin.h Shares administration command tables.
plugins/​cmds-admin/​cmds-admin-security.c Exposes the security command table.
plugins/​cmds-admin/​cmds-admin-print.h Defines the relatives printer interface.
plugins/​cmds-admin/​cmds-admin-print.c Dispatches relatives printing in process.
plugins/​cmds-admin/​cmds-admin-print-stdout.c Moves relatives output into the admin plugin.
plugins/​cmds-admin/​cmds-admin-plugin.c Registers controller, media, and security groups.
plugins/​cmds-admin/​cmds-admin-ctrl.c Exposes the controller command table.
plugins/​amzn/​amzn-nvme.c Uses the relocated identify interface.
NEWS.md Announces command modules and initramfs requirements.
meson.build Removes the obsolete deprecated-command define.
MAINTAINERS Updates the OCP ownership path.
Documentation/​TESTING.md Updates the documented statistics source path.
Documentation/​PRIVSEP.md Clarifies plugin printer sandbox exceptions.
Documentation/​BUILDING.md Documents command modules and deployment dependencies.

Review effort: Balanced

Comment thread tests/cli/meson.build Resolved
@dwsuse
dwsuse force-pushed the modularize branch 2 times, most recently from b7c9392 to e83a547 Compare November 19, 2026 10:58
rpmb_get_regs converts the RPMBS field to host byte order, and rpmb info
passes it to nvme_show_id_ctrl_rpmbs, which converts it once more. On a
big-endian host the output shows the bytes swapped.

Pass the field in little-endian byte order, as the printer expects.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
The plugins of nvme itself are about to move into plugins/cmds-<plugin>,
next to the plugins which will hold the top-level commands. Their names
on the command line and in the plugins option stay the same.

Look for a plugin in plugins/cmds-<plugin> when there is such a
directory, and in plugins/<plugin> otherwise. The plugins option and
plugin_needs keep naming the plugins.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
A module is named after its plugin, and plugin_name can differ from the
directory: plugins/sandisk builds sndk.so. The plugins of nvme are about
to move into plugins/cmds-<plugin> with their names unchanged, which
would leave the modules named differently from their directories.

Name a module, and its symbols, after the directory of its plugin.
plugin-names.h maps the name of a plugin to its module, which
nvme_load_plugin uses for "nvme <plugin>".

nvme_load_plugins loads all modules in the order of their plugin names,
not their file names, so the plugins keep their order in the command
metadata.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Move the plugins of nvme itself, the ones with .core = true, into
plugins/cmds-<plugin>, which tells them apart from the vendor plugins.
They set plugin_name, so their names on the command line and the values
of the plugins option stay the same. Their modules are named after the
directory, e.g. cmds-id.so.

Move the tests of the ocp plugin along, into tests/cli/cmds_ocp and
tests/e2e/plugins/cmds_ocp: Python can't import a package with a '-'.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
The top-level commands are compiled into nvme. A plugin can add them
too, but nvme loads a plugin only for "nvme <plugin>", so its top-level
commands would only exist once all plugins are loaded.

A plugin now lists its top-level commands and their aliases in
plugin_commands and plugin_command_aliases in its meson.build. The build
generates an index of them, command-index.h, as it generates
plugin-names.h. When nvme doesn't have a top-level command, it looks the
name up in the index, loads the plugin of the command and looks again.
The index takes part in the prefix match like the commands themselves,
so an abbreviation selects the same command as before. A command whose
plugin is missing is "not installed", as a plugin is.

A plugin with only top-level commands sets plugin_extension to false. It
is no "nvme <plugin>", so plugin-names.h leaves it out.

The help lists the groups of top-level commands in the order the program
registers them. A plugin registers its group later, so the program now
names the order of the groups in builtin_groups, and plugin_add_group
puts a group at its place. The deprecated commands get the title
"Deprecated" for this. The help lists none of them, nor the title.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
nvme loads the plugin of a top-level command from the index the plugins
declare in their meson.build. A command missing from it doesn't exist
until all plugins are loaded, and a wrong entry loads the wrong plugin.

Add a test which compares the index with the commands of the plugins. It
takes the top-level commands from "nvme utils dump-command-metadata",
run with the utils plugin only, and with the utils plugin and one more.
The commands that plugin adds have to be its commands in the index, and
every command of the index has to be a command of nvme, with its alias.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
The keys tests of the deprecated aliases skip themselves when nvme has
no gen-dhchap-key. They look for it in the help, which lists no
deprecated command, so they always skip.

Ask for the help of gen-dhchap-key instead.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
The deprecated top-level commands only forward to the commands of the
plugins which replace them. They don't need to be in nvme itself.

Move them into the plugin cmds-deprecated, a plugin with only top-level
commands. Its meson.build lists them for the command index, so
"nvme smart-log" loads cmds-deprecated.so, which runs "nvme log smart"
from cmds-log.so. The build adds the plugin when the deprecated commands
are enabled, so CONFIG_DEPRECATED_CMDS has no user left.

Add tests for the lookup of the top-level commands of a plugin: a
command and its alias load only their plugin, an abbreviation selects
the same command as before, and a command without its plugin is not
installed.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
The printers of resv report, dir receive and rpmb info are about to move
into their plugins. Check that they still decode the device data in the
sandbox, and pin the output of rpmb info, which no test covered so far.
Add rpmb info to the print tests, so the sandbox compare covers it too.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
nvme_show_resv_report and its printers are only used by the resv plugin,
so move them into the plugin with its own printer table. The printers
run through nvme_print_decoder in the sandbox as before.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
nvme_directive_show and its printers are only used by the dir plugin, so
move them into the plugin with its own printer table. The printers run
through nvme_print_decoder in the sandbox as before.

NVME_DIRECTIVE_IDENTIFY_PARAM_LEN and nvme_streams_status_nr_sid are
only used by these printers, so they move along.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
stdout_id_ctrl_rpmbs_table is used by the id-ctrl printer of the id
plugin and by nvme_show_id_ctrl_rpmbs, whose only user is the rpmb
plugin. Move the table and the id_ctrl_rpmbs printers into the id
plugin, which now provides nvme_show_id_ctrl_rpmbs to rpmb. The rpmb
plugin needs the id plugin for it.

src/nvme-print-stdout-id.c is empty now, so remove it.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
The printers of get-lba-status are about to move into a plugin. No test
covers their output so far. Pin the output in every format, check that
--dry-run decodes no data and that the data is decoded in the sandbox.
Add get-lba-status to the print tests, so the sandbox compare covers it
too.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
The I/O commands don't need to be in nvme itself. Move them into the
plugin cmds-io, a plugin with only top-level commands. Its meson.build
lists them for the command index, so "nvme read" loads cmds-io.so only.
The build always adds the plugin.

Add tests that an I/O command loads only its plugin, and that it is not
installed without the plugin.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
nvme_show_lba_status and its printers are only used by get-lba-status,
so move them into the plugin cmds-io with its own printer table. The
printers run through nvme_print_decoder in the sandbox as before.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
plugin

reset, subsystem-reset, ns-rescan, virt-mgmt, device-self-test,
sanitize, sanitize-ns, format and lockdown don't need to be in nvme
itself.

Move them into the plugin cmds-admin, a plugin with only top-level
commands. Its meson.build lists them for the command index, so "nvme
format" loads cmds-admin.so. The commands keep their help groups, and
the build always adds the plugin.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
The register printers are about to move into a plugin. Check that
show-regs, get-reg and get-property still decode the registers in the
sandbox, and pin the binary output of show-regs, which no test covered
so far.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
show-regs, get-reg, set-reg, get-property and set-property don't need
to be in nvme itself. Move them into the plugin cmds-regs, a plugin with
only top-level commands. Its meson.build lists the commands for the
command index, so "nvme show-regs" loads cmds-regs.so. The build always
adds the plugin.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
nvme_show_ctrl_registers and its printers are only used by the register
commands, so move them into the cmds-regs plugin with its own printer
table. The printers run through nvme_print_decoder in the sandbox as
before.

stdout_bitfields_table and json_bitfields are only used by these
printers, so they move along and become static.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
The register table of nvme-regs.c and the bitfield decoder of
bitfields.c are only used by the register commands and their printers,
so move them into the cmds-regs plugin. The unit tests build them from
there.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
admin-passthru and io-passthru don't need to be in nvme itself. Move
them into the plugin cmds-passthru, a plugin with only top-level
commands. Its meson.build lists the commands for the command index, so
"nvme admin-passthru" loads cmds-passthru.so. The build always adds the
plugin.

struct passthru_config is only used by these commands, so it moves
along.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
get-log fills a struct nvme_get_log_args only to pass some of its
members to nvme_show_log. Pass the values directly, and remove the
struct from nvme-cmds-common.h, as it has no other user there. The log
plugin has its own copy.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
get-log is the generic counterpart of the log page commands of the log
plugin, and it doesn't need to be in nvme itself. Move it into the log
plugin as a top-level command. Its meson.build lists get-log for the
command index, so "nvme get-log" loads cmds-log.so.

nvme_show_log is only used by get-log, so it moves along. It calls
the decoder of the log plugin directly, and loads the fdp and zns
plugins for their decoders. nvme keeps the registry of the log page
decoders for them.

The tests which run get-log skip it in builds without the log plugin.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
get-feature and set-feature are the generic forms of the commands of the
feat plugin. Move them from nvme into the plugin. The plugin lists them
for the command index, so "nvme get-feature" loads cmds-feat.so. The
build always adds the plugin, so the commands stay in every build.

struct feat_cfg is only used by these commands, so move it along.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
The feat commands show the fields of the value they set even for a dry
run, while the other feature decoders, like the one of the LBA Status
Information Interval of set-feature, don't run. Add tests for both, so
that the move of the decoders into the feat plugin keeps them.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
nvme_print runs the show_feature_fields printer for dry runs as well, so
that the feat commands show the fields of the value they set. A plugin
printer runs through nvme_print_decoder, which skips dry runs.

Add nvme_print_decoder_always, which runs the printer for dry runs as
well, for the feature decoders once they move into the feat plugin.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
The feature printers decode the result and data of Get Features and Set
Features: show_feature, show_feature_fields, select_result, lba_range
and lba_status_info, with their helpers and strings. Their users are the
feat plugin, the persistent event log decoders of log, and ocp. Move
them into a printer table of the feat plugin, which now provides them to
the other plugins. log and ocp need the feat plugin for them.

memblaze only called nvme_select_to_string for the current value, so it
prints "Current" directly instead of needing the feat plugin.

nvme_print runs show_feature_fields for dry runs as well, so the plugin
runs it through nvme_print_decoder_always.

nvme_fdp_event_to_string, nvme_feature_power_limit_scale_to_string and
nvme_power_measurement_type_to_string stay in nvme, as the fdp, id and
log printers use them as well.

Wrap the long lines of the moved code.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
nvme_resources indexes the libnvme tree by name. stdout_relatives uses
it, and so do the printers of list, which are about to move into a
plugin.

Move it into nvme-resources.c, with the hash tables in a header, so
that both can use it.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
list, list-subsys, show-topology and top only look at the devices in
sysfs. They don't need to be in nvme itself.

Move them into the plugin cmds-list, a plugin with only top-level
commands. Its meson.build lists them for the command index, so
"nvme list" loads cmds-list.so. The printers stay in nvme for now.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
The printers of the libnvme tree (list_item, list_items,
print_nvme_subsystem_list, topology_*) and the printers of top are
only used by the commands of cmds-list, and list_item by zns list.

Move them into the plugin with the helpers only they use, in a printer
table of their own. They read sysfs while printing, so they still run
in process.

zns list prints the table of list with nvme_show_list_item, so zns
needs cmds-list now.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
dashboard and nvme-iostat are only used by the top printers, which are
in cmds-list now. Move them into the plugin.

The unit test and the fuzz target of nvme-iostat build it from its new
place.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
The relatives printer is only used by format, so move it into the
cmds-admin plugin, in a printer table of its own. It reads sysfs, so it
runs in process like before. It uses the name index in nvme-resources.c,
which stays in core for the list printers.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
The discovery log printers run for discover and for get-log --verbose,
the configuration printer for config show. No test checks the JSON
output of discover, get-log decoding a Discovery log page, or config
show at all.

Add tests for them, and check that discover decodes in the sandbox and
config show prints in process.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
The privsep tests check that a built-in command which keeps root starts
no helper. A top-level command of a plugin is only known once nvme
loaded its plugin, which has to happen before nvme decides to drop
its privileges.

Check this with show-hostnqn, which keeps root.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Nothing calls nvme_show_connect_msg. hook_connected in fabrics.c prints
the device it connected itself.

Remove the printer and its member of struct print_ops.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
nvme_config_create is only used by "nvme config create", so move it
into the config plugin.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Once all top-level command groups live in plugins, nvme itself registers
none, and builtin.commands stays NULL until a plugin adds one. The
command lookup and the help walk the list without a NULL check and
crash.

Start with an empty list, so they work before any plugin is loaded.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
The fabrics commands don't need to be in nvme itself. Move them into
the plugin cmds-fabrics, which has only top-level commands. Its
meson.build lists them for the command index, so "nvme connect-all"
loads cmds-fabrics.so. The build adds the plugin when fabrics is
enabled.

fabrics.c, config-convert.c and pre-os.c are only used by these
commands and by the config plugin, so move them along, with the call
which loads the nvme-fabrics kernel module. The config plugin calls
fabrics_config_validate, fabrics_config_show, nvme_config_convert,
nvme_config_status and the option helpers of fabrics.c, so it needs
cmds-fabrics, which makes cmds-fabrics a provider.

Add a test that connect-all loads only its plugin.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
The discovery log and connection list printers are only used by the
fabrics commands, by config show and by get-log --verbose for a
Discovery log page.

Move them into a printer table of the cmds-fabrics plugin. The
discovery log printer still runs in the sandbox, the connection list
printer in process. get-log decodes a Discovery log page through a log
decoder of the plugin, so nvme_show_log has no case of its own left.
Without fabrics nothing decoded this page before either.

No change in output.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
The top-level commands moved from src/nvme-cmds-*.c into plugin
plugins. Update the contributing guide to point at them and mention
plugin_commands, and tell packagers in BUILDING.md which plugins an
initramfs needs.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Extend the entry about the plugins: the top-level commands are plugins
now too, and an initramfs needs the plugins of the commands it runs.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
@igaw
igaw merged commit e1606d3 into linux-nvme:master Nov 19, 2026
39 checks passed
@dwsuse
dwsuse deleted the modularize branch November 19, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants