[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] Large USB patch
From: |
nix . wie . weg |
Subject: |
Re: [Qemu-devel] Large USB patch |
Date: |
Sat, 22 Apr 2006 11:33:20 +0200 |
User-agent: |
Mail/News 1.5 (X11/20060228) |
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.
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;
- Re: [Qemu-devel] Large USB patch, (continued)
- Re: [Qemu-devel] Large USB patch, Lonnie Mendez, 2006/04/21
- Re: [Qemu-devel] Large USB patch, Lonnie Mendez, 2006/04/21
- Re: [Qemu-devel] Large USB patch, Lonnie Mendez, 2006/04/21
- Re: [Qemu-devel] Large USB patch, Lonnie Mendez, 2006/04/21
- Re: [Qemu-devel] Large USB patch, nix . wie . weg, 2006/04/21
- Re: [Qemu-devel] Large USB patch, Lonnie Mendez, 2006/04/21
- Re: [Qemu-devel] Large USB patch, Lonnie Mendez, 2006/04/21
- Re: [Qemu-devel] Large USB patch, Lonnie Mendez, 2006/04/21
- Re: [Qemu-devel] Large USB patch, Lonnie Mendez, 2006/04/21
- Re: [Qemu-devel] Large USB patch,
nix . wie . weg <=
- Re: [Qemu-devel] Large USB patch, Lonnie Mendez, 2006/04/22
- Re: [Qemu-devel] Large USB patch, nix . wie . weg, 2006/04/22
- Re: [Qemu-devel] Large USB patch, nix . wie . weg, 2006/04/22
- Re: [Qemu-devel] Large USB patch, nix . wie . weg, 2006/04/22
- Re: [Qemu-devel] Large USB patch, Lonnie Mendez, 2006/04/22
- Re: [Qemu-devel] Large USB patch, nix . wie . weg, 2006/04/22
- Re: [Qemu-devel] Large USB patch, Lonnie Mendez, 2006/04/22
- Re: [Qemu-devel] Large USB patch, nix . wie . weg, 2006/04/23
- Re: [Qemu-devel] Large USB patch, Lonnie Mendez, 2006/04/28
- Re: [Qemu-devel] Large USB patch, Lonnie Mendez, 2006/04/28