diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2010-11-26 12:26:17 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2011-01-11 15:56:00 +0100 |
commit | 4a1e1bc416e99254dcc59a689b3806775ae8dabd (patch) | |
tree | 2f1adc4608457683dd9f8c668a64e4623c5e8250 /hw/usb-msd.c | |
parent | 132a3f55f05dff4eedde0d23d844ecdedef8ba68 (diff) |
usb storage: serial number support
If a serial number is present for the drive fill it into the usb
serialnumber string descriptor.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/usb-msd.c')
-rw-r--r-- | hw/usb-msd.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 20ab886747..9aa8888bae 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -482,6 +482,7 @@ static int usb_msd_initfn(USBDevice *dev) { MSDState *s = DO_UPCAST(MSDState, dev, dev); BlockDriverState *bs = s->conf.bs; + DriveInfo *dinfo; if (!bs) { error_report("usb-msd: drive property not set"); @@ -500,6 +501,11 @@ 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); + } + s->dev.speed = USB_SPEED_FULL; scsi_bus_new(&s->bus, &s->dev.qdev, 0, 1, usb_msd_command_complete); s->scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0); |