提交 61e094c0 编写于 作者: G Gerd Hoffmann 提交者: Anthony Liguori

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: NGerd Hoffmann <kraxel@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 2b0efdc3
......@@ -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;
}
......
......@@ -133,6 +133,7 @@ struct USBDevice {
int speed;
uint8_t addr;
char devname[32];
int auto_attach;
int attached;
int state;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册