From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:35120) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QzQUY-0000U8-Ib for qemu-devel@nongnu.org; Fri, 02 Sep 2011 05:56:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QzQUW-00029Z-7h for qemu-devel@nongnu.org; Fri, 02 Sep 2011 05:56:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28078) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QzQUV-00029K-Ve for qemu-devel@nongnu.org; Fri, 02 Sep 2011 05:56:52 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p829upJd010359 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 2 Sep 2011 05:56:51 -0400 From: Gerd Hoffmann Date: Fri, 2 Sep 2011 11:56:33 +0200 Message-Id: <1314957407-29508-5-git-send-email-kraxel@redhat.com> In-Reply-To: <1314957407-29508-1-git-send-email-kraxel@redhat.com> References: <1314957407-29508-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 04/18] usb-host: limit open retries List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Limit the number of times qemu tries to open host devices to three. Reset error counter when the device goes away, after un-plugging and re-plugging the device qemu will try again three times. Signed-off-by: Gerd Hoffmann --- usb-linux.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/usb-linux.c b/usb-linux.c index 344af22..36d25d7 100644 --- a/usb-linux.c +++ b/usb-linux.c @@ -132,6 +132,7 @@ typedef struct USBHostDevice { int addr; char port[MAX_PORTLEN]; struct USBAutoFilter match; + int seen, errcount; QTAILQ_ENTRY(USBHostDevice) next; } USBHostDevice; @@ -1769,6 +1770,10 @@ static int usb_host_auto_scan(void *opaque, int bus_num, int addr, char *port, continue; } /* We got a match */ + s->seen++; + if (s->errcount >= 3) { + return 0; + } /* Already attached ? */ if (s->fd != -1) { @@ -1776,7 +1781,9 @@ static int usb_host_auto_scan(void *opaque, int bus_num, int addr, char *port, } DPRINTF("husb: auto open: bus_num %d addr %d\n", bus_num, addr); - usb_host_open(s, bus_num, addr, port, product_name, speed); + if (usb_host_open(s, bus_num, addr, port, product_name, speed) < 0) { + s->errcount++; + } break; } @@ -1794,6 +1801,10 @@ static void usb_host_auto_check(void *unused) if (s->fd == -1) { unconnected++; } + if (s->seen == 0) { + s->errcount = 0; + } + s->seen = 0; } if (unconnected == 0) { -- 1.7.1