-
Notifications
You must be signed in to change notification settings - Fork 660
USB passthrough rabbit hole #2224
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
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 |
if you refer to https://docs.getutm.app/guest-support/sharing/usb/
Yes, it is "broken", at least your mileage may vary. And yes, after a lot of research it looks like all solutions out there use E.g. even for QEMU people complain about some devices not working all the time 🤷 As I use MacOS only for work (as do most people I guess) and there's no real business case for this feature (for most companies) I suppose this won't be fixed anytime soon 🤷 FYI: I was only interested in this, because MacOS doesn't allow for USB sniffing without deactivating System Integrity Protection and I wanted a workaround :D |
Parallels works, qemu doesn't |
Possible. In case you refer to "Parallels Desktop", that's a closed-source, commercial solution. 🤷 Most people don't have the time (nor the nerve) to cater for the needs of people who complain about how bad open source is, want stuff for free and then compare solutions with industry standard paid products (all while overlooking that nothing in the Apple world is actually meant to incentivize open source community contributions :D) |
A very weird response my dude. I'm merely pointing out that it is possible. This isn't a criticism of open source, so please park your zealotry. I'm also pointing out that a solution exists for those who need it. As for kernel extensions, they can also be open source and the API is well documented. This isn't Linux (thank God). A long ass time ago (2001?), I even wrote a driver for OSX for an obscure USB device. Also, it's unlikely a kernel extension is used let alone necessary. DriverKit runs in userspace. Even the first OS X release had USB drivers run in userspace. Again, this isn't Linux (thank God). |
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: