Skip to content

Conversation

@vojtechtrefny
Copy link
Member

@vojtechtrefny vojtechtrefny commented Jan 9, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Improved detection/reporting for non-existent device mappings and relaxed the root-only guard so mapping queries can proceed without root.
    • More reliable extraction of subsystem identifiers using a device-mapper task-based approach.
  • Tests

    • Expanded tests for subsystem extraction, creation/removal side effects, non-existent map error handling, and plugin version verification.
  • Chores

    • Added a new public error variant to represent non-existent devices.

✏️ 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 public API; replaces shell-based dmsetup lookup with a libdevmapper DM_DEVICE_INFO task flow in the DM plugin (including device-existence and UUID/subsystem extraction); updates tests for subsystem extraction, create/remove side-effects, and plugin soname 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.
Plugin header
src/plugins/dm.h
Added enum value BD_DM_ERROR_DEVICE_NOEXIST to the BDDMError typedef.
Plugin implementation
src/plugins/dm.c
Replaced dmsetup/output-parsing with a libdevmapper task flow (DM_DEVICE_INFO): create/set name/run/get info, check info.exists, extract uuid, derive subsystem as substring before first -, return errors via GError, ensure DM task destruction, include necessary headers; removed root-only guard in bd_dm_map_exists. Review required: DM task lifecycle, error mappings, and subsystem-parsing edge cases.
Tests
tests/dm_test.py
Removed DevMapperPluginVersionCase; added test_get_subsystem_from_name_linear; added filesystem existence assertions after create/remove; renamed DMDepsTestDMNoStorageTest and moved test_plugin_version (NOSTORAGE); removed one assertion in DevMapperNameNodeBijection. Review required: test expectations around device presence and UUID handling.

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 58.33% 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 pull request title accurately and specifically describes the main change: replacing dmsetup-based subsystem retrieval with a libdevmapper-based approach in the dm plugin.

✏️ 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 bfeae65 and 80ba38c.

📒 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 (2)
  • src/lib/plugin_apis/dm.api
  • 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-aarch64
  • GitHub Check: testing-farm:fedora-43-x86_64
  • GitHub Check: testing-farm:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-43-aarch64
  • GitHub Check: rpm-build:fedora-43-ppc64le
  • GitHub Check: rpm-build:fedora-rawhide-ppc64le
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-43-aarch64
  • GitHub Check: rpm-build:fedora-43-ppc64le
  • GitHub Check: rpm-build:fedora-rawhide-aarch64
  • GitHub Check: rpm-build:fedora-rawhide-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: testing-farm:fedora-43-x86_64:revdeps_udisks
  • GitHub Check: testing-farm:fedora-43-x86_64:revdeps_blivet
  • GitHub Check: testing-farm:fedora-43-aarch64
  • GitHub Check: testing-farm:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-ppc64le
  • GitHub Check: rpm-build:fedora-43-ppc64le
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-aarch64
  • GitHub Check: rpm-build:fedora-43-aarch64
  • GitHub Check: csmock
  • GitHub Check: compilation (gcc-13)
  • GitHub Check: compilation (gcc-10)
  • GitHub Check: compilation (clang-16)
  • GitHub Check: compilation (gcc-11)
  • GitHub Check: compilation (clang-14)
  • GitHub Check: compilation (gcc-12)
  • GitHub Check: compilation (gcc-14)
  • GitHub Check: compilation (clang-17)
  • GitHub Check: compilation (clang-15)
  • GitHub Check: compilation (clang-18)
  • GitHub Check: symbols
  • GitHub Check: Analyze (python)
  • GitHub Check: udisks-build
  • GitHub Check: Analyze (cpp)
  • GitHub Check: blivet-tests
🔇 Additional comments (4)
src/plugins/dm.h (1)

16-16: LGTM!

New error enum value follows the existing naming convention and is placed at the end of the enum, preserving ABI compatibility.

src/plugins/dm.c (3)

21-21: LGTM!

Required include for strchr usage in the new implementation.


246-279: Solid error handling and cleanup.

All task operation failures are properly handled with consistent cleanup via dm_task_destroy. The new BD_DM_ERROR_DEVICE_NOEXIST error code provides clear differentiation from task failures.


287-291: The current behavior is correct and intentional. The function extracts the subsystem prefix from DM UUIDs, which follows the device-mapper convention where recognized subsystems use a hyphen-delimited format (e.g., LVM-..., CRYPT-...). A UUID without a hyphen indicates no recognized subsystem prefix, and returning an empty string is the appropriate behavior—confirmed by tests in tests/dm_test.py which explicitly verify that UUIDs without hyphens should return empty string. Returning the full UUID would violate the API contract and be semantically incorrect since the function's purpose is to extract the prefix, not the entire UUID.

Likely an incorrect or invalid review comment.


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.

@vojtechtrefny vojtechtrefny force-pushed the master_dm-subsystem-libdevmapper branch from 683495a to 3ca96b3 Compare January 9, 2026 11:46
@vojtechtrefny vojtechtrefny force-pushed the master_dm-subsystem-libdevmapper branch 2 times, most recently from 3ca96b3 to a8a61c0 Compare January 13, 2026 08:31
Faster pbkdf when creating LUKS device for testing, reducing
number of test cases and adding some additional checks.
Checking only EUID is not enough and we don't really support
running without root privileges. If someone tries to run this
function as non-root, the first dm_task_create will fail and the
reason is logged, so that should be good enough.
@vojtechtrefny vojtechtrefny force-pushed the master_dm-subsystem-libdevmapper branch from bfeae65 to 80ba38c Compare January 13, 2026 14:43
Copy link
Member

@tbzatek tbzatek left a comment

Choose a reason for hiding this comment

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

Thanks!

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.

2 participants