Skip to content

udev: fix parent mapping and restore on detach#143

Draft
code-loyko wants to merge 2 commits into
QubesOS:mainfrom
code-loyko:main
Draft

udev: fix parent mapping and restore on detach#143
code-loyko wants to merge 2 commits into
QubesOS:mainfrom
code-loyko:main

Conversation

@code-loyko

@code-loyko code-loyko commented Jul 13, 2026

Copy link
Copy Markdown

This is my first contribution to Qubes OS. I do not master all the components around these changes and am not confident in their potential impacts. I would appreciate a thorough review to verify their safety, and to check if this is indeed the correct approach.

On my hardware, attaching a partition block device (ex: sdX1) broke its device ID mapping because the parent disk's keys (sdX) were deleted from QubesDB to hide it. Additionally, detaching the partition left the parent disk permanently hidden, and blocked subsequent reattachments with a "QubesDaemonAccessError" in dom0.

This patch resolves these issues by:

  1. Swapping the udev parent checks so USB partitions map directly to their physical USB port instead of the parent disk sdX.
  2. Replacing the synchronous parent refresh with an asynchronous "udevadm trigger" to ensure it executes after unbinding finishes.

I verified on my system that these changes successfully preserve the hardware mappings, restore automatic parent disk visibility on detach, and resolve the reattachment error.

Fixes QubesOS/qubes-issues#10828
Fixes QubesOS/qubes-issues#10180
Fixes QubesOS/qubes-issues#9566

This is my first contribution to Qubes OS. I do not master all the components around these changes and am not confident in their potential impacts. I would appreciate a thorough review to verify their safety, and to check if this is indeed the correct approach.

On my hardware, attaching a partition block device (ex: sdX1) broke its device ID mapping because the parent disk's keys (sdX) were deleted from QubesDB to hide it. Additionally, detaching the partition left the parent disk permanently hidden, and blocked subsequent reattachments with a "QubesDaemonAccessError" in dom0.

This patch resolves these issues by:
1. Swapping the udev parent checks so USB partitions map directly to their physical USB port instead of the parent disk sdX.
2. Replacing the synchronous parent refresh with an asynchronous "udevadm trigger" to ensure it executes after unbinding finishes.

I verified on my system that these changes successfully preserve the hardware mappings, restore automatic parent disk visibility on detach, and resolve the reattachment error.

Fixes #10180
Fixes #9566
@codecov-commenter

codecov-commenter commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.24%. Comparing base (2151d10) to head (ea0731b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #143      +/-   ##
==========================================
+ Coverage   71.09%   71.24%   +0.14%     
==========================================
  Files           6        6              
  Lines         993      991       -2     
==========================================
  Hits          706      706              
+ Misses        287      285       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Remove the redundant '--action=change' flag since udev trigger defaults to 'change', and remove the '/dev/null' redirect which was used during testing and committed by mistake.
@code-loyko
code-loyko marked this pull request as draft July 13, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants