tart icon indicating copy to clipboard operation
tart copied to clipboard

Passthrough USB devices

Open fkorotkov opened this issue 3 years ago • 11 comments
trafficstars

We need to investigate how to passthough an iPhone connected to the host. This will be useful for running on device integration tests.

fkorotkov avatar Jun 27 '22 18:06 fkorotkov

Doesn't seem to be possible at this point, see https://github.com/docker/for-mac/issues/5263.

Doing something similar to VirtualHere is an option, though, but most involves (1) delving into, most likely, IOUSBHost and IOKit frameworks and (2) installing the agent on each running VM that will forward the USB data packets to and from the host.

Thinking of adb, there's an idb alternative for iOS which can serve emulators and devices over the gRPC, but I'm not sure if Tart can directly help with doing that besides starting a VM and helping to get it's IP address.

edigaryev avatar Jul 01 '22 06:07 edigaryev

Let's keep the issue open for visibility. not possible atm label should do fine.

fkorotkov avatar Jul 01 '22 23:07 fkorotkov

This can also be useful for things like passing through block devices directly, or in my case passing an optical drive straight through to a VM for isolation/testing purposes.

geerlingguy avatar Oct 05 '22 15:10 geerlingguy

What about employing https://gitlab.freedesktop.org/spice/usbredir ?

sheerun avatar Jan 22 '23 01:01 sheerun

It’d be preferable to use something like usb-ip (but for Mac, as mentioned above) because (unlike USB redirection/pass-through solutions) it would allow sharing one device with multiple guests, from what I understand.

dinvlad avatar Jan 30 '23 09:01 dinvlad

@geerlingguy it is now possible to pass block devices to that VMs via --disk flag. You need to run run tart under sudo though:

sudo TART_HOME="$HOME/.tart" tart run sonoma-xcode --disk=/dev/disk4s1

In the example above /dev/disk4s1 is a USB drive that I have on my machine.

fkorotkov avatar Nov 16 '23 19:11 fkorotkov

Looks like USB Support was added to the Virtualization Framework as beta at WWDC last week. https://developer.apple.com/documentation/virtualization/usb_devices?language=objc

cbreedbfly avatar Jun 17 '24 14:06 cbreedbfly