-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
USB passthrough rabbit hole #2224
Comments
I wonder if
This happened after I called:
In other words
In fact, I see errors from usb after I kill qemu!
|
In the end, it seems to come down to this [1], This is the correct payload that QEMU supports { "execute": "device_add", "arguments": {"driver": "usb-host", "vendorid": "0x13fe", "productid": "0x3e00", "id": "usb-disk", "hostbus": "1", "hostaddr": "26"} } in order to actually connect the USB device, we need to unload the kexts that talk to the device. If that doesn't happen, libusb_kernel_driver_active will fail. |
fyi, podman 4.x has support for this on macos, which I think comes down to a couple qemu flags. From
And looks like lima already uses the flag |
Does it need the root on the host? |
Following. Would love to see this implemented 😃 |
I got an implementation working, based on https://github.com/SPICEorg/usbredir. It does run the I just wanted to know about the expections for the config file structure.
How would you expect to configure this in the YAML structure? What are the expections if you try to start an instance where the usb port/device is already in use by another instance? Note: It does not use SPICE, but rather qemu's usb-redir function. A similar approach could be used with WSL. Personally I feel like the implementation would be "driver specific", with VZ not offering any support currently. |
Puh... working on a PR, but I'd need some guidance around where want to go with the "daemons". It feels like there's a ton of code tied into the i'm mainly writing this, because if there's another PR working in this area, rather large conflicts in code with low test coverage will arise. |
If it's the same passthrough method as UTM, it's broken and I don't think anyone is working on fixing it |
Description
QEMU usb passthrough rabbit hole
Okay, so I went down this rabbit hole to see how doable it is to implement USB passthrough.
Let's go step by step:
Lima talks to QEMU through QMP (QEMU Machine Protocol). It uses a lib made by DigitalOcean, go-qemu, which has a function DeviceAdd [1] that seems to be autogenerated. From the qemu qmp ref docs [2] we can see that it accepts device, bus and id. However, according to [3], it should accept other kinds of args as well. In our case, device would be usb-host, and then we would require vendorid and productid.
Trying on the qemu monitor, I see this error:
The whole bus could be connected, according to [4]
From my tests, if the device_add syntax is wrong or device is inexistent, it freezes the whole instance, seems to be a qemu bug.
More info at [5] and [6]
References
[1] https://pkg.go.dev/github.com/digitalocean/[email protected]/qmp/raw#Monitor.DeviceAdd
[2] https://www.qemu.org/docs/master/interop/qemu-qmp-ref.html#qapidoc-2506
[3] https://qemu-project.gitlab.io/qemu/system/devices/usb.html
[4] #1317
[5] https://gitlab.com/qemu-project/qemu/-/issues/1951
[6] libusb/libusb#908
The text was updated successfully, but these errors were encountered: