Skip to content

nvme: do not print status message on default#3416

Draft
igaw wants to merge 1 commit into
linux-nvme:masterfrom
igaw:do-not-print-status-messages
Draft

nvme: do not print status message on default#3416
igaw wants to merge 1 commit into
linux-nvme:masterfrom
igaw:do-not-print-status-messages

Conversation

@igaw
Copy link
Copy Markdown
Collaborator

@igaw igaw commented Jun 2, 2026

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

[note: there are plenty more places where nvme-cli still prints directly to stdout. this needs to be updated as well. but given the size of this tasks, let's go incrementatlly]

Copy link
Copy Markdown

Copilot AI left a comment

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 reduces unsolicited “success”/status output from nvme commands by moving many messages behind a new “verbose-only message” helper, aligning default behavior with Unix composability expectations (clean stdout on success).

Changes:

  • Replace a number of unconditional success printf()/fprintf() calls with nvme_show_verbose_result() / nvme_show_verbose_info().
  • Add nvme_show_verbose_message() to centralize verbose-only messaging in the print layer.
  • Suppress namespace-management success status output unless --verbose is set.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
nvme.c Converts many success/status messages to verbose-only output and adjusts namespace-management status printing.
nvme-print.h Adds convenience macros for verbose-only messaging.
nvme-print.c Implements nvme_show_verbose_message() to gate status output behind verbosity and output format handling.

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

Comment thread nvme-print.h Outdated
Comment thread nvme-print.c Outdated
Comment thread nvme.c
Comment thread nvme.c
@igaw
Copy link
Copy Markdown
Collaborator Author

igaw commented Jun 2, 2026

$ ./nvme write /dev/nvme0n1 --start-block=1023 --block-count=0 --data-size=512 --data=nvmetests/TestNVMeCompareCmd/write_file.txt
$ ./nvme write /dev/nvme0n1 --start-block=1023 --block-count=0 --data-size=512 --data=nvmetests/TestNVMeCompareCmd/write_file.txt -v
write: Success
$ ./nvme write /dev/nvme0n1 --start-block=1023 --block-count=0 --data-size=512 --data=nvmetests/TestNVMeCompareCmd/write_file.txt -v -o json
{
  "result":"write: Success"
}

@igaw igaw force-pushed the do-not-print-status-messages branch from 54fc7f8 to b35f84a Compare June 2, 2026 11:55
@igaw igaw requested a review from Copilot June 2, 2026 11:57
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread nvme.c Outdated
Comment thread nvme.c Outdated
Comment on lines +2955 to +2956
if (!err && !nvme_args.verbose && !nvme_is_output_format_normal())
return;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@copilot: what about this?

	if (!err && !nvme_args.verbose && nvme_is_output_format_normal())
		return;

Comment thread nvme-print.c Outdated
Comment on lines +1746 to +1764
void nvme_show_verbose_message(bool error, const char *msg, ...)
{
struct print_ops *ops = nvme_print_ops(NORMAL);
bool json = nvme_is_output_format_json();
va_list ap;

if (!nvme_args.verbose)
return;

va_start(ap, msg);

if (json)
ops = nvme_print_ops(JSON);

if (ops && ops->show_message)
ops->show_message(json ? error : true, msg, ap);

va_end(ap);
}
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>
@igaw igaw force-pushed the do-not-print-status-messages branch from b35f84a to 4c5a105 Compare June 2, 2026 12:23
@igaw igaw marked this pull request as draft June 2, 2026 12:24
@igaw
Copy link
Copy Markdown
Collaborator Author

igaw commented Jun 2, 2026

I realize there is a bit more work to do here. Especially if we want to split progress/status infos as unix tool wants to have.

Also the whole flag parsing around nvme_args.output_format should be made more sane, that is we parse it once and store it globally in something like nvme_args.output_format_flags.

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

2 participants