usb-host: attach only to running guest

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2012-06-08 13:02:52 +02:00
parent 30e9d4120f
commit a844ed842d

View File

@ -1737,25 +1737,27 @@ static void usb_host_auto_check(void *unused)
struct USBHostDevice *s; struct USBHostDevice *s;
int unconnected = 0; 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) { QTAILQ_FOREACH(s, &hostdevs, next) {
if (s->fd == -1) { if (s->fd == -1) {
unconnected++; unconnected++;
}
if (s->seen == 0) {
s->errcount = 0;
}
s->seen = 0;
} }
if (s->seen == 0) {
s->errcount = 0;
}
s->seen = 0;
}
if (unconnected == 0) { if (unconnected == 0) {
/* nothing to watch */ /* nothing to watch */
if (usb_auto_timer) { if (usb_auto_timer) {
qemu_del_timer(usb_auto_timer); qemu_del_timer(usb_auto_timer);
trace_usb_host_auto_scan_disabled(); trace_usb_host_auto_scan_disabled();
}
return;
} }
return;
} }
if (!usb_auto_timer) { if (!usb_auto_timer) {