utmapp / UTM

Virtual machines for iOS and macOS
https://getutm.app
Apache License 2.0
26.29k stars 1.31k forks source link

Add USB sharing option to macOS guest (from macOS host) #3778

Open natevw opened 2 years ago

natevw commented 2 years ago

With an e.g. Windows guest UTM offers sharing settings including for USB devices:

Screen Shot 2022-03-14 at 3 26 33 PM

But no such settings are available for a macOS guest:

Screen Shot 2022-03-14 at 3 26 05 PM

Can USB devices be shared with the new Virtualization framework? [Update: fwiw, I'm sure not seeing anything related to USB passthrough in Apple's https://developer.apple.com/documentation/virtualization overview documentation… ☹️ ]

(Sorry if this is a duplicate, I could not find one. This is in a somewhat similar vein as https://github.com/utmapp/UTM/issues/3567 — the new Virtualization.framework is still missing some features compared to the QEMU settings. File sharing is another such but I'm focusing this request on USB specifically since there's userspace options for transferring files, but not really any good workaround for passing through a USB device.)

Valkhes commented 2 years ago

Hello,

I asked this question on Twitter few weeks ago : https://twitter.com/Valkhes/status/1481192075672629253?s=20&t=ZCdAmzI9b3KW1p2CD2rE0g

This is the feature I'm also missing to be able to use macOS VM, but it seems that it is not currently supported by Apple in Virtualization.framework . Right now, it seems that no options are available at all, I also tried other apps like Parallels for example, and they are not supporting it too. Even USB over IP solutions right now can't use a mac M1 as a guest to receive an USB device, which would have been a great workaround for me.

This looks to be for the moment a dead end until Apple can support it.

osy commented 2 years ago

It is indeed dependent on Apple support. We have to wait until WWDC to see what's next for Virtualization.framework.

tucnak commented 2 years ago

Is there news/work-around on this?

blue-beret commented 1 year ago

These look like they're relevant:

Entitlement for Virtualization Guest USB access

Apple docs aren't exactly self explanatory but it seems like these would be used to open a connection to an interface or specific device and then you could use something like SPICE's usbredir for the VM end.

(https://developer.apple.com/documentation/iousbhost/iousbhostobject) (https://developer.apple.com/documentation/iousbhost/iousbhostdevice) (https://developer.apple.com/documentation/iousbhost/iousbhostinterface)

Further investigation seems as though this may only work for Hypervisor.Framework.

osy commented 1 year ago

Yeah we use them in QEMU. This issue is about Apple Virtualization.

ZeppLu commented 8 months ago

With Sonoma we can share a block device with guest, is this feature helpful?

jdjingdian commented 8 months ago

Hi, I'm just a bit curious. I tried Parallels Desktop, they have a 'Rosetta' switch in vm settings, and even when I enable it, I can still share my usb device into the vm. So do you think Apple Hypervisor has the ability to share USB, or Parallels achieve this in some tricky way?

jdjingdian commented 8 months ago

Hi, I'm just a bit curious. I tried Parallels Desktop, they have a 'Rosetta' switch in vm settings, and even when I enable it, I can still share my usb device into the vm. So do you think Apple Hypervisor has the ability to share USB, or Parallels achieve this in some tricky way?

After some research, I think the Rosetta does not really need the Apple Hypervisor to run, its kind of apple's limitation. There is a repo that patch previous version of rosetta and let it run on any arm64 linux. https://github.com/CathyKMeow/rosetta-linux-asahi I tried it on a vm manage by qemu, and it works.

So maybe parallels did not actually use the Apple Hypervisor as backend.

ZeppLu commented 8 months ago

I tried Parallels Desktop, they have a 'Rosetta' switch in vm settings, and even when I enable it, I can still share my usb device into the vm.

I believe you're referencing Linux guest, since PD does not support USB passthrough in mac guest either.

solarispika commented 3 months ago

Looks like Virtualization.framework has new USB support now. https://developer.apple.com/documentation/virtualization/vzvirtualmachineconfiguration/4360569-usbcontrollers?changes=latest_minor&language=objc Does it help on USB-sharing?

jredbart commented 2 months ago

Are there any plans to adopt the new virtualisation framework USB support with the upcoming macOS release?

joshm89 commented 2 months ago

Would be brilliant if we can get support for USB devices on a macOS host. I work on my personal device and would love to set up a separate macOS VM for work, but I need access to my webcam.

conradev commented 3 weeks ago

This would go great with the new iCloud support on macOS 15 because I use USB security keys to protect my Apple ID