From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1G2OZT-00066F-1Q for qemu-devel@nongnu.org; Mon, 17 Jul 2006 04:35:19 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1G2OZQ-000644-I1 for qemu-devel@nongnu.org; Mon, 17 Jul 2006 04:35:18 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G2OZQ-00063s-5n for qemu-devel@nongnu.org; Mon, 17 Jul 2006 04:35:16 -0400 Received: from [24.93.47.44] (helo=ms-smtp-05.texas.rr.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1G2Oc2-0001Tx-Tp for qemu-devel@nongnu.org; Mon, 17 Jul 2006 04:37:59 -0400 Received: from vaio (cpe-67-9-160-120.austin.res.rr.com [67.9.160.120]) by ms-smtp-05.texas.rr.com (8.13.6/8.13.6) with ESMTP id k6H8ZD9Q026996 for ; Mon, 17 Jul 2006 03:35:14 -0500 (CDT) Subject: Re: [Qemu-devel] [usb] call destroy for usb devices upon removal from guest From: Lonnie Mendez Content-Type: multipart/mixed; boundary="=-SeKbuW6Fw8x4PQUDGO1J" Date: Mon, 17 Jul 2006 03:35:12 -0500 Message-Id: <1153125312.4812.7.camel@vaio> Mime-Version: 1.0 Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --=-SeKbuW6Fw8x4PQUDGO1J Content-Type: text/plain Content-Transfer-Encoding: 7bit lo list. I have found the old diff to be incorrect on many levels. New diff has additionally cleanup code for the linux redirector. Please see the attached patch for solution. --=-SeKbuW6Fw8x4PQUDGO1J Content-Disposition: attachment; filename=qemu-usb-cleanup.diff Content-Type: text/x-patch; name=qemu-usb-cleanup.diff; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit --- qemu/vl.c 2006-07-17 03:16:38.191157512 -0500 +++ qemu/vl.c 2006-07-17 03:18:13.402683160 -0500 @@ -3781,6 +3781,7 @@ { USBPort *port; USBPort **lastp; + USBDevice *dev; int bus_num, addr; const char *p; @@ -3805,8 +3806,10 @@ if (!port) return -1; + dev = port->dev; *lastp = port->next; usb_attach(port, NULL); + dev->handle_reset(dev, 1); port->next = free_usb_ports; free_usb_ports = port; return 0; --- qemu/usb-linux.c 2006-06-26 16:00:51.000000000 -0500 +++ qemu/usb-linux.c 2006-07-17 03:32:28.427699600 -0500 @@ -59,6 +59,14 @@ static void usb_host_handle_reset(USBDevice *dev, int destroy) { + USBHostDevice *s = (USBHostDevice *)dev; + + if (destroy) { + if (s->fd >= 0) + close(s->fd); + qemu_free(s); + return; + } #if 0 USBHostDevice *s = (USBHostDevice *)dev; /* USBDEVFS_RESET, but not the first time as it has already be --=-SeKbuW6Fw8x4PQUDGO1J--