From patchwork Wed Nov 14 15:00:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 198932 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AA64C2C0090 for ; Thu, 15 Nov 2012 02:12:34 +1100 (EST) Received: from localhost ([::1]:49378 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYedj-0004zZ-7k for incoming@patchwork.ozlabs.org; Wed, 14 Nov 2012 10:12:31 -0500 Received: from eggs.gnu.org ([208.118.235.92]:33519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYedX-0004zE-A4 for qemu-devel@nongnu.org; Wed, 14 Nov 2012 10:12:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TYedU-0002x0-7p for qemu-devel@nongnu.org; Wed, 14 Nov 2012 10:12:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:7407) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYedU-0002wq-0A for qemu-devel@nongnu.org; Wed, 14 Nov 2012 10:12:16 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qAEFCEVv029278 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 14 Nov 2012 10:12:15 -0500 Received: from rincewind.home.kraxel.org (ovpn-116-71.ams2.redhat.com [10.36.116.71]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qAEF0E86024086; Wed, 14 Nov 2012 10:00:34 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 3187246065; Wed, 14 Nov 2012 16:00:14 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 14 Nov 2012 16:00:13 +0100 Message-Id: <1352905213-28969-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH] usb-host: scan for usb devices when the vm starts X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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) {