summary refs log tree commit diff stats
path: root/hw/usb/host-linux.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2012-06-08 13:02:52 +0200
committerGerd Hoffmann <kraxel@redhat.com>2012-06-20 14:46:02 +0200
commita844ed842d9a9d929645c09ae0f52f753d7a02e0 (patch)
tree732055ce749dd405e6f70b920e875a35d290349a /hw/usb/host-linux.c
parent30e9d4120faa7b0e9318aa41529a936aa1cdb334 (diff)
downloadfocaccia-qemu-a844ed842d9a9d929645c09ae0f52f753d7a02e0.tar.gz
focaccia-qemu-a844ed842d9a9d929645c09ae0f52f753d7a02e0.zip
usb-host: attach only to running guest
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/usb/host-linux.c')
-rw-r--r--hw/usb/host-linux.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/hw/usb/host-linux.c b/hw/usb/host-linux.c
index a95b0eda55..06b6ed3380 100644
--- a/hw/usb/host-linux.c
+++ b/hw/usb/host-linux.c
@@ -1737,25 +1737,27 @@ static void usb_host_auto_check(void *unused)
     struct USBHostDevice *s;
     int unconnected = 0;
 
-    usb_host_scan(NULL, usb_host_auto_scan);
+    if (runstate_is_running()) {
+        usb_host_scan(NULL, usb_host_auto_scan);
 
-    QTAILQ_FOREACH(s, &hostdevs, next) {
-        if (s->fd == -1) {
-            unconnected++;
-        }
-        if (s->seen == 0) {
-            s->errcount = 0;
+        QTAILQ_FOREACH(s, &hostdevs, next) {
+            if (s->fd == -1) {
+                unconnected++;
+            }
+            if (s->seen == 0) {
+                s->errcount = 0;
+            }
+            s->seen = 0;
         }
-        s->seen = 0;
-    }
 
-    if (unconnected == 0) {
-        /* nothing to watch */
-        if (usb_auto_timer) {
-            qemu_del_timer(usb_auto_timer);
-            trace_usb_host_auto_scan_disabled();
+        if (unconnected == 0) {
+            /* nothing to watch */
+            if (usb_auto_timer) {
+                qemu_del_timer(usb_auto_timer);
+                trace_usb_host_auto_scan_disabled();
+            }
+            return;
         }
-        return;
     }
 
     if (!usb_auto_timer) {