[Bug]: `nvidia-container-cli list` default listing depends on argv count (`--imex-channel 0` vs `--imex-channel=0`, `--no-persistenced` prints nothing)

未关闭 适合新手
#406 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
86/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
c
领域
cli

调研方向

阅读 src/cli/list.c,尤其是 ARGP_KEY_END 处的 list_parser(),并追踪已解析的选择选项如何设置列表上下文。使用 CLI 重现 argv 的写法和 opt-out 情况;issue 说使用了 stub 后端。当不同的选项写法产生等效输出、opt-out 标志保留默认列表但排除其指定的文件,并且显式选择选项保持当前行为时,即算完成。

由索引模型根据 Issue 内容生成。

描述

needs-triage

Motivation

I was checking which files nvidia-container-cli list reports when IMEX channels or the new opt-out flags are used, and the output changed depending on how I spelled the same option.

  • I would like to work on this issue.

Describe the bug

list prints everything (device nodes, binaries, libraries, IPCs, firmware) when it is called without options. When --imex-channel was added, the IMEX-only case was meant to keep that default listing and add the channel nodes on top. The check in list_parser() (src/cli/list.c, ARGP_KEY_END) counts argv entries instead of looking at which options were given:

if (state->argc == 1 || (state->argc == 2 && ctx->imex_channels != NULL)) {

argp accepts both --imex-channel=0 (one argv entry) and --imex-channel 0 (two argv entries), so the result depends on the spelling:

  • list --imex-channel=0 prints the full listing plus /dev/nvidia-caps-imex-channels/channel0.
  • list --imex-channel 0 prints only /dev/nvidia-caps-imex-channels/channel0.
  • list --imex-channel=0 --imex-channel=1 prints only the two channel nodes, while list --imex-channel=0,1 prints everything.

The same check also affects the opt-out flags added in v1.16.2. --no-persistenced, --no-fabricmanager and --no-gsp-firmware only change what the driver lookup returns; they do not select anything to list. But each one makes argc == 2, so list --no-persistenced (or --no-gsp-firmware, or --no-fabricmanager) prints nothing and exits 0. The ctx->list_firmwares = false; in the --no-gsp-firmware case suggests the flag was expected to remove firmware from the default listing, not to empty it.

The IMEX gate has been there since v1.15.0, the opt-out flags since v1.16.2, and both are still on current main (c7727e5).

To Reproduce

The difference is in argument parsing only, so it shows on any host. The output below is from the current main CLI front-end built against a stub backend that reports one GPU, one binary, one library, the persistenced socket and one GSP firmware file:

$ nvidia-container-cli list --imex-channel=0
/dev/nvidiactl
/dev/nvidia0
/dev/nvidia-caps-imex-channels/channel0
/usr/bin/nvidia-smi
/usr/lib/libcuda.so.580.0.0
/run/nvidia-persistenced/socket
/lib/firmware/nvidia/580.0.0/gsp_ga10x.bin

$ nvidia-container-cli list --imex-channel 0
/dev/nvidia-caps-imex-channels/channel0

$ nvidia-container-cli list --no-persistenced
$ echo $?
0

$ nvidia-container-cli list --no-gsp-firmware
$ nvidia-container-cli list --no-fabricmanager

On a real host the first command prints the full driver file list; the second one still prints only the channel node.

Expected behavior

  • --imex-channel 0 and --imex-channel=0 give the same output, and repeating --imex-channel behaves like a comma-separated list.
  • list --no-persistenced prints the default listing without the persistenced socket; list --no-gsp-firmware prints it without the firmware files; list --no-fabricmanager prints it without the fabricmanager socket.
  • Options that select what to list (--device, --libraries, --binaries, --ipcs, --firmwares, --compat32, --mig-config, --mig-monitor) keep their current behavior: only the selected parts are printed.

Proposed fix

In ARGP_KEY_END, decide whether to apply the default listing from the parsed context instead of from state->argc: apply it when none of the selecting options above was given. --imex-channel and the --no-* flags then only modify the default listing, however they are spelled. The ctx->list_firmwares = false; line in the --no-gsp-firmware case is dropped: firmware lookup is already skipped through the driver option, and keeping the line would make list -f --no-gsp-firmware fall back to the full listing. The change is about 7 lines in src/cli/list.c and does not touch configure or the library.

I checked the change against these cases: list, list --libraries, list --device=0, list -f --no-gsp-firmware, list --compat32 and list --imex-channel=0 print exactly what they print today. list --imex-channel 0, repeated --imex-channel, and the three --no-* flags behave as described above. There is no C test suite in the repository, so I used a small out-of-tree script that runs the CLI against a stub backend; I can share it if that helps.

Environment (please provide the following information):

  • Version: main at c7727e5 (same code in v1.16.2 through v1.20.2)
  • OS / Distribution: Ubuntu 24.04 (aarch64)
  • Kernel Version: n/a (argument parsing only)
  • Container Runtime Version: n/a (nvidia-container-cli list called directly)

This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.

主要语言
C
星标
1.1k
派生
278
平均合并
3 天 7 小时
30 天内合并 PR
2

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

NVIDIA/libnvidia-container 的其他 Issue

查看 NVIDIA/libnvidia-container 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。