Signed-off-by: Shahar Havivi <shah...@redhat.com> --- usb-linux.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/usb-linux.c b/usb-linux.c index 22a85e3..2a595f0 100644 --- a/usb-linux.c +++ b/usb-linux.c @@ -286,6 +286,17 @@ static void async_cancel(USBPacket *unused, void *opaque) } } +static void usb_host_cleanup(void) +{ + struct USBHostDevice *s; + + QTAILQ_FOREACH(s, &hostdevs, next) { + if (s->fd != -1) { + ioctl(s->fd, USBDEVFS_RESET); + } + } +} + static int usb_host_claim_interfaces(USBHostDevice *dev, int configuration) { int dev_descr_len, config_descr_len; @@ -1066,6 +1077,7 @@ USBDevice *usb_host_device_open(const char *devname) qdev_prop_set_uint32(&dev->qdev, "vendorid", filter.vendor_id); qdev_prop_set_uint32(&dev->qdev, "productid", filter.product_id); qdev_init_nofail(&dev->qdev); + atexit(usb_host_cleanup); return dev; fail: -- 1.7.0.4