Skip to content

nvme: do not print status message on default#3553

Merged
igaw merged 6 commits into
linux-nvme:masterfrom
dwsuse:do-not-print-status-messages
Jul 7, 2026
Merged

nvme: do not print status message on default#3553
igaw merged 6 commits into
linux-nvme:masterfrom
dwsuse:do-not-print-status-messages

Conversation

@dwsuse

@dwsuse dwsuse commented Jul 6, 2026

Copy link
Copy Markdown
Contributor
Unix tools should remain silent on success and produce output only when
it is part of their functional result. Emitting status messages by
default violates the long-established convention that stdout is reserved
for machine-consumable data, while diagnostics and optional progress
reporting belong on stderr or behind an explicit verbose flag.

A core strength of Unix tooling is composability: commands are routinely
used in pipelines, shell scripts, automation frameworks, and other
programs. Unsolicited status output contaminates stdout, forcing
consumers to implement fragile filtering logic and making the tool
harder to integrate reliably. The absence of default status messages is
therefore not merely a stylistic preference but an interoperability
requirement.

This follows the traditional Unix principle that "no news is good news":
successful execution is indicated by the exit status, not by
human-readable confirmation text. Users who need operational visibility
can opt into it through verbose or progress-reporting options, while
automation and existing workflows continue to receive clean,
deterministic output.

Fixes: #2025
Replaces: #3416

igaw and others added 4 commits July 6, 2026 11:34
After the final json_print_object add a newline so that the output
doesn't interfere with the shell command line print afterwards.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Add variants of nvme_show_verbose_* which will only print when verbose
mode is enabled.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Don't print empty json output.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
There can only be one JSON root object, thus create it at after parsing
the options and print it when existing the program. With this in place,
it's possible remove embedded creation of json_r object. It will always
exist when those code paths are hit.

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

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.

Pull request overview

This PR aligns nvme-cli and its plugins with the Unix convention of being silent on success and keeping stdout clean for machine-consumable output, by moving many status/diagnostic messages behind verbose helpers and/or to stderr.

Changes:

  • Replaces many direct printf / fprintf(stderr, ...) / perror sites with nvme_show_* helpers for consistent routing/formatting.
  • Introduces verbose-only printing helpers (nvme_show_verbose_message, nvme_show_verbose_result/info, nvme_show_verbose_key_value) and updates multiple plugins to use them.
  • Adds explicit trailing newlines after some JSON prints to ensure valid line-oriented JSON output.

Reviewed changes

Copilot reviewed 55 out of 56 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
plugins/zns/zns.c Moves ZNS plugin success/status/error messaging to nvme_show_* helpers and verbose-only output.
plugins/wdc/wdc-utils.c Converts error printing to nvme_show_error.
plugins/virtium/virtium-nvme.c Adds nvme-print.h and switches multiple user messages to nvme_show_error / verbose helpers.
plugins/transcend/transcend-nvme.c Adds nvme-print.h and switches “Device not found” output to nvme_show_error.
plugins/toshiba/toshiba-nvme.c Converts stderr diagnostics to nvme_show_error.
plugins/solidigm/solidigm-workload-tracker.c Minor message formatting change via nvme_show_error.
plugins/solidigm/solidigm-temp-stats.c Switches a stderr error to nvme_show_error.
plugins/solidigm/solidigm-telemetry.c Reworks argument-validation errors to nvme_show_error / nvme_show_err.
plugins/solidigm/solidigm-smart.c Converts invalid-format error output to nvme_show_error.
plugins/solidigm/solidigm-log-page-dir.c Tweaks invalid-format message formatting via nvme_show_error.
plugins/solidigm/solidigm-latency-tracking.c Routes errors to nvme_show_error / nvme_show_err and success to verbose helpers.
plugins/solidigm/solidigm-internal-logs.c Switches perror/printf success messages to nvme_show_perror and verbose helpers.
plugins/solidigm/solidigm-garbage-collection.c Converts invalid-format message to nvme_show_error.
plugins/shannon/shannon-nvme.c Converts stderr/perror/status handling to nvme_show_error / nvme_show_err.
plugins/sed/sedopal_cmd.c Adds nvme-print.h and converts many stderr messages to nvme_show_error.
plugins/sed/sed.c Converts stderr messages to nvme_show_error.
plugins/seagate/seagate-nvme.c Adds explicit \n after JSON output and converts several messages to nvme_show_error / nvme_show_err.
plugins/scaleflux/sfx-nvme.c Converts several messages to nvme_show_error / nvme_show_err and gates success output behind verbose helpers.
plugins/sandisk/sandisk-utils.c Converts stderr error messages to nvme_show_error.
plugins/sandisk/sandisk-nvme.c Converts many stderr messages to nvme_show_error / nvme_show_err and adjusts telemetry/resize messaging.
plugins/registry/registry-nvme.c Adds nvme-print.h and converts user prompts/errors to nvme_show_error.
plugins/ocp/ocp-telemetry-decode.c Converts messages to nvme_show_error and removes some embedded newlines.
plugins/ocp/ocp-smart-extended-log.c Converts stderr messages to nvme_show_error and adjusts GUID mismatch messaging.
plugins/ocp/ocp-print.c Routes “unhandled output format” to nvme_show_error.
plugins/ocp/ocp-hardware-component-log.c Converts info-level stderr printing macro to nvme_show_error.
plugins/ocp/ocp-fw-activation-history.c Converts stderr messages to nvme_show_error.
plugins/ocp/ocp-clear-features.c Gates “Success” behind verbose helper and routes failures to nvme_show_error.
plugins/netapp/netapp-nvme.c Adds nvme-print.h and converts many stderr diagnostics to nvme_show_error.
plugins/micron/micron-utils-win.c Adds nvme-print.h and routes platform-not-supported messages to nvme_show_error.
plugins/micron/micron-utils-linux.c Adds nvme-print.h and converts perror/printf to nvme_show_perror / nvme_show_error / verbose helpers.
plugins/memblaze/memblaze-nvme.c Converts success/failure messaging to nvme_show_error / nvme_show_err / verbose helpers.
plugins/lm/lm-print.c Adds nvme-print.h and routes “unhandled output format” to nvme_show_error.
plugins/lm/lm-print-stdout.c Adds nvme-print.h and routes warnings to nvme_show_error.
plugins/lm/lm-print-json.c Adds nvme-print.h and routes warnings to nvme_show_error.
plugins/lm/lm-nvme.c Gates several “Successful” messages behind verbose helpers.
plugins/intel/intel-nvme.c Adds \n after JSON output and routes various messages through nvme_show_error / nvme_show_perror / verbose helpers.
plugins/innogrit/innogrit-nvme.c Converts some printf error markers to nvme_show_error.
plugins/ibm/ibm-nvme.c Converts error messages to nvme_show_error / nvme_show_perror.
plugins/huawei/huawei-nvme.c Adds nvme-print.h and routes allocation/open failures to nvme_show_error.
plugins/feat/feat-nvme.c Removes nvme_show_init/finish wrappers around some outputs.
plugins/fdp/fdp.c Converts stderr/perror/success prints to nvme_show_error / nvme_show_err / verbose helpers.
plugins/exclusion/exclusion-nvme.c Adds nvme-print.h and converts many stderr messages to nvme_show_error.
plugins/amzn/amzn-nvme.c Converts stderr messages to nvme_show_error.
plugin.c Routes invalid sub-command errors to stderr (instead of stdout).
nvme-rpmb.c Converts many stderr prints to nvme_show_error / nvme_show_perror and uses nvme_show_result for data output.
nvme-print.h Adds verbose result/info macros and new verbose helper declarations.
nvme-print.c Refactors message/key-value helpers and introduces verbose variants.
nvme-print-stdout.c Fixes negative-status strerror usage.
nvme-models.c Adds nvme-print.h and routes several errors through nvme_show_error.
logging.c Replaces some stdout debug prints with structured key/value helpers.
fabrics.c Routes many messages through nvme_show_error / verbose helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/zns/zns.c
Comment thread plugins/lm/lm-nvme.c
Comment on lines 113 to 120
if (err < 0)
nvme_show_error("ERROR: nvme_lm_cdq() failed: %s", libnvme_strerror(errno));
else if (err)
nvme_show_status(err);
else
printf("Create CDQ Successful: CDQID=0x%04x\n",
nvme_show_verbose_result("Create CDQ Successful: CDQID=0x%04x",
NVME_GET((__u32)cmd.result, LM_CREATE_CDQ_CDQID));

Comment thread plugins/zns/zns.c
Comment thread plugins/solidigm/solidigm-temp-stats.c
Comment thread plugins/scaleflux/sfx-nvme.c
Comment thread nvme-print.c
Comment thread plugins/zns/zns.c
Comment thread plugins/zns/zns.c
Comment thread plugins/sandisk/sandisk-nvme.c
@igaw
igaw force-pushed the do-not-print-status-messages branch from 4dea663 to 9c93b8f Compare July 7, 2026 07:55
igaw added 2 commits July 7, 2026 09:59
Unix tools should remain silent on success and produce output only when
it is part of their functional result. Emitting status messages by
default violates the long-established convention that stdout is reserved
for machine-consumable data, while diagnostics and optional progress
reporting belong on stderr or behind an explicit verbose flag.

A core strength of Unix tooling is composability: commands are routinely
used in pipelines, shell scripts, automation frameworks, and other
programs. Unsolicited status output contaminates stdout, forcing
consumers to implement fragile filtering logic and making the tool
harder to integrate reliably. The absence of default status messages is
therefore not merely a stylistic preference but an interoperability
requirement.

This follows the traditional Unix principle that "no news is good news":
successful execution is indicated by the exit status, not by
human-readable confirmation text. Users who need operational visibility
can opt into it through verbose or progress-reporting options, while
automation and existing workflows continue to receive clean,
deterministic output.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
The error code is stored in status not errno.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
@igaw
igaw force-pushed the do-not-print-status-messages branch from 9c93b8f to 5b9e34a Compare July 7, 2026 08:00
@igaw

igaw commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

While this not addressing all the issues the code base has, it is going into the right direction. There are more cleanups needed. Let's get this in and fixup the rest piece by piece. There is no point trying to fix everything in one go.

@igaw
igaw merged commit 15aa31e into linux-nvme:master Jul 7, 2026
31 of 32 checks passed
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.

admin-passthru with raw_binary prepends status message

3 participants