* [Qemu-devel] usb: a problem of using libusb for usb pass through @ 2013-07-16 8:45 Gonglei (Arei) 2013-07-22 12:58 ` Gerd Hoffmann 0 siblings, 1 reply; 7+ messages in thread From: Gonglei (Arei) @ 2013-07-16 8:45 UTC (permalink / raw) To: Gerd Hoffmann, qemu-devel Cc: Linqiangmin, Luonengjun, Huangweidong (Hardware) Hi, Gerd My Qemu version is 1.5.1, and use libusb for usb pass through. I pass through a host usb device to the guest by bus number and physical port, when I unplug the usb device from the host, and plug in on the same physical port immediately, but the usb device don't show up in the guest. The qemu log show: libusb_release_interface: -4 [NO_DEVICE] libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device /dev/bus/usb/002/004: No such file or directory libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device /dev/bus/usb/002/004: No such file or directory libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device /dev/bus/usb/002/004: No such file or directory I find the reason is that the global libusb_context has recorded the usb devices' devnum, but when the host device was unplugged and plugged from the host, the devnum will change, finally cause the problem. Any ideas ? Thanks! Best Regards! -Gonglei ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] usb: a problem of using libusb for usb pass through 2013-07-16 8:45 [Qemu-devel] usb: a problem of using libusb for usb pass through Gonglei (Arei) @ 2013-07-22 12:58 ` Gerd Hoffmann 2013-07-25 13:21 ` Gonglei (Arei) 2013-07-30 17:13 ` Hans de Goede 0 siblings, 2 replies; 7+ messages in thread From: Gerd Hoffmann @ 2013-07-22 12:58 UTC (permalink / raw) To: Gonglei (Arei) Cc: Linqiangmin, Hans de Goede, Luonengjun, qemu-devel, Huangweidong (Hardware) On 07/16/13 10:45, Gonglei (Arei) wrote: > Hi, Gerd > My Qemu version is 1.5.1, and use libusb for usb pass through. > I pass through a host usb device to the guest by bus number and physical port, when I unplug the usb device from > the host, and plug in on the same physical port immediately, but the usb device don't show up in the guest. > The qemu log show: > libusb_release_interface: -4 [NO_DEVICE] > libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device /dev/bus/usb/002/004: No such file or directory > libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device /dev/bus/usb/002/004: No such file or directory > libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device /dev/bus/usb/002/004: No such file or directory > > I find the reason is that the global libusb_context has recorded the usb devices' devnum, but when the host device was unplugged and plugged > from the host, the devnum will change, finally cause the problem. > Any ideas ? Thanks! Sounds like libusbx doesn't flush the cache on unplug even though it should. Hans? [ qemu uses one global libusb_context. libusb_device and libusb_device_handle are allocated and released on open/close ] cheers, Gerd ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] usb: a problem of using libusb for usb pass through 2013-07-22 12:58 ` Gerd Hoffmann @ 2013-07-25 13:21 ` Gonglei (Arei) 2013-07-30 17:13 ` Hans de Goede 1 sibling, 0 replies; 7+ messages in thread From: Gonglei (Arei) @ 2013-07-25 13:21 UTC (permalink / raw) To: Gerd Hoffmann Cc: Linqiangmin, Hans de Goede, Luonengjun, qemu-devel, Huangweidong (Hardware) > Subject: Re: usb: a problem of using libusb for usb pass through > > On 07/16/13 10:45, Gonglei (Arei) wrote: > > Hi, Gerd > > My Qemu version is 1.5.1, and use libusb for usb pass through. > > I pass through a host usb device to the guest by bus number and physical > port, when I unplug the usb device from > > the host, and plug in on the same physical port immediately, but the usb > device don't show up in the guest. > > The qemu log show: > > libusb_release_interface: -4 [NO_DEVICE] > > libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device > /dev/bus/usb/002/004: No such file or directory > > libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device > /dev/bus/usb/002/004: No such file or directory > > libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device > /dev/bus/usb/002/004: No such file or directory > > > > I find the reason is that the global libusb_context has recorded the usb > devices' devnum, but when the host device was unplugged and plugged > > from the host, the devnum will change, finally cause the problem. > > Any ideas ? Thanks! > > Sounds like libusbx doesn't flush the cache on unplug even though it > should. Hans? > > [ qemu uses one global libusb_context. libusb_device and > libusb_device_handle are allocated and released on open/close ] > > cheers, > Gerd > Thanks for responding, Gerd. Would you have a plan to resolve it? -Gonglei ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] usb: a problem of using libusb for usb pass through 2013-07-22 12:58 ` Gerd Hoffmann 2013-07-25 13:21 ` Gonglei (Arei) @ 2013-07-30 17:13 ` Hans de Goede 2013-07-30 17:15 ` Hans de Goede 2013-07-31 9:47 ` Gerd Hoffmann 1 sibling, 2 replies; 7+ messages in thread From: Hans de Goede @ 2013-07-30 17:13 UTC (permalink / raw) To: Gerd Hoffmann Cc: Linqiangmin, Gonglei (Arei), Luonengjun, qemu-devel, Huangweidong (Hardware) Hi, On 07/22/2013 02:58 PM, Gerd Hoffmann wrote: > On 07/16/13 10:45, Gonglei (Arei) wrote: >> Hi, Gerd >> My Qemu version is 1.5.1, and use libusb for usb pass through. >> I pass through a host usb device to the guest by bus number and physical port, when I unplug the usb device from >> the host, and plug in on the same physical port immediately, but the usb device don't show up in the guest. >> The qemu log show: >> libusb_release_interface: -4 [NO_DEVICE] >> libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device /dev/bus/usb/002/004: No such file or directory >> libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device /dev/bus/usb/002/004: No such file or directory >> libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device /dev/bus/usb/002/004: No such file or directory >> >> I find the reason is that the global libusb_context has recorded the usb devices' devnum, but when the host device was unplugged and plugged >> from the host, the devnum will change, finally cause the problem. >> Any ideas ? Thanks! > > Sounds like libusbx doesn't flush the cache on unplug even though it > should. Hans? This looks like qemu's host-libusb code is re-using the libusb_device handle, what it should do after seeing an unplug (ie ENODEV error), it should close both the handle, and free any devices it may have, then redo the libusb_get_device_list() and you should get a libusb_device with the new address. This is what the usb code in the spice-client does, and it has no problems with sc > [ qemu uses one global libusb_context. libusb_device and > libusb_device_handle are allocated and released on open/close ] That is fine, do you also free the device_list, and re-do the libusb_get_device_list() ? Regards, Hans ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] usb: a problem of using libusb for usb pass through 2013-07-30 17:13 ` Hans de Goede @ 2013-07-30 17:15 ` Hans de Goede 2013-07-31 9:47 ` Gerd Hoffmann 1 sibling, 0 replies; 7+ messages in thread From: Hans de Goede @ 2013-07-30 17:15 UTC (permalink / raw) To: Gerd Hoffmann Cc: Linqiangmin, Gonglei (Arei), Luonengjun, qemu-devel, Huangweidong (Hardware) Hi, On 07/30/2013 07:13 PM, Hans de Goede wrote: > Hi, > > On 07/22/2013 02:58 PM, Gerd Hoffmann wrote: >> On 07/16/13 10:45, Gonglei (Arei) wrote: >>> Hi, Gerd >>> My Qemu version is 1.5.1, and use libusb for usb pass through. >>> I pass through a host usb device to the guest by bus number and physical port, when I unplug the usb device from >>> the host, and plug in on the same physical port immediately, but the usb device don't show up in the guest. >>> The qemu log show: >>> libusb_release_interface: -4 [NO_DEVICE] >>> libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device /dev/bus/usb/002/004: No such file or directory >>> libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device /dev/bus/usb/002/004: No such file or directory >>> libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device /dev/bus/usb/002/004: No such file or directory >>> >>> I find the reason is that the global libusb_context has recorded the usb devices' devnum, but when the host device was unplugged and plugged >>> from the host, the devnum will change, finally cause the problem. >>> Any ideas ? Thanks! >> >> Sounds like libusbx doesn't flush the cache on unplug even though it >> should. Hans? > > This looks like qemu's host-libusb code is re-using the libusb_device handle, what it should do after seeing an > unplug (ie ENODEV error), it should close both the handle, and free any devices it may have, then redo > the libusb_get_device_list() and you should get a libusb_device with the new address. This is what the > usb code in the spice-client does, and it has no problems with sc That should have read: "it has no problems with this scenario" Regards, Hans ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] usb: a problem of using libusb for usb pass through 2013-07-30 17:13 ` Hans de Goede 2013-07-30 17:15 ` Hans de Goede @ 2013-07-31 9:47 ` Gerd Hoffmann 2013-08-01 1:24 ` Gonglei (Arei) 1 sibling, 1 reply; 7+ messages in thread From: Gerd Hoffmann @ 2013-07-31 9:47 UTC (permalink / raw) To: Hans de Goede Cc: Linqiangmin, Gonglei (Arei), Luonengjun, qemu-devel, Huangweidong (Hardware) On 07/30/13 19:13, Hans de Goede wrote: > Hi, > > On 07/22/2013 02:58 PM, Gerd Hoffmann wrote: >> On 07/16/13 10:45, Gonglei (Arei) wrote: >>> Hi, Gerd >>> My Qemu version is 1.5.1, and use libusb for usb pass through. >>> I pass through a host usb device to the guest by bus number and >>> physical port, when I unplug the usb device from >>> the host, and plug in on the same physical port immediately, but the >>> usb device don't show up in the guest. >>> The qemu log show: >>> libusb_release_interface: -4 [NO_DEVICE] >>> libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device >>> /dev/bus/usb/002/004: No such file or directory >>> libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device >>> /dev/bus/usb/002/004: No such file or directory >>> libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device >>> /dev/bus/usb/002/004: No such file or directory >>> >>> I find the reason is that the global libusb_context has recorded >>> the usb devices' devnum, but when the host device was unplugged and >>> plugged >>> from the host, the devnum will change, finally cause the problem. >>> Any ideas ? Thanks! >> >> Sounds like libusbx doesn't flush the cache on unplug even though it >> should. Hans? > > This looks like qemu's host-libusb code is re-using the libusb_device > handle, what it should do after seeing an > unplug (ie ENODEV error), it should close both the handle, and free any > devices it may have, then redo > the libusb_get_device_list() and you should get a libusb_device with the > new address. This is what the > usb code in the spice-client does, and it has no problems with sc host-libusb.c doesn't do that, and I also can't reproduce the issue. Running libusbx-1.0.14 at the moment. I get slightly different errors: libusb_release_interface: -4 [NO_DEVICE] libusbx: error [_open_sysfs_attr] open /sys/bus/usb/devices/10-1/bConfigurationValue failed ret=-1 errno=2 Which comes from host-libusb trying to release the (unplugged) device on closing. They are harmless. >> [ qemu uses one global libusb_context. libusb_device and >> libusb_device_handle are allocated and released on open/close ] > > That is fine, do you also free the device_list, and re-do the > libusb_get_device_list() ? Sure. Each time it looks for new devices it calls libusb_get_device_list(). cheers, Gerd ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] usb: a problem of using libusb for usb pass through 2013-07-31 9:47 ` Gerd Hoffmann @ 2013-08-01 1:24 ` Gonglei (Arei) 0 siblings, 0 replies; 7+ messages in thread From: Gonglei (Arei) @ 2013-08-01 1:24 UTC (permalink / raw) To: Gerd Hoffmann, Hans de Goede Cc: Linqiangmin, Luonengjun, qemu-devel, Huangweidong (Hardware) > -----Original Message----- > From: Gerd Hoffmann [mailto:kraxel@redhat.com] > Sent: Wednesday, July 31, 2013 5:47 PM > To: Hans de Goede > Cc: Gonglei (Arei); qemu-devel@nongnu.org; Luonengjun; Huangweidong > (Hardware); Linqiangmin > Subject: Re: usb: a problem of using libusb for usb pass through > > On 07/30/13 19:13, Hans de Goede wrote: > > Hi, > > > > On 07/22/2013 02:58 PM, Gerd Hoffmann wrote: > >> On 07/16/13 10:45, Gonglei (Arei) wrote: > >>> Hi, Gerd > >>> My Qemu version is 1.5.1, and use libusb for usb pass through. > >>> I pass through a host usb device to the guest by bus number and > >>> physical port, when I unplug the usb device from > >>> the host, and plug in on the same physical port immediately, but the > >>> usb device don't show up in the guest. > >>> The qemu log show: > >>> libusb_release_interface: -4 [NO_DEVICE] > >>> libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device > >>> /dev/bus/usb/002/004: No such file or directory > >>> libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device > >>> /dev/bus/usb/002/004: No such file or directory > >>> libusbx: error [_get_usbfs_fd] libusbx couldn't open USB device > >>> /dev/bus/usb/002/004: No such file or directory > >>> > >>> I find the reason is that the global libusb_context has recorded > >>> the usb devices' devnum, but when the host device was unplugged and > >>> plugged > >>> from the host, the devnum will change, finally cause the problem. > >>> Any ideas ? Thanks! > >> > >> Sounds like libusbx doesn't flush the cache on unplug even though it > >> should. Hans? > > > > This looks like qemu's host-libusb code is re-using the libusb_device > > handle, what it should do after seeing an > > unplug (ie ENODEV error), it should close both the handle, and free any > > devices it may have, then redo > > the libusb_get_device_list() and you should get a libusb_device with the > > new address. This is what the > > usb code in the spice-client does, and it has no problems with sc > > host-libusb.c doesn't do that, and I also can't reproduce the issue. > Running libusbx-1.0.14 at the moment. > Hi, Gerd. I was using libusbx-1.0.16 when I reported that overhead problem. -Gonglei > I get slightly different errors: > > libusb_release_interface: -4 [NO_DEVICE] > libusbx: error [_open_sysfs_attr] open > /sys/bus/usb/devices/10-1/bConfigurationValue failed ret=-1 errno=2 > > Which comes from host-libusb trying to release the (unplugged) device on > closing. They are harmless. > > >> [ qemu uses one global libusb_context. libusb_device and > >> libusb_device_handle are allocated and released on open/close ] > > > > That is fine, do you also free the device_list, and re-do the > > libusb_get_device_list() ? > > Sure. Each time it looks for new devices it calls libusb_get_device_list(). > > cheers, > Gerd > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-08-01 1:26 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-07-16 8:45 [Qemu-devel] usb: a problem of using libusb for usb pass through Gonglei (Arei) 2013-07-22 12:58 ` Gerd Hoffmann 2013-07-25 13:21 ` Gonglei (Arei) 2013-07-30 17:13 ` Hans de Goede 2013-07-30 17:15 ` Hans de Goede 2013-07-31 9:47 ` Gerd Hoffmann 2013-08-01 1:24 ` Gonglei (Arei)
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.