From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ShLXW-0005dh-Pn for qemu-devel@nongnu.org; Wed, 20 Jun 2012 10:05:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ShLXO-0000mc-KY for qemu-devel@nongnu.org; Wed, 20 Jun 2012 10:05:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54740) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ShLXO-0000lU-Cy for qemu-devel@nongnu.org; Wed, 20 Jun 2012 10:05:38 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q5KE5aal031783 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 20 Jun 2012 10:05:36 -0400 From: Gerd Hoffmann Date: Wed, 20 Jun 2012 16:05:32 +0200 Message-Id: <1340201134-21109-5-git-send-email-kraxel@redhat.com> In-Reply-To: <1340201134-21109-1-git-send-email-kraxel@redhat.com> References: <1340201134-21109-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 4/6] usb-host: attach only to running guest List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Signed-off-by: Gerd Hoffmann --- hw/usb/host-linux.c | 32 +++++++++++++++++--------------- 1 files changed, 17 insertions(+), 15 deletions(-) diff --git a/hw/usb/host-linux.c b/hw/usb/host-linux.c index a95b0ed..06b6ed3 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) { -- 1.7.1