Skip to content

Use libudev for USB device selection - #196

Merged
pjbgf merged 1 commit into
mainfrom
libudev-usb
Aug 20, 2026
Merged

Use libudev for USB device selection#196
pjbgf merged 1 commit into
mainfrom
libudev-usb

Conversation

@pjbgf

@pjbgf pjbgf commented Aug 20, 2026

Copy link
Copy Markdown
Member

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.

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
Copilot AI lite review requested due to automatic review settings August 20, 2026 22:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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:product IDs (preferred) or product-name prefixes (compat).
  • Add qubesome usb (hidden) to list detected USB devices, IDs, names, and resolved /dev paths.
  • 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.

@pjbgf
pjbgf merged commit e48ff39 into main Aug 20, 2026
5 of 6 checks passed
@pjbgf
pjbgf deleted the libudev-usb branch August 20, 2026 22:52
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