Use libudev for USB device selection - #196
Merged
Merged
Conversation
Replace the hand-rolled /sys/bus/usb globbing with the qubesome/libudev scanner. USB devices can now be selected by a stable vendor:product ID (e.g. 1050:0407), falling back to product-name prefix matching for backwards compatibility. The emitted /dev paths are unchanged, so the docker and podman runners are untouched. Add a hidden `qubesome usb` command that lists detected USB devices with their vendor:product ID, product name and resolved /dev paths, to help users discover the IDs to put in usbDevices. The scanner roots are injected explicitly so the feature works on hosts without /run/udev/data, and hidraw discovery stops at downstream USB devices so hubs no longer claim their children's hidraw nodes. Assisted-by: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Paulo Gomes <paulo@entire.io> Entire-Checkpoint: 01M0GNCER7YZRBD56A29SB4ECP
There was a problem hiding this comment.
Pull request overview
This PR replaces the existing USB device discovery logic (previously based on /sys/bus/usb globbing) with a qubesome/libudev-based scan, allowing USB selection by stable vendor:product IDs while retaining product-name prefix matching for backwards compatibility. It also adds a hidden CLI helper to enumerate detected devices and the /dev paths that would be passed through to workloads.
Changes:
- Switch USB selection to match either
vendor:productIDs (preferred) or product-name prefixes (compat). - Add
qubesome usb(hidden) to list detected USB devices, IDs, names, and resolved/devpaths. - Add unit tests covering ID matching, prefix matching, and hidraw discovery boundaries (no downstream-device leakage).
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/types/workload.go | Updates usbDevices config documentation to describe ID-based selection and point to qubesome usb. |
| internal/runners/util/usb/devices.go | Replaces sysfs globbing with libudev scanning; implements ID/prefix matching and improved hidraw discovery. |
| internal/runners/util/usb/devices_test.go | Adds tests for selection behavior, sorting, and hidraw traversal constraints. |
| cmd/cli/usb.go | Adds hidden usb command to enumerate detected devices and their resolved paths. |
| cmd/cli/root.go | Registers the new hidden usb command. |
| go.mod | Adds dependency on github.com/qubesome/libudev v0.0.2. |
| go.sum | Adds checksums for github.com/qubesome/libudev v0.0.2. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace the hand-rolled /sys/bus/usb globbing with the qubesome/libudev scanner. USB devices can now be selected by a stable vendor:product ID (e.g. 1050:0407), falling back to product-name prefix matching for backwards compatibility. The emitted /dev paths are unchanged, so the docker and podman runners are untouched.
Add a hidden
qubesome usbcommand that lists detected USB devices with their vendor:product ID, product name and resolved /dev paths, to help users discover the IDs to put in usbDevices.The scanner roots are injected explicitly so the feature works on hosts without /run/udev/data, and hidraw discovery stops at downstream USB devices so hubs no longer claim their children's hidraw nodes.