[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 4/7] usb: make attach optional.
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 4/7] usb: make attach optional. |
Date: |
Mon, 26 Oct 2009 15:56:48 +0100 |
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 <address@hidden>
---
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
- [Qemu-devel] [PATCH v2 0/7] use qdev for -usbdevice, Gerd Hoffmann, 2009/10/26
- [Qemu-devel] [PATCH 4/7] usb: make attach optional.,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 1/7] usb core: use qdev for -usbdevice, Gerd Hoffmann, 2009/10/26
- [Qemu-devel] [PATCH 2/7] usb-hid: use qdev for -usbdevice, Gerd Hoffmann, 2009/10/26
- [Qemu-devel] [PATCH 7/7] usb: print attached status in info qtree, Gerd Hoffmann, 2009/10/26
- [Qemu-devel] [PATCH 3/7] usb-serial and braille: use qdev for -usbdevice, Gerd Hoffmann, 2009/10/26
- [Qemu-devel] [PATCH 5/7] usb-storage: use qdev for -usbdevice, Gerd Hoffmann, 2009/10/26
- [Qemu-devel] [PATCH 6/7] usb-host: use qdev for -usbdevice + rework., Gerd Hoffmann, 2009/10/26