* [Qemu-devel] [PATCH] usb-storage: Turn drive serial into a qdev property usb-storage.serial
@ 2011-06-17 8:52 Markus Armbruster
2011-06-23 15:10 ` Gerd Hoffmann
0 siblings, 1 reply; 2+ messages in thread
From: Markus Armbruster @ 2011-06-17 8:52 UTC (permalink / raw)
To: qemu-devel; +Cc: kraxel
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 <armbru@redhat.com>
---
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 c59797b..9033843 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;
@@ -531,9 +532,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);
@@ -632,6 +639,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.2.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] usb-storage: Turn drive serial into a qdev property usb-storage.serial
2011-06-17 8:52 [Qemu-devel] [PATCH] usb-storage: Turn drive serial into a qdev property usb-storage.serial Markus Armbruster
@ 2011-06-23 15:10 ` Gerd Hoffmann
0 siblings, 0 replies; 2+ messages in thread
From: Gerd Hoffmann @ 2011-06-23 15:10 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel
On 06/17/11 10:52, Markus Armbruster wrote:
> 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.
Patch applied to usb queue.
thanks,
Gerd
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-06-23 15:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-17 8:52 [Qemu-devel] [PATCH] usb-storage: Turn drive serial into a qdev property usb-storage.serial Markus Armbruster
2011-06-23 15:10 ` Gerd Hoffmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).