Skip to content

Conversation

@kanchansenlaskar
Copy link
Collaborator

Upstream change context:
- nvme-cli reworked nvme list -o json around v2.11, removing the
legacy top-level .Devices[].DevicePath and nesting device info under: Subsystems → Controllers → Namespaces.
- Reference discussion and breakage report: linux-nvme/nvme-cli#2749 (thread points to commit 929f461 as the change introducing the new JSON)
- Some distro builds may still emit DevicePath. This logic supports both.
- jq option is implemented to simplify parsing, but a pure-Python fallback is also provided if jq is not available on the target system. jq option is more efficient and robust, so it is preferred when possible.

@kanchansenlaskar kanchansenlaskar changed the title Fix nvme device path fetch logic Return NVMe device nodes/paths (/dev/...) robustly across nvme-cli schemas Oct 26, 2025
@kanchansenlaskar kanchansenlaskar force-pushed the kasenlaskar/fix_nvme_device_path_fetch_logic branch from dfc5566 to 12ab6ee Compare October 26, 2025 12:09
# -------------------------------
# Pure Python (when jq is not available)
# -------------------------------
nvme_devices = self.get_devices(force_run=force_run) # raw ["Devices"]
Copy link
Member

@squirrelsc squirrelsc Oct 27, 2025

Choose a reason for hiding this comment

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

  1. Move the parser logic into get_devices, so it can be shared, and managed in one place. get_devices should return a data structure, not a json object.
  2. Place comments above the code line, not at the end.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  1. Move the parser logic into get_devices, so it can be shared, and managed in one place. get_devices should return a data structure, not a json object.
  2. Place comments above the code line, not at the end.
  1. get_devices has always been returning a json object, as its job is to get us the details of devices. And that is the output consumed by many other functions in other files too. It has always been the job of the get_disks to parse it and fetch the device paths. Hence I changed the logic in get_disks and left get_devices as is.

  2. That was the order even before, I will update it, also will change the content of that json.

Copy link
Member

@squirrelsc squirrelsc Oct 28, 2025

Choose a reason for hiding this comment

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

The method isn’t widely used—based on my search, it only shows up twice in this class. Also, the comment # raw ["Devices"] looks like a recent addition.

@kanchansenlaskar kanchansenlaskar force-pushed the kasenlaskar/fix_nvme_device_path_fetch_logic branch from 12ab6ee to c6a97d2 Compare October 28, 2025 13:57
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.

4 participants