From 71938a09d2b9fd4007515fec6c395916cb08f868 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 12 Jun 2013 13:01:49 +0200 Subject: usb: add serial bus property This patch adds a serial property for all usb devices, which can be used to set the serial number of a usb device (as listed by lsusb -v) to a specific value. Applies to emulated devices only. Signed-off-by: Gerd Hoffmann --- hw/usb/dev-storage.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'hw/usb/dev-storage.c') diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 1073901af1..fe914ab005 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -58,7 +58,6 @@ typedef struct { USBPacket *packet; /* usb-storage only */ BlockConf conf; - char *serial; uint32_t removable; } MSDState; @@ -602,7 +601,7 @@ static int usb_msd_initfn_storage(USBDevice *dev) return -1; } - blkconf_serial(&s->conf, &s->serial); + blkconf_serial(&s->conf, &dev->serial); /* * Hack alert: this pretends to be a block device, but it's really @@ -616,16 +615,11 @@ static int usb_msd_initfn_storage(USBDevice *dev) bdrv_detach_dev(bs, &s->dev.qdev); s->conf.bs = NULL; - if (s->serial) { - usb_desc_set_string(dev, STR_SERIALNUMBER, s->serial); - } else { - usb_desc_create_serial(dev); - } - + usb_desc_create_serial(dev); usb_desc_init(dev); scsi_bus_new(&s->bus, &s->dev.qdev, &usb_msd_scsi_info_storage, NULL); scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0, !!s->removable, - s->conf.bootindex, s->serial); + s->conf.bootindex, dev->serial); if (!scsi_dev) { return -1; } @@ -734,7 +728,6 @@ static const VMStateDescription vmstate_usb_msd = { static Property msd_properties[] = { DEFINE_BLOCK_PROPERTIES(MSDState, conf), - DEFINE_PROP_STRING("serial", MSDState, serial), DEFINE_PROP_BIT("removable", MSDState, removable, 0, false), DEFINE_PROP_END_OF_LIST(), }; -- cgit v1.2.1