From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N2R0K-000838-3Y for qemu-devel@nongnu.org; Mon, 26 Oct 2009 10:57:04 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N2R0F-00081e-6l for qemu-devel@nongnu.org; Mon, 26 Oct 2009 10:57:03 -0400 Received: from [199.232.76.173] (port=54442 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N2R0F-00081a-3Z for qemu-devel@nongnu.org; Mon, 26 Oct 2009 10:56:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64038) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N2R0D-0007ux-Ga for qemu-devel@nongnu.org; Mon, 26 Oct 2009 10:56:58 -0400 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.13.8/8.13.8) with ESMTP id n9QEuuJi002042 for ; Mon, 26 Oct 2009 10:56:56 -0400 From: Gerd Hoffmann Date: Mon, 26 Oct 2009 15:56:48 +0100 Message-Id: <1256569011-20256-5-git-send-email-kraxel@redhat.com> In-Reply-To: <1256569011-20256-1-git-send-email-kraxel@redhat.com> References: <1256569011-20256-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 4/7] usb: make attach optional. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Add a auto_attach field to USBDevice, which is enabled by default. USB drivers can clear this field in case they do *not* want the device being attached (i.e. plugged into a usb port) automatically after successfull init(). Use cases (see next patches): * attaching encrypted mass storage devices. * -usbdevice host:... Signed-off-by: Gerd Hoffmann --- hw/usb-bus.c | 3 ++- hw/usb.h | 1 + 2 files changed, 3 insertions(+), 1 deletions(-) diff --git a/hw/usb-bus.c b/hw/usb-bus.c index 28b517f..87dcc7f 100644 --- a/hw/usb-bus.c +++ b/hw/usb-bus.c @@ -45,8 +45,9 @@ static int usb_qdev_init(DeviceState *qdev, DeviceInfo *base) pstrcpy(dev->devname, sizeof(dev->devname), qdev->info->name); dev->info = info; + dev->auto_attach = 1; rc = dev->info->init(dev); - if (rc == 0) + if (rc == 0 && dev->auto_attach) usb_device_attach(dev); return rc; } diff --git a/hw/usb.h b/hw/usb.h index a875d5b..a01f334 100644 --- a/hw/usb.h +++ b/hw/usb.h @@ -133,6 +133,7 @@ struct USBDevice { int speed; uint8_t addr; char devname[32]; + int auto_attach; int attached; int state; -- 1.6.2.5