utmapp / UTM

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

USB 3.2 controller in QEMU guest #4167

Open techpro2004 opened 2 years ago

techpro2004 commented 2 years ago

I am in the process of adding a egpu as a usb device to a windows 11 vm on a macos host. It would be great if I could get the full bandwidth of the device passed through. This would require a usb 3.2 controller option in utm. Please add the option for a usb 3.2 controller in utm.

ideologysec commented 2 years ago

There are three different versions of USB 3.2 (yes the spec name is hot trash).

USB 3.2 Gen 1 (aka the old "USB 3.0", 5Gbps) is supported via an XHCI device in QEMU.

I don't believe Gen 2 (10Gbps) or Gen 3 (20Gpbs) are currently supported upstream in QEMU; UTM would be blocked on waiting for that to be added.

conath commented 2 years ago

@techpro2004 Are you certain your eGPU works with USB 3.2 or would it need Thunderbolt 3?

Fmstrat commented 2 years ago

I don't believe Gen 2 (10Gbps) or Gen 3 (20Gpbs) are currently supported upstream in QEMU; UTM would be blocked on waiting for that to be added.

Really? Then how are people doing this 4 years ago? https://www.reddit.com/r/VFIO/comments/am10z3/success_thunderbolt_egpu_passthrough_on_dell_9560/

Or is this host-OS specific?

conath commented 2 years ago

I don't believe Gen 2 (10Gbps) or Gen 3 (20Gpbs) are currently supported upstream in QEMU; UTM would be blocked on waiting for that to be added.

Really? Then how are people doing this 4 years ago? https://www.reddit.com/r/VFIO/comments/am10z3/success_thunderbolt_egpu_passthrough_on_dell_9560/

Or is this host-OS specific?

The link you shared is about a very different version of QEMU and a somewhat different use case. In the link above, someone is using the KVM backend to pass through a PCIe device. "KVM" is a "kernel virtual machine" and relies on the x86 CPU virtualization features. It is not available on Mac hosts (at least those with Apple Silicon).

On Mac, UTM uses the HVF & SPICE "backend" layers, which currently lack the features as mentioned above.

Fmstrat commented 2 years ago

@conath Interesting, and good to know. I've previously used QEMU to pass through PCIe and USB controllers similar to the above using a command like below, so I didn't know if it was possible to do the same with the Thunderbolt 3 controller:

    sudo qemu-system-x86_64 \
    -name $vmname,process=$vmname \
    -machine type=q35,accel=kvm \
    -cpu host,kvm=off,hv_vendor_id=1234567890ab,hv_vapic,hv_time,hv_relaxed,hv_spinlocks=0x1fff \
    -smp 6,sockets=1,cores=3,threads=2 \
    -m 8G \
    -mem-path /dev/hugepages \
    -mem-prealloc \
    -balloon none \
    -rtc clock=host,base=localtime \
    -vga none \
    -nographic \
    -serial none \
    -parallel none \
    -soundhw hda \
    -usb \
    -device usb-host,vendorid=0x045e,productid=0x02e6 \
    -device usb-host,vendorid=0x045e,productid=0x02ea \
    -device usb-host,vendorid=0x045e,productid=0x02fe \
    \
    -device usb-host,vendorid=0x0bda,productid=0x8153 \
    \
    -device usb-host,vendorid=0x0a12,productid=0x0001 \
    \
    -device usb-host,vendorid=0x0424,productid=0x274d \
    -device usb-host,vendorid=0x0bb4,productid=0x0306 \
    -device usb-host,vendorid=0x0bb4,productid=0x2744 \
    \
    -device vfio-pci,host=01:00.0,multifunction=on \
    -device vfio-pci,host=01:00.1 \
    -drive if=pflash,format=raw,readonly,file=/usr/share/OVMF/OVMF_CODE.fd \
    -drive if=pflash,format=raw,file=/tmp/my_vars.fd \
    -boot order=dc \
    -drive id=disk0,if=virtio,cache=none,format=qcow2,file=/storage/KVM/Windows10/windows10vm.qcow2 \
    -drive id=disk1,if=virtio,cache=none,format=qcow2,file=/storage/KVM/Windows10/windows10vm_games.qcow2 \
    \
    -object input-linux,id=mouse1,evdev=/dev/input/by-id/usb-Logitech_USB_Receiver-if02-event-mouse \
    -object input-linux,id=kbd,evdev=/dev/input/by-id/usb-Logitech_USB_Receiver-event-kbd,grab_all=on,repeat=on \
    \
    -netdev type=tap,id=net0,ifname=vmtap0,vhost=on \
    -device virtio-net-pci,netdev=net0,mac=00:16:3e:00:01:01

This was for a high-performance gaming use-case.

osy commented 2 years ago

KVM is a Linux specific thing. There’s only HVF on macOS.