aboutsummaryrefslogtreecommitdiff
path: root/hw/usb-bus.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2009-10-26 15:56:48 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2009-10-30 08:39:31 -0500
commit61e094c049c1f58291e596910d300c7842cfd998 (patch)
tree309a8af6bcd9f0a704f51838dbb519c032aad824 /hw/usb-bus.c
parent2b0efdc3e116753e349bc3d1888a8520f57e8315 (diff)
usb: make attach optional.
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 <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/usb-bus.c')
-rw-r--r--hw/usb-bus.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index 28b517f5da..87dcc7f175 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;
}