On Sun, 24 Sept 2023 at 23:05, Igor Ordecha <igor.orde...@gmail.com> wrote: > I'm trying to emulate a USB thumb drive from a .img file. My current > arguments for that look like this: > > -drive file=/path/to/file.img,if=none,id=drive-usb0,format=raw -device > nec-usb-xhci,id=xhci -device > usb-storage,bus=xhci.0,id=drive-usb0,drive=drive-usb0,removable=on,serial=0123456789abcdef > > It works but the device shows up as 46f4:0001 (vendor="QEMU", product="QEMU > USB HARDDRIVE") which my guest really doesn't like. Is there a way to change > the vendor id and product id? I looked everywhere, the manpage, forums, I > even asked ChatGPT in desperation(which surprisingly kinda worked. It told me > about the "serial" parameter which I also needed to spoof.), nothing. > > All I found was an email on this mailing list: > https://lists.nongnu.org/archive/html/qemu-discuss/2015-07/msg00072.html (I > don't know how to properly link a thread, this is my first time using a > mailing list, sorry) > It contains a hacky(as described by the author themself) patch to take vid > and pid but it's from 2015 and uses "-usbdevice disk" which is deprecated, I > believe. > > Is there a way to set vid and pid in current versions of QEMU or do I need to > adjust that patch to "-drive usb-storage" myself?
No, I don't think there is any way to set these -- they're in a bit of fixed C code: https://gitlab.com/qemu-project/qemu/-/blob/master/hw/usb/dev-storage.c?ref_type=heads#L165 (The right place to provide a command line override is probably similar to serial=, as a bus property defined in the list in hw/usb/bus.c which then affects the behaviour of the code in hw/usb/desc.c. But I'm not very familiar with the USB subsystem.) What is this guest which doesn't like it? I would have expected that since every random USB stick is going to be from a different vendor that any guest that checks for specific values here would not work on a lot of real-world hardware... thanks -- PMM