qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Re: [Qemu-devel] [usb] call destroy for usb devices upon removal from guest
@ 2006-07-17  8:35 Lonnie Mendez
  2006-07-18 21:36 ` Fabrice Bellard
  2006-07-18 21:46 ` Fabrice Bellard
  0 siblings, 2 replies; 5+ messages in thread
From: Lonnie Mendez @ 2006-07-17  8:35 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 179 bytes --]

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.

[-- Attachment #2: qemu-usb-cleanup.diff --]
[-- Type: text/x-patch, Size: 975 bytes --]

--- 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

^ permalink raw reply	[flat|nested] 5+ messages in thread
* [Qemu-devel] [usb] call destroy for usb devices upon removal from guest
@ 2006-05-26 22:36 Lonnie Mendez
  0 siblings, 0 replies; 5+ messages in thread
From: Lonnie Mendez @ 2006-05-26 22:36 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 123 bytes --]

   lo list.  The attached patch calls the cleanup message destroy when 
the device is detached by the user from the guest.

[-- Attachment #2: qemu-usb-destroy.diff --]
[-- Type: text/plain, Size: 1486 bytes --]

--- qemu/hw/usb-hub.c	2006-05-25 18:58:51.000000000 -0500
+++ qemu/hw/usb-hub.c	2006-05-26 16:47:47.000000000 -0500
@@ -194,7 +194,6 @@
             /* send the detach message */
             dev->handle_packet(dev, 
                                USB_MSG_DETACH, 0, 0, NULL, 0);
-            port->port.dev = NULL;
         }
     }
 }
--- qemu/hw/usb-uhci.c	2006-05-22 12:17:06.000000000 -0500
+++ qemu/hw/usb-uhci.c	2006-05-26 15:41:48.000000000 -0500
@@ -355,7 +355,6 @@
             dev->handle_packet(dev, 
                                USB_MSG_DETACH, 0, 0, NULL, 0);
         }
-        port->port.dev = NULL;
     }
 }
 
--- qemu/hw/usb-ohci.c	2006-05-25 18:37:07.000000000 -0500
+++ qemu/hw/usb-ohci.c	2006-05-26 16:58:03.000000000 -0500
@@ -308,7 +308,6 @@
             dev->handle_packet(dev, 
                                USB_MSG_DETACH, 0, 0, NULL, 0);
         }
-        port->port.dev = NULL;
         dprintf("usb-ohci: Detached port %d\n", port1->index);
     }
 
--- qemu/vl.c	2006-05-25 18:58:51.000000000 -0500
+++ qemu/vl.c	2006-05-26 15:42:55.000000000 -0500
@@ -3313,6 +3313,7 @@
 {
     USBPort *port;
     USBPort **lastp;
+    USBDevice *dev;
     int bus_num, addr;
     const char *p;
 
@@ -3339,6 +3340,9 @@
 
     *lastp = port->next;
     usb_attach(port, NULL);
+    dev = port->dev;
+    dev->handle_packet(dev, USB_MSG_DESTROY, 0, 0, NULL, 0);
+    port->dev = NULL;
     port->next = free_usb_ports;
     free_usb_ports = port;
     return 0;

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-07-19  3:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-17  8:35 [Qemu-devel] [usb] call destroy for usb devices upon removal from guest Lonnie Mendez
2006-07-18 21:36 ` Fabrice Bellard
2006-07-18 21:46 ` Fabrice Bellard
2006-07-19  3:12   ` Lonnie Mendez
  -- strict thread matches above, loose matches on Subject: below --
2006-05-26 22:36 Lonnie Mendez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).