[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 12/13] usb-storage: Turn drive serial into a qdev pr
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 12/13] usb-storage: Turn drive serial into a qdev property usb-storage.serial |
Date: |
Fri, 24 Jun 2011 12:59:34 +0200 |
From: Markus Armbruster <address@hidden>
It needs to be a qdev property, because it belongs to the drive's
guest part. Precedence: commit a0fef654 and 6ced55a5.
Bonus: info qtree now shows the serial number.
Signed-off-by: Markus Armbruster <address@hidden>
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/usb-msd.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index a75948b..86582cc 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -51,6 +51,7 @@ typedef struct {
SCSIRequest *req;
SCSIBus bus;
BlockConf conf;
+ char *serial;
SCSIDevice *scsi_dev;
uint32_t removable;
int result;
@@ -532,9 +533,15 @@ static int usb_msd_initfn(USBDevice *dev)
bdrv_detach(bs, &s->dev.qdev);
s->conf.bs = NULL;
- dinfo = drive_get_by_blockdev(bs);
- if (dinfo && dinfo->serial) {
- usb_desc_set_string(dev, STR_SERIALNUMBER, dinfo->serial);
+ if (!s->serial) {
+ /* try to fall back to value set with legacy -drive serial=... */
+ dinfo = drive_get_by_blockdev(bs);
+ if (*dinfo->serial) {
+ s->serial = strdup(dinfo->serial);
+ }
+ }
+ if (s->serial) {
+ usb_desc_set_string(dev, STR_SERIALNUMBER, s->serial);
}
usb_desc_init(dev);
@@ -633,6 +640,7 @@ static struct USBDeviceInfo msd_info = {
.usbdevice_init = usb_msd_init,
.qdev.props = (Property[]) {
DEFINE_BLOCK_PROPERTIES(MSDState, conf),
+ DEFINE_PROP_STRING("serial", MSDState, serial),
DEFINE_PROP_BIT("removable", MSDState, removable, 0, false),
DEFINE_PROP_END_OF_LIST(),
},
--
1.7.1
- [Qemu-devel] [PATCH 04/13] ehci: add freq + maxframes properties, (continued)
- [Qemu-devel] [PATCH 04/13] ehci: add freq + maxframes properties, Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 02/13] usb-linux: make iso urb count contigurable, Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 01/13] usb-linux: add get_endp(), Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 06/13] usb-bus: Don't allow attaching a device to a bus with no free ports, Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 05/13] ehci: switch to nanoseconds, Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 09/13] usb-linux: allow "compatible" high speed devices to connect at fullspeed, Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 08/13] usb: Add a speedmask to devices, Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 13/13] usb: ignore USB_DT_DEBUG, Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 11/13] hw/usb-ohci.c: Fix handling of remote wakeup corner cases, Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 07/13] usb: Proper error propagation for usb_device_attach errors, Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 12/13] usb-storage: Turn drive serial into a qdev property usb-storage.serial,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 10/13] usb-bus: Don't allow speed mismatch while attaching devices, Gerd Hoffmann, 2011/06/24
- Re: [Qemu-devel] [PULL] usb patch queue, Hans de Goede, 2011/06/24
- Re: [Qemu-devel] [PULL] usb patch queue, Anthony Liguori, 2011/06/27