Repository navigation
usb(macOS): connect a saved USB device when it is plugged in again - #8133
Open
UTMapp-bot wants to merge 1 commit into
Open
UTMapp-bot wants to merge 1 commit into
UTMapp-bot wants to merge 1 commit into
Conversation
This was referenced Nov 11, 2026
A USB device set to "Auto connect on start" was only connected when the virtual machine started. When it was unplugged and plugged in again while the virtual machine ran, or restarted itself as a device does after a firmware update, UTM asked whether to connect it, or did nothing when the prompt is turned off or the window is not in front. Connect such a device when it appears, without asking. A device that another virtual machine has, or that this one has no room for, is left alone without an alert. The idea and a first version are from giovariot in #7928. Assisted-by: OpenCode:deepseek-v4.1-flash Assisted-by: Claude:claude-fable-5-2
osy
force-pushed
the
usb/reconnect-saved-device
branch
from
November 12, 2026 06:42
c848ba9 to
c0c4100
Compare
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.
Stack 2/2 — stacked on #8134; merge the stack bottom-up.
A USB device set to "Auto connect on start" was only connected when the virtual machine started. When it was unplugged and plugged in again while the VM ran, or restarted itself as a device does after a firmware update, UTM asked whether to connect it, or did nothing when the prompt is turned off or the VM window is not in front.
Such a device is now connected when it appears, without asking. A device that another VM has, or that this VM has no room for, is left alone without an alert. The menu item keeps its name.
The idea and a first version are from @giovariot in #7928 and the commit is in their name. Differences from that version: whether a device is saved is looked up off the main thread (it reads the device's descriptors, and this now runs for every device that is plugged in), a secondary window that gets the event hands the connect to the primary one, and a device this VM already has is skipped.
Testing
Tested by an AI agent on a MacBook Pro M2 Max, macOS 27.2 (26B123), with Debug builds of the macOS scheme. A person unplugged and plugged in the drive when the test asked for it.
Setup: a Seagate 4 TB drive (0bc2:ab28) on a 5 Gb/s link, an Ubuntu 26.04 arm64 guest on a USB 3.0 controller. I cannot click the "Auto connect on start" menu item, so both builds had a temporary change (not in this PR) that makes
isAutoConnecttrue for this drive. The VM is started, which connects the drive (auto connect on start), then the drive is unplugged for about 5 s and plugged in again.new SuperSpeed USB device number 3 using xhci_hcd) and reads from it at 117 MB/s. No prompt. Run twice, once before and once after the changes from review.disconnectcommand): 25 s later the drive is still with the Mac and its volume is mounted. A saved device that is handed back does not come back by itself.The static checks pass.
Not tested: a VM with a second display or serial window (the case the secondary-window change is for), a device that restarts itself, two VMs with the same saved device, and the real menu setting (the temporary change stood in for it).
Notes from review