Skip to content

Add a CLI tool to manage USB devices, fix USB suspend/resume and make killswitch persistent#1445

Merged
brianmcgillion merged 1 commit intotiiuae:mainfrom
nesteroff:vhotplug-update
Oct 9, 2025
Merged

Add a CLI tool to manage USB devices, fix USB suspend/resume and make killswitch persistent#1445
brianmcgillion merged 1 commit intotiiuae:mainfrom
nesteroff:vhotplug-update

Conversation

@nesteroff
Copy link
Copy Markdown
Contributor

@nesteroff nesteroff commented Oct 3, 2025

Description of Changes

  • Adds a CLI tool to manage USB device passthrough.
  • Updates USB configuration to handle static USB devices via vhotplug.
  • Adds services to gracefully suspend and resume USB devices.
  • Makes the killswitch for USB devices persistent.

Type of Change

  • New Feature
  • Bug Fix
  • Improvement / Refactor

Related Issues / Tickets

Checklist

  • Clear summary in PR description
  • Detailed and meaningful commit message(s)
  • Commits are logically organized and squashed if appropriate
  • Contribution guidelines followed
  • Ghaf documentation updated with the commit - https://tiiuae.github.io/ghaf/
  • Author has run make-checks and it passes
  • All automatic GitHub Action checks pass - see actions
  • Author has added reviewers and removed PR draft status

Testing Instructions

Applicable Targets

  • Orin AGX aarch64
  • Orin NX aarch64
  • Lenovo X1 x86_64
  • Dell Latitude x86_64
  • System 76 x86_64

Installation Method

  • Requires full re-installation
  • Can be updated with nixos-rebuild ... switch
  • Other:

Test Steps To Verify:

Persistent Killswitch for USB Devices:

  • Execute ghaf-killswitch block cam and ensure the integrated camera is detached from business-vm.
  • Reboot and verify that it is still detached.
  • Re-enable it by executing ghaf-killswitch unblock cam.

CLI Tool for USB Management:

  • Execute vhotplugcli usb list to get a list of connected devices along with their properties. The CLI tool can be run either on the host or in gui-vm.
  • Detach a USB device using one of the following commands:
vhotplugcli usb detach --vid 8087 --pid 0033
vhotplugcli usb detach --bus 3 --port 10
vhotplugcli usb detach --devnode /dev/bus/usb/003/005
  • Use similar commands like vhotplugcli usb attach to reattach devices to VMs.
  • For devices allowed to connect to multiple VMs, specify --vm business-vm in the attach command. Currently, external webcams can be connected to both chrome-vm and business-vm.

Graceful USB Suspend/Resume:

  • During suspend, all USB devices are disconnected from VMs, which should be visible in the vhotplug logs. They should reconnect on resume and function normally.
  • This may resolve issues related to USB devices being in use during suspend (e.g., SSRCSP-6721).

Signed-off-by: Yuri Nesterov <yuriy.nesterov@unikie.com>
@nesteroff nesteroff marked this pull request as ready for review October 7, 2025 09:24
@nesteroff nesteroff added the Needs Testing CI Team to pre-verify label Oct 7, 2025
@milva-unikie
Copy link
Copy Markdown

Tested on Darter Pro (nixos-rebuild switch) & Lenovo X1 (nixos-rebuild switch)

  • ghaf-killswitch state persists after reboot.
  • USB devices can be attached and detached successfully.
  • I believe the issue with USB headsets and suspend has been fixed. This should be verified by someone who has experienced the issue. I don't usually use USB headsets.

Notes

  • USB headset is automatically attached to audio-vm.
  • USB stick is automatically attached to gui-vm.
  • USB camera is not automatically attached to any VM.

@milva-unikie milva-unikie added Tested on Lenovo X1 Carbon This PR has been tested on Lenovo X1 Carbon Tested on System76 and removed Needs Testing CI Team to pre-verify labels Oct 9, 2025
@clayhill66
Copy link
Copy Markdown
Collaborator

Confirmed that the issue with USB headset and suspend is no longer reproducible with this PR. Both suspend from power menu and automatic suspend works fine, audio and video resume nicely and issues with power off (previously 15 sec hard reset required after using USB headset) are resolved. Good stuff :-)

@brianmcgillion brianmcgillion merged commit 30f3e3c into tiiuae:main Oct 9, 2025
28 checks passed
@nesteroff nesteroff deleted the vhotplug-update branch October 9, 2025 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Tested on Lenovo X1 Carbon This PR has been tested on Lenovo X1 Carbon Tested on System76

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants