Usb 20200617 patches
The following changes since commit 5c24bce3056ff209a1ecc50ff4b7e65b85ad8e74:
Merge remote-tracking branch 'remotes/stsquad/tags/pull-testing-and-plugin-160620-2' into staging (2020-06-16 14:57:15 +0100)
are available in the Git repository at:
git://git.kraxel.org/qemu tags/usb-20200617-pull-request
for you to fetch changes up to 54cdfe511219b8051046be55a6e156c4f08ff7ff:
usb-host: workaround libusb bug (2020-06-17 09:12:33 +0200)
----------------------------------------------------------------
usb-host: add hostdevice property, workaround libusb bug
----------------------------------------------------------------
Gerd Hoffmann (2):
usb: add hostdevice property to usb-host
usb-host: workaround libusb bug
hw/usb/host-libusb.c | 89 +++++++++++++++++++++++++++++++++++++------- hw/usb/trace-events | 1 + 2 files changed, 76 insertions(+), 14 deletions(-)
Signature · 1 line
2.18.4
[PULL 2/2] usb-host: workaround libusb bug
libusb seems to no allways call the completion callback for requests canceled (which it is supposed to do according to the docs). So add a limit to avoid qemu waiting forever.
Message-Id: <[email protected]>
--- hw/usb/host-libusb.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
hw/usb/host-libusb.c +14 -0
@@ -972,6 +972,7 @@ fail:static void usb_host_abort_xfers (USBHostDevice *s) {USBHostRequest *r, *rtmp; +int limit =100 ; QTAILQ_FOREACH_SAFE(r, &s->requests, next, rtmp) {usb_host_req_abort (r);
@@ -982,6 +983,19 @@ static void usb_host_abort_xfers(USBHostDevice *s)memset (&tv,0 ,sizeof (tv)); tv.tv_usec =2500 ;libusb_handle_events_timeout (ctx, &tv); +if (--limit ==0 ) { +/* +* Don't wait forever for libusb calling the complete +* callback (which will unlink and free the request). +* +* Leaking memory here, to make sure libusb will not +* access memory which we have released already. +*/ + QTAILQ_FOREACH_SAFE(r, &s->requests, next, rtmp) { +QTAILQ_REMOVE (&s->requests, r, next); + } +return ; + } } }
Signature · 1 line
2.18.4
[PULL 1/2] usb: add hostdevice property to usb-host
In reply to Gerd HoffmannThe new property allows to specify usb host device name. Uses standard qemu_open(), so both file system path (/dev/bus/usb/$bus/$dev on linux) and file descriptor passing can be used.
Requires libusb 1.0.23 or newer. The hostdevice property is only present in case qemu is compiled against a new enough library version, so the presence of the property can be used for feature detection.
Message-Id: <[email protected]>
--- hw/usb/host-libusb.c | 75 +++++++++++++++++++++++++++++++++++--------- hw/usb/trace-events | 1 + 2 files changed, 62 insertions(+), 14 deletions(-)
hw/usb/host-libusb.c +61 -14
@@ -80,6 +80,7 @@ struct USBHostDevice {/* properties */ struct USBAutoFilter match; +char *hostdevice;int32_t bootindex;uint32_t iso_urb_count;uint32_t iso_urb_frames;
@@ -97,6 +98,7 @@ struct USBHostDevice {int addr;char port[16 ]; +int hostfd;libusb_device *dev;libusb_device_handle *dh;struct libusb_device_descriptor ddesc;
@@ -880,26 +882,45 @@ static void usb_host_ep_update(USBHostDevice *s)libusb_free_config_descriptor (conf); } -static int usb_host_open (USBHostDevice *s,libusb_device *dev) +static int usb_host_open (USBHostDevice *s,libusb_device *dev,int hostfd) {USBDevice *udev =USB_DEVICE (s); -int bus_num =libusb_get_bus_number (dev); -int addr =libusb_get_device_address (dev); +int bus_num =0 ; +int addr =0 ;int rc;Error *local_err =NULL ;if (s->bh_postld_pending) {return -1 ; } - -trace_usb_host_open_started (bus_num, addr); -if (s->dh !=NULL ) { goto fail; } - rc =libusb_open (dev, &s->dh); -if (rc !=0 ) { - goto fail; + +if (dev) { + bus_num =libusb_get_bus_number (dev); + addr =libusb_get_device_address (dev); +trace_usb_host_open_started (bus_num, addr); + + rc =libusb_open (dev, &s->dh); +if (rc !=0 ) { + goto fail; + } + }else { +#if LIBUSB_API_VERSION >=0x01000107 +trace_usb_host_open_hostfd (hostfd); + + rc =libusb_wrap_sys_device (ctx, hostfd, &s->dh); +if (rc !=0 ) { + goto fail; + } + s->hostfd = hostfd; + dev =libusb_get_device (s->dh); + bus_num =libusb_get_bus_number (dev); + addr =libusb_get_device_address (dev); +#else +g_assert_not_reached (); +#endif } s->dev = dev;
@@ -988,6 +1009,11 @@ static int usb_host_close(USBHostDevice *s) s->dh =NULL ; s->dev =NULL ; +if (s->hostfd !=-1 ) { +close (s->hostfd); + s->hostfd =-1 ; + } +usb_host_auto_check (NULL );return 0 ; }
@@ -1025,9 +1051,6 @@ static libusb_device *usb_host_find_ref(int bus, int addr)libusb_device *ret =NULL ;int i, n; -if (usb_host_init () !=0 ) { -return NULL ; - } n =libusb_get_device_list (ctx, &devs);for (i =0 ; i < n; i++) { if (libusb_get_bus_number(devs[i]) == bus &&
@@ -1046,6 +1069,10 @@ static void usb_host_realize(USBDevice *udev, Error **errp)libusb_device *ldev;int rc; +if (usb_host_init () !=0 ) { +error_setg (errp,"failed to init libusb" ); +return ; + }if (s->match.vendor_id >0xffff ) {error_setg (errp,"vendorid out of range" );return ;
@@ -1064,7 +1091,24 @@ static void usb_host_realize(USBDevice *udev, Error **errp) udev->auto_attach =0 ;QTAILQ_INIT (&s->requests);QTAILQ_INIT (&s->isorings); + s->hostfd =-1 ; +#if LIBUSB_API_VERSION >=0x01000107 +if (s->hostdevice) { +int fd; + s->needs_autoscan = false; + fd =qemu_open (s->hostdevice,O_RDWR ); +if (fd <0 ) { +error_setg_errno (errp, errno,"failed to open %s" , s->hostdevice); +return ; + } + rc =usb_host_open (s,NULL , fd); +if (rc <0 ) { +error_setg (errp,"failed to open host usb device %s" , s->hostdevice); +return ; + } + } else +#endif if (s->match.addr && s->match.bus_num && !s->match.vendor_id && !s->match.product_id &&
@@ -1077,7 +1121,7 @@ static void usb_host_realize(USBDevice *udev, Error **errp) s->match.bus_num, s->match.addr);return ; } - rc =usb_host_open (s, ldev); + rc =usb_host_open (s, ldev,0 );libusb_unref_device (ldev);if (rc <0 ) { error_setg(errp, "failed to open host usb device %d:%d",
@@ -1605,6 +1649,9 @@ static Property usb_host_dev_properties[] = {DEFINE_PROP_STRING ("hostport" , USBHostDevice, match.port),DEFINE_PROP_UINT32 ("vendorid" , USBHostDevice, match.vendor_id,0 ),DEFINE_PROP_UINT32 ("productid" , USBHostDevice, match.product_id,0 ), +#if LIBUSB_API_VERSION >= 0x01000107 +DEFINE_PROP_STRING ("hostdevice" , USBHostDevice, hostdevice), +#endifDEFINE_PROP_UINT32 ("isobufs" , USBHostDevice, iso_urb_count,4 ),DEFINE_PROP_UINT32 ("isobsize" , USBHostDevice, iso_urb_frames,32 ), DEFINE_PROP_BOOL("guest-reset", USBHostDevice,
@@ -1723,7 +1770,7 @@ static void usb_host_auto_check(void *unused)if (s->dh !=NULL ) {continue ; } -if (usb_host_open (s, devs[i]) <0 ) { +if (usb_host_open (s, devs[i],0 ) <0 ) { s->errcount++;continue ; }
hw/usb/trace-events +1 -0
@@ -291,6 +291,7 @@ usb_mtp_file_monitor_event(int dev, const char *path, const char *s) "dev %d, pa # host-libusb.c usb_host_open_started(int bus, int addr) "dev %d:%d" +usb_host_open_hostfd(int hostfd) "hostfd %d" usb_host_open_success(int bus, int addr) "dev %d:%d" usb_host_open_failure(int bus, int addr) "dev %d:%d" usb_host_close(int bus, int addr) "dev %d:%d"
Signature · 1 line
2.18.4
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the asan build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-debug@fedora TARGET_LIST=x86_64-softmmu J=14 NETWORK=1 === TEST SCRIPT END ===
LINK tests/qemu-iotests/socket_scm_helper GEN docs/interop/qemu-qmp-ref.html GEN docs/interop/qemu-qmp-ref.txt
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of ` GEN docs/interop/qemu-qmp-ref.7__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
CC qga/commands.o
CC qga/guest-agent-command-state.o
---
AR libvhost-user.a GEN docs/interop/qemu-ga-ref.html GEN docs/interop/qemu-ga-ref.txt /usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o) GEN docs/interop/qemu-ga-ref.7 AS pc-bios/optionrom/multiboot.o AS pc-bios/optionrom/linuxboot.o --- BUILD pc-bios/optionrom/kvmvapic.img BUILD pc-bios/optionrom/multiboot.img BUILD pc-bios/optionrom/linuxboot_dma.img /usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o) BUILD pc-bios/optionrom/linuxboot.raw BUILD pc-bios/optionrom/kvmvapic.raw BUILD pc-bios/optionrom/multiboot.raw BUILD pc-bios/optionrom/linuxboot_dma.raw /usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o) SIGN pc-bios/optionrom/linuxboot.bin SIGN pc-bios/optionrom/multiboot.bin LINK ivshmem-client --- BUILD pc-bios/optionrom/pvh.img BUILD pc-bios/optionrom/pvh.raw LINK ivshmem-server
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
SIGN pc-bios/optionrom/pvh.bin
LINK qemu-nbd/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK qemu-storage-daemon/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK qemu-img/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK qemu-io/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK qemu-edid/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o) /usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK fsdev/virtfs-proxy-helper
LINK scsi/qemu-pr-helper/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK qemu-bridge-helper/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK virtiofsd/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK vhost-user-input/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o) /usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
GEN x86_64-softmmu/hmp-commands.h
GEN x86_64-softmmu/hmp-commands-info.h
GEN x86_64-softmmu/config-target.h
---
CC x86_64-softmmu/hw/net/virtio-net.o
CC x86_64-softmmu/hw/rdma/rdma_utils.o
CC x86_64-softmmu/hw/rdma/rdma_backend.o
/tmp/qemu-test/src/fpu/softfloat.c:3365:13: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
absZ &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:3423:18: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
absZ0 &= ~ ( ( (uint64_t) ( absZ1<<1 ) == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:3483:18: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
absZ0 &= ~(((uint64_t)(absZ1<<1) == 0) & roundNearestEven);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:3606:13: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
zSig &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:3760:13: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
zSig &= ~ ( ( ( roundBits ^ 0x200 ) == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:3987:21: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:4003:22: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
zSig0 &= ~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:4273:18: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
zSig1 &= ~ ( ( zSig2 + zSig2 == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!8 errors generated.
make[1]: *** [/tmp/qemu-test/src/rules.mak:69: fpu/softfloat.o] Error 1
make[1]: *** Waiting for unfinished jobs..../tmp/qemu-test/src/migration/ram.c:919:45: error: implicit conversion from 'unsigned long' to 'double' changes value from 18446744073709551615 to 18446744073709551616 [-Werror,-Wimplicit-int-float-conversion]
xbzrle_counters.encoding_rate = UINT64_MAX;
~ ^~~~~~~~~~/usr/include/stdint.h:130:23: note: expanded from macro 'UINT64_MAX'
---
18446744073709551615UL
^~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [/tmp/qemu-test/src/rules.mak:69: migration/ram.o] Error 1
make: *** [Makefile:527: x86_64-softmmu/all] Error 2
make: *** Waiting for unfinished jobs....
Traceback (most recent call last):
File "./tests/docker/docker.py", line 669, in <module>
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=7637dd62d65a44c4b23b4dea307e6cf4', '-u', '1001', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=x86_64-softmmu', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-6g6548n1/src/docker-src.2020-06-17-07.29.01.31752:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-debug']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=7637dd62d65a44c4b23b4dea307e6cf4
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-6g6548n1/src'
make: *** [docker-run-test-debug@fedora] Error 2
real 3m58.779s
user 0m8.571s
The full log is available at
http://patchew.org/logs/[email protected]/testing.asan/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Peter Maydell
AppliedQuoted 9 lines · Gerd Hoffmann
The following changes since commit
5c24bce3056ff209a1ecc50ff4b7e65b85ad8e74:Merge remote-tracking branch 'remotes/stsquad/tags/pull-testing-and-plugin-160620-2' into staging (2020-06-16 14:57:15 +0100)
are available in the Git repository at:
git://git.kraxel.org/qemutags/usb-20200617-pull-request
Quoted 8 lines
for you to fetch changes up to
54cdfe511219b8051046be55a6e156c4f08ff7ff:usb-host: workaround libusb bug (2020-06-17 09:12:33 +0200)
----------------------------------------------------------------
usb-host: add hostdevice property, workaround libusb bug----------------------------------------------------------------
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/5.1
for any user-visible changes.
-- PMM