]> git.proxmox.com Git - qemu.git/commitdiff
usb: make attach optional.
authorGerd Hoffmann <kraxel@redhat.com>
Mon, 26 Oct 2009 14:56:48 +0000 (15:56 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 30 Oct 2009 13:39:31 +0000 (08:39 -0500)
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>
hw/usb-bus.c
hw/usb.h

index 28b517f5dad4adf04cc896a37833c569df8ab273..87dcc7f17542dc690a5d55de3fcd8bab76d6f97c 100644 (file)
@@ -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;
 }
index a875d5b4c60e77c3f7f0feb9a647bf0bdf25ee5e..a01f3348830fcb00cf1969d3bb1042c01d239503 100644 (file)
--- 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;