mirror of https://github.com/xemu-project/xemu.git
usb-storage: Turn drive serial into a qdev property usb-storage.serial
It needs to be a qdev property, because it belongs to the drive's guest part. Precedence: commita0fef654
and6ced55a5
. Bonus: info qtree now shows the serial number. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
f3dc0051dc
commit
c3a90cb120
12
hw/usb-msd.c
12
hw/usb-msd.c
|
@ -51,6 +51,7 @@ typedef struct {
|
||||||
SCSIRequest *req;
|
SCSIRequest *req;
|
||||||
SCSIBus bus;
|
SCSIBus bus;
|
||||||
BlockConf conf;
|
BlockConf conf;
|
||||||
|
char *serial;
|
||||||
SCSIDevice *scsi_dev;
|
SCSIDevice *scsi_dev;
|
||||||
uint32_t removable;
|
uint32_t removable;
|
||||||
int result;
|
int result;
|
||||||
|
@ -532,9 +533,15 @@ static int usb_msd_initfn(USBDevice *dev)
|
||||||
bdrv_detach(bs, &s->dev.qdev);
|
bdrv_detach(bs, &s->dev.qdev);
|
||||||
s->conf.bs = NULL;
|
s->conf.bs = NULL;
|
||||||
|
|
||||||
|
if (!s->serial) {
|
||||||
|
/* try to fall back to value set with legacy -drive serial=... */
|
||||||
dinfo = drive_get_by_blockdev(bs);
|
dinfo = drive_get_by_blockdev(bs);
|
||||||
if (dinfo && dinfo->serial) {
|
if (*dinfo->serial) {
|
||||||
usb_desc_set_string(dev, STR_SERIALNUMBER, dinfo->serial);
|
s->serial = strdup(dinfo->serial);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (s->serial) {
|
||||||
|
usb_desc_set_string(dev, STR_SERIALNUMBER, s->serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
usb_desc_init(dev);
|
usb_desc_init(dev);
|
||||||
|
@ -633,6 +640,7 @@ static struct USBDeviceInfo msd_info = {
|
||||||
.usbdevice_init = usb_msd_init,
|
.usbdevice_init = usb_msd_init,
|
||||||
.qdev.props = (Property[]) {
|
.qdev.props = (Property[]) {
|
||||||
DEFINE_BLOCK_PROPERTIES(MSDState, conf),
|
DEFINE_BLOCK_PROPERTIES(MSDState, conf),
|
||||||
|
DEFINE_PROP_STRING("serial", MSDState, serial),
|
||||||
DEFINE_PROP_BIT("removable", MSDState, removable, 0, false),
|
DEFINE_PROP_BIT("removable", MSDState, removable, 0, false),
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue