qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: nix.wie.weg@gmx.de
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Large USB patch
Date: Sat, 22 Apr 2006 11:33:20 +0200	[thread overview]
Message-ID: <4449F860.1060809@gmx.de> (raw)
In-Reply-To: <44494596.3070808@austin.rr.com>

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

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.

[-- Attachment #2: lusb-upd2.diff --]
[-- Type: text/plain, Size: 4297 bytes --]

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;

  reply	other threads:[~2006-04-22  9:33 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-20 19:59 [Qemu-devel] Large USB patch nix.wie.weg
2006-04-21  2:23 ` Lonnie Mendez
2006-04-21  5:59   ` nix.wie.weg
2006-04-21  7:04     ` Lonnie Mendez
2006-04-21 14:53 ` Lonnie Mendez
2006-04-21 15:00   ` Lonnie Mendez
2006-04-21 15:50   ` Lonnie Mendez
2006-04-21 16:19     ` Lonnie Mendez
2006-04-21 16:29       ` nix.wie.weg
2006-04-21 17:28         ` Lonnie Mendez
2006-04-21 18:06           ` Lonnie Mendez
2006-04-21 18:38             ` Lonnie Mendez
2006-04-21 20:50               ` Lonnie Mendez
2006-04-22  9:33                 ` nix.wie.weg [this message]
2006-04-22 14:36                   ` Lonnie Mendez
2006-04-22 15:36                     ` nix.wie.weg
2006-04-22 15:38                       ` nix.wie.weg
2006-04-22 16:00                     ` nix.wie.weg
2006-04-22 16:19                       ` Lonnie Mendez
2006-04-22 16:35                         ` nix.wie.weg
2006-04-23  3:38                           ` Lonnie Mendez
2006-04-23 21:54                             ` nix.wie.weg
2006-04-29  1:03                             ` Lonnie Mendez
2006-04-29  3:29                               ` Lonnie Mendez
2006-04-30  0:46                                 ` Lonnie Mendez
2006-04-30 20:56                                   ` Lonnie Mendez
2006-04-21 16:26     ` nix.wie.weg
2006-04-22 14:15 ` nix.wie.weg
2006-04-23 15:02 ` Fabrice Bellard
2006-04-23 16:11   ` nix.wie.weg
2006-04-24 23:50 ` [Qemu-devel] Update for cvs 2006-04-24 nix.wie.weg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4449F860.1060809@gmx.de \
    --to=nix.wie.weg@gmx.de \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).