Skip to content

Conversation

@vojtechtrefny
Copy link
Member

@vojtechtrefny vojtechtrefny commented Jan 9, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Improved detection and reporting for non-existent devices.
    • More reliable subsystem extraction from device mapper entries.
  • Tests

    • Expanded and adjusted tests to cover subsystem extraction, creation/removal side effects, and plugin version checks.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 9, 2026

📝 Walkthrough

Walkthrough

Adds BD_DM_ERROR_DEVICE_NOEXIST to the device-mapper public API; switches subsystem extraction in the plugin from a shell call to the libdevmapper user-space API with robust error handling and root checks; and updates tests to cover subsystem extraction, existence assertions, and plugin version placement.

Changes

Cohort / File(s) Change Summary
API Declaration
src/lib/plugin_apis/dm.api
Added enum constant BD_DM_ERROR_DEVICE_NOEXIST to BDDMError.
Header
src/plugins/dm.h
Added enum value BD_DM_ERROR_DEVICE_NOEXIST to BDDMError typedef.
Core Implementation
src/plugins/dm.c
Replaced shell-based dmsetup call with libdevmapper task flow (DM_DEVICE_INFO): create/setup/run/destroy task, check root, handle errors, validate info.exists, parse uuid to derive subsystem, added string.h, ensured cleanup on all paths.
Tests
tests/dm_test.py
Removed DevMapperPluginVersionCase; added test_get_subsystem_from_name_linear; added existence assertions in DevMapperCreateRemoveLinear; renamed DMDepsTestDMNoStorageTest and moved test_plugin_version (NOSTORAGE); removed one assertion in DevMapperNameNodeBijection.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing dmsetup with libdevmapper API calls to retrieve subsystem information from a device name.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 683495a and 3ca96b3.

📒 Files selected for processing (4)
  • src/lib/plugin_apis/dm.api
  • src/plugins/dm.c
  • src/plugins/dm.h
  • tests/dm_test.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/plugins/dm.h
🧰 Additional context used
🧬 Code graph analysis (1)
tests/dm_test.py (2)
tests/utils.py (3)
  • run (751-756)
  • tag_test (735-748)
  • TestTags (710-732)
src/python/gi/overrides/BlockDev.py (1)
  • dm_create_linear (406-407)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (42)
  • GitHub Check: testing-farm:fedora-43-aarch64
  • GitHub Check: testing-farm:fedora-43-aarch64
  • GitHub Check: testing-farm:fedora-43-x86_64
  • GitHub Check: testing-farm:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-aarch64
  • GitHub Check: rpm-build:fedora-rawhide-aarch64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-43-ppc64le
  • GitHub Check: rpm-build:fedora-43-ppc64le
  • GitHub Check: rpm-build:fedora-43-aarch64
  • GitHub Check: rpm-build:fedora-43-aarch64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-ppc64le
  • GitHub Check: rpm-build:fedora-rawhide-ppc64le
  • GitHub Check: testing-farm:fedora-43-x86_64:revdeps_udisks
  • GitHub Check: testing-farm:fedora-43-x86_64:revdeps_blivet
  • GitHub Check: testing-farm:fedora-43-x86_64
  • GitHub Check: testing-farm:fedora-43-aarch64
  • GitHub Check: rpm-build:fedora-rawhide-ppc64le
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-aarch64
  • GitHub Check: rpm-build:fedora-43-aarch64
  • GitHub Check: rpm-build:fedora-43-ppc64le
  • GitHub Check: compilation (clang-17)
  • GitHub Check: compilation (clang-18)
  • GitHub Check: compilation (clang-16)
  • GitHub Check: compilation (clang-14)
  • GitHub Check: Analyze (cpp)
  • GitHub Check: compilation (clang-15)
  • GitHub Check: compilation (gcc-11)
  • GitHub Check: compilation (gcc-13)
  • GitHub Check: compilation (gcc-12)
  • GitHub Check: compilation (gcc-14)
  • GitHub Check: compilation (gcc-10)
  • GitHub Check: Analyze (python)
  • GitHub Check: udisks-build
  • GitHub Check: symbols
  • GitHub Check: csmock
  • GitHub Check: blivet-tests
🔇 Additional comments (11)
src/lib/plugin_apis/dm.api (1)

20-20: LGTM!

The new error constant follows the existing naming convention and integrates well with the implementation.

src/plugins/dm.c (6)

21-21: LGTM!

The string.h include is necessary for the strchr function used in line 293.


246-250: LGTM!

The root privilege check is appropriate for DM device queries and consistent with other functions in the file (e.g., bd_dm_map_exists at line 324).


252-271: Excellent error handling and resource management.

The DM task lifecycle is correctly implemented with proper cleanup on all error paths. Each libdevmapper API call is checked and dm_task_destroy is called before returning on failures.


273-285: LGTM!

The device existence check properly uses the new BD_DM_ERROR_DEVICE_NOEXIST error code and ensures cleanup before returning.


287-297: LGTM!

The UUID parsing logic correctly handles all cases:

  • No UUID or empty UUID → returns empty string
  • UUID without hyphen → returns empty string
  • UUID with hyphen → returns substring before hyphen

The distinction between returning empty string (valid but no subsystem) versus NULL with error (failure) is appropriate.


299-300: LGTM!

The DM task is properly destroyed before returning, completing the resource cleanup pattern established in all the error paths.

tests/dm_test.py (4)

77-101: Well-structured test covering key scenarios.

The test verifies:

  • Empty subsystem for devices without UUID
  • Empty subsystem for UUIDs without hyphens
  • Proper error for non-existent devices

Note: The test suite already covers subsystem extraction from UUIDs with hyphens via the LVM and CRYPT tests above.


110-110: Good addition!

The existence check after creation validates the expected side effect of the operation.


114-115: Good addition!

The non-existence check after removal validates that the device was properly cleaned up.


157-160: LGTM!

The class rename better reflects its purpose, and consolidating the plugin version test here improves test organization. The NOSTORAGE tag is correctly applied.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @tests/dm_test.py:
- Around line 88-93: After creating the device with
BlockDev.dm_create_linear("testMap", ...) assert success, add a check that
queries the device mapping/subsystem for "testMap" (for example using the
existing helper that reads DM metadata such as BlockDev.dm_get_subsystem or
other test helper that returns the subsystem) and assert that the returned
subsystem equals "TEST" before calling BlockDev.dm_remove("testMap"); this
ensures the UUID-without-hyphen case is validated prior to removal.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d15c5a and 683495a.

📒 Files selected for processing (4)
  • src/lib/plugin_apis/dm.api
  • src/plugins/dm.c
  • src/plugins/dm.h
  • tests/dm_test.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (42)
  • GitHub Check: testing-farm:fedora-43-aarch64
  • GitHub Check: testing-farm:fedora-43-x86_64
  • GitHub Check: testing-farm:fedora-43-x86_64
  • GitHub Check: testing-farm:fedora-43-aarch64
  • GitHub Check: rpm-build:fedora-43-ppc64le
  • GitHub Check: rpm-build:fedora-rawhide-aarch64
  • GitHub Check: rpm-build:fedora-43-aarch64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-ppc64le
  • GitHub Check: rpm-build:fedora-rawhide-ppc64le
  • GitHub Check: rpm-build:fedora-rawhide-aarch64
  • GitHub Check: rpm-build:fedora-43-ppc64le
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-43-aarch64
  • GitHub Check: testing-farm:fedora-43-x86_64:revdeps_udisks
  • GitHub Check: testing-farm:fedora-43-x86_64:revdeps_blivet
  • GitHub Check: testing-farm:fedora-43-x86_64
  • GitHub Check: testing-farm:fedora-43-aarch64
  • GitHub Check: rpm-build:fedora-rawhide-ppc64le
  • GitHub Check: rpm-build:fedora-rawhide-aarch64
  • GitHub Check: rpm-build:fedora-43-ppc64le
  • GitHub Check: rpm-build:fedora-43-aarch64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: compilation (clang-17)
  • GitHub Check: compilation (clang-18)
  • GitHub Check: compilation (gcc-12)
  • GitHub Check: compilation (gcc-10)
  • GitHub Check: compilation (clang-16)
  • GitHub Check: compilation (clang-14)
  • GitHub Check: compilation (gcc-14)
  • GitHub Check: compilation (gcc-11)
  • GitHub Check: compilation (gcc-13)
  • GitHub Check: compilation (clang-15)
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (cpp)
  • GitHub Check: csmock
  • GitHub Check: symbols
  • GitHub Check: blivet-tests
  • GitHub Check: udisks-build
🔇 Additional comments (8)
src/lib/plugin_apis/dm.api (1)

20-20: LGTM!

The new error code BD_DM_ERROR_DEVICE_NOEXIST is correctly added at the end of the enum, maintaining ABI compatibility. The naming follows existing conventions in the codebase.

src/plugins/dm.h (1)

16-16: LGTM!

The enum addition is consistent with the public API declaration in dm.api.

src/plugins/dm.c (2)

21-21: LGTM!

The <string.h> include is correctly added for strchr() used in the subsystem extraction logic.


239-302: Well-structured refactor to use libdevmapper API.

The implementation correctly:

  • Checks root privileges upfront
  • Manages the DM task lifecycle with proper cleanup on all paths
  • Uses the new BD_DM_ERROR_DEVICE_NOEXIST error code for non-existent devices
  • Handles edge cases (NULL/empty UUID returns empty string)
  • Extracts subsystem as the UUID prefix before the first hyphen
tests/dm_test.py (4)

95-97: LGTM!

Good test coverage for the new BD_DM_ERROR_DEVICE_NOEXIST error path.


107-112: LGTM!

Good additions to verify filesystem-level side effects of device creation and removal.


154-158: LGTM!

The class rename to DMNoStorageTest better reflects its purpose. The plugin version test is a useful sanity check.


71-72: LGTM!

Using --pbkdf=pbkdf2 --pbkdf-force-iterations=1000 is a good optimization for faster test execution.

Faster pbkdf when creating LUKS device for testing, reducing
number of test cases and adding some additional checks.
@vojtechtrefny vojtechtrefny force-pushed the master_dm-subsystem-libdevmapper branch from 683495a to 3ca96b3 Compare January 9, 2026 11:46
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