Skip to content

[NEW] Add Zoned Block Device (ZBD) support to blockdevice module#823

Open
xsub wants to merge 1 commit into
pytest-dev:mainfrom
xsub:feature/zbd-support
Open

[NEW] Add Zoned Block Device (ZBD) support to blockdevice module#823
xsub wants to merge 1 commit into
pytest-dev:mainfrom
xsub:feature/zbd-support

Conversation

@xsub

@xsub xsub commented Jul 4, 2026

Copy link
Copy Markdown

Motivation

With the growing adoption of SMR (Shingled Magnetic Recording) HDDs and NVMe ZNS (Zoned Namespace) drives, it's becoming more common to configure and test infrastructure that relies on Zoned Block Devices (ZBD). This PR extends the blockdevice module to allow querying ZBD-specific properties directly from Testinfra.

Changes

This PR adds support for ZBD properties in LinuxBlockDevice by safely querying the Linux kernel's sysfs (/sys/block/<dev>/queue/).

New properties added:

  • is_zoned (bool)
  • zoned_type (e.g., "none", "host-managed", "host-aware")
  • zoned_chunk_sectors
  • zoned_nr_zones
  • zone_append_max_bytes
  • max_open_zones
  • max_active_zones

Implementation details:

  • Safe attribute reading: Instead of running shell commands (cat) and relying on exit codes or kernel version parsing, the code simply checks if the relevant sysfs file exists using host.file().exists and reads its content.
  • Backward compatibility: If a device is a standard block device (or if the kernel is too old to expose newer limits like max_active_zones), the module gracefully returns None for these specific attributes and "none" for zoned_type. It won't break existing tests.
  • Used standard Python @property decorators for a clean API.

Usage Example

def test_nvme_zns_drive(host):
    drive = host.block_device("nvme1n1")
    
    assert drive.is_zoned is True
    assert drive.zoned_type == "host-managed"
    assert drive.max_open_zones == 14

@xsub

xsub commented Jul 4, 2026

Copy link
Copy Markdown
Author

Hey Testinfra team!

Here's a small update for the blockdevice module to support Zoned Block Devices (ZBD). It adds a few properties like is_zoned, zoned_type, and various ZBD limits (max open zones, etc.).

Hope you find it useful.

Thanks,
xsub

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.

1 participant