From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZME0-0003Fw-Vv for qemu-devel@nongnu.org; Fri, 16 Nov 2012 08:44:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TZMDx-0001aN-Te for qemu-devel@nongnu.org; Fri, 16 Nov 2012 08:44:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52269) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZMDx-0001aC-K8 for qemu-devel@nongnu.org; Fri, 16 Nov 2012 08:44:49 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qAGDinP8020241 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 16 Nov 2012 08:44:49 -0500 From: Gerd Hoffmann Date: Fri, 16 Nov 2012 14:44:36 +0100 Message-Id: <1353073487-19233-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1353073487-19233-1-git-send-email-kraxel@redhat.com> References: <1353073487-19233-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 03/14] usb-host: scan for usb devices when the vm starts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Commit a844ed842d9a9d929645c09ae0f52f753d7a02e0 leads to usb-host detecting devices not right after qemu startup because the guest isn't running yet. Instead they are found on the first of the regular usb device poll runs. Which is too late for seabios to see them, so booting from usb sticks fails. Fix this by adding a vm state change handler which triggers a device scan when the vm is started. Signed-off-by: Gerd Hoffmann --- hw/usb/host-linux.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/hw/usb/host-linux.c b/hw/usb/host-linux.c index ca3e24a..5bc77b2 100644 --- a/hw/usb/host-linux.c +++ b/hw/usb/host-linux.c @@ -1738,6 +1738,7 @@ static int usb_host_scan(void *opaque, USBScanFunc *func) } static QEMUTimer *usb_auto_timer; +static VMChangeStateEntry *usb_vmstate; static int usb_host_auto_scan(void *opaque, int bus_num, int addr, const char *port, @@ -1792,6 +1793,13 @@ static int usb_host_auto_scan(void *opaque, int bus_num, return 0; } +static void usb_host_vm_state(void *unused, int running, RunState state) +{ + if (running) { + usb_host_auto_check(unused); + } +} + static void usb_host_auto_check(void *unused) { struct USBHostDevice *s; @@ -1820,6 +1828,9 @@ static void usb_host_auto_check(void *unused) } } + if (!usb_vmstate) { + usb_vmstate = qemu_add_vm_change_state_handler(usb_host_vm_state, NULL); + } if (!usb_auto_timer) { usb_auto_timer = qemu_new_timer_ms(rt_clock, usb_host_auto_check, NULL); if (!usb_auto_timer) { -- 1.7.1