diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2011-08-24 13:45:06 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2011-09-07 09:50:49 +0200 |
commit | 3ee886c5ba77a65d6b2c2a372a091d6796ed502b (patch) | |
tree | c9d336371596b17e902aeb69bb8f5059a39f059c /usb-linux.c | |
parent | 9b87e19bc7adea69bd55ae9c64b8a7fb81214726 (diff) | |
download | qemu-3ee886c5ba77a65d6b2c2a372a091d6796ed502b.tar.gz qemu-3ee886c5ba77a65d6b2c2a372a091d6796ed502b.tar.bz2 qemu-3ee886c5ba77a65d6b2c2a372a091d6796ed502b.zip |
usb-host: limit open retries
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 <kraxel@redhat.com>
Diffstat (limited to 'usb-linux.c')
-rw-r--r-- | usb-linux.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/usb-linux.c b/usb-linux.c index 344af22405..36d25d7328 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) { |