From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FXEUZ-0003sY-JZ for qemu-devel@nongnu.org; Sat, 22 Apr 2006 05:33:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FXEUY-0003rQ-V8 for qemu-devel@nongnu.org; Sat, 22 Apr 2006 05:33:27 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FXEUY-0003r7-Fk for qemu-devel@nongnu.org; Sat, 22 Apr 2006 05:33:26 -0400 Received: from [213.165.64.20] (helo=mail.gmx.net) by monty-python.gnu.org with smtp (Exim 4.52) id 1FXEWI-000593-SY for qemu-devel@nongnu.org; Sat, 22 Apr 2006 05:35:15 -0400 Message-ID: <4449F860.1060809@gmx.de> Date: Sat, 22 Apr 2006 11:33:20 +0200 From: nix.wie.weg@gmx.de MIME-Version: 1.0 Subject: Re: [Qemu-devel] Large USB patch References: <4447E811.1040403@gmx.de> <4448F1F6.4090609@austin.rr.com> <4448FF3F.3030009@austin.rr.com> <44490614.50406@austin.rr.com> <44490852.2080608@gmx.de> <44491659.30804@austin.rr.com> <44491F0A.2090608@austin.rr.com> <444926AC.3070104@austin.rr.com> <44494596.3070808@austin.rr.com> In-Reply-To: <44494596.3070808@austin.rr.com> Content-Type: multipart/mixed; boundary="------------060100010501060807030908" 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 This is a multi-part message in MIME format. --------------060100010501060807030908 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hello, Lonnie Mendez wrote: > > There are of course more bugs I've found. Namely being able to > usb_add any particular string with that string showing up as a new > device even though no valid entry for it exists. I have fixed this issue, also I have found the segfault on usb_del. Patch is attached. Next problem: Linux does not recognize it, if I add a "tablet" while linux is allready running. The attach is not delivered to the operating system. --------------060100010501060807030908 Content-Type: text/plain; name="lusb-upd2.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="lusb-upd2.diff" diff -Nur qemu-last-snapshot/hw/usb-hid.c qemu/hw/usb-hid.c --- qemu-last-snapshot/hw/usb-hid.c 2006-04-22 10:23:40.000000000 +0200 +++ qemu/hw/usb-hid.c 2006-04-22 11:13:31.000000000 +0200 @@ -339,6 +339,13 @@ return 1; } +static int usb_mouse_handle_close(USBDevice *dev) +{ + USBMouseState *s = (USBMouseState *)dev->opaque; + qemu_free (s); + return 1; +} + static int usb_mouse_handle_control(USBDevice *dev, int request, int value, int index, int length, uint8_t *data) { @@ -541,6 +548,7 @@ dev->handle_packet= usb_generic_handle_packet; dev->handle_reset= usb_mouse_handle_reset; + dev->handle_close= usb_mouse_handle_close; dev->handle_control= usb_mouse_handle_control; dev->handle_data= usb_mouse_handle_data; s->kind= USB_MOUSE; diff -Nur qemu-last-snapshot/hw/usb.c qemu/hw/usb.c --- qemu-last-snapshot/hw/usb.c 2006-04-22 10:23:40.000000000 +0200 +++ qemu/hw/usb.c 2006-04-22 11:15:46.000000000 +0200 @@ -372,19 +372,27 @@ return 1; USBDevice *dev= (*tree)->dev; for (;tmp != NULL; tmp= tmp->next) { - if( tmp == *tree ) { + if (tmp == *tree) { + if (dev != NULL){ + if( dev->father != NULL && + dev->father->handle_attach + (dev->father, NULL, dev->father_port) < 0) { +#ifdef DEBUG + printf ("Could not dettach from father\n"); +#endif + return -1; + } + if (dev->handle_close(dev) < 0) { +#ifdef DEBUG + printf ("Could not close device\n"); +#endif + return -2; + } + } if( last != NULL ) { last->next= (*tree)->next; } - if( dev != NULL && dev->father != NULL && - !dev->father->handle_attach - (dev->father, NULL, dev->father_port)) { - return -1; - } else { - if( dev != NULL && !dev->handle_close(dev) ) - return -2; - } - free (*tree); + qemu_free (*tree); *tree= last; return 1; } @@ -441,8 +449,11 @@ if( tree->dev == NULL ) { usb_remove_device(&tree); return -1; + } else { + return 0; } } + return -1; } else if (strstr (tree->name, "host:") == tree->name) { /* we found a host device */ tree->dev= usb_host_init (tree->name); @@ -459,8 +470,10 @@ /* we found a guest usb tablet */ tree->dev = usb_tablet_init (); return add_usb_device (tree); - } - return 1; + } else { + usb_remove_device(&tree); + return -1; + } } /* this function connects or removes devices according to usb_tree */ @@ -555,10 +568,11 @@ dev->setup_index= 0; dev->handle_packet= &usb_dummy_handle_packet; dev->handle_reset= &usb_dummy_handle_reset; + dev->handle_close= &usb_dummy_handle_close; dev->handle_control= &usb_dummy_handle_control; dev->handle_msg= &usb_dummy_handle_msg; dev->handle_data= &usb_dummy_handle_data; - dev->handle_attach= &usb_dummy_handle_attach; + dev->handle_attach= &usb_dummy_handle_attach; } return dev; } diff -Nur qemu-last-snapshot/vl.c qemu/vl.c --- qemu-last-snapshot/vl.c 2006-04-22 10:23:40.000000000 +0200 +++ qemu/vl.c 2006-04-22 10:57:09.000000000 +0200 @@ -3274,6 +3274,7 @@ usb_tree= tmp; tmp->next= NULL; } + tmp->dev= NULL; memcpy (tmp->name, devname, nameend-devname); tmp->name[nameend-devname+1]= '\0'; memcpy (tmp->path, bus, 4); @@ -3334,6 +3335,7 @@ last->next= qemu_malloc (sizeof (USBTree)); tree= last->next; tree->next= NULL; + tree->dev= NULL; strcpy (tree->name, name); strcpy( tree->path, treepath ); tree->device_status= USB_ADD_DEVICE; --------------060100010501060807030908--