From patchwork Sat Jun 12 09:59:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shahar Havivi X-Patchwork-Id: 55385 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5D35DB7D85 for ; Sat, 12 Jun 2010 20:04:32 +1000 (EST) Received: from localhost ([127.0.0.1]:32912 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ONNZl-0003g1-FU for incoming@patchwork.ozlabs.org; Sat, 12 Jun 2010 06:04:29 -0400 Received: from [140.186.70.92] (port=33347 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ONNVB-0001Wb-8Z for qemu-devel@nongnu.org; Sat, 12 Jun 2010 05:59:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ONNVA-0004zh-3a for qemu-devel@nongnu.org; Sat, 12 Jun 2010 05:59:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1026) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ONNV9-0004zW-M2 for qemu-devel@nongnu.org; Sat, 12 Jun 2010 05:59:44 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5C9xeGX016295 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 12 Jun 2010 05:59:40 -0400 Received: from localhost (dhcp-1-229.tlv.redhat.com [10.35.1.229]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5C9xYbd016836 for ; Sat, 12 Jun 2010 05:59:35 -0400 Date: Sat, 12 Jun 2010 12:59:50 +0300 From: Shahar Havivi To: qemu-devel@nongnu.org Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-08-17) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 2/2] Return usb device to host on exit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Shahar Havivi --- 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: