ide: Turn drive serial into a qdev property ide-drive.serial

It needs to be a qdev property, because it belongs to the drive's
guest part.

Bonus: info qtree now shows the serial number.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Markus Armbruster 2010-06-01 20:32:32 +02:00 committed by Kevin Wolf
parent d21357df9a
commit 6ced55a57d
3 changed files with 24 additions and 7 deletions

View file

@ -99,7 +99,20 @@ typedef struct IDEDrive {
static int ide_drive_initfn(IDEDevice *dev)
{
IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus);
ide_init_drive(bus->ifs + dev->unit, dev->conf.dinfo, dev->version);
IDEState *s = bus->ifs + dev->unit;
const char *serial;
serial = dev->serial;
if (!serial) {
/* try to fall back to value set with legacy -drive serial=... */
serial = dev->conf.dinfo->serial;
}
ide_init_drive(s, dev->conf.dinfo, dev->version, serial);
if (!dev->serial) {
dev->serial = qemu_strdup(s->drive_serial_str);
}
return 0;
}
@ -111,6 +124,7 @@ static IDEDeviceInfo ide_drive_info = {
DEFINE_PROP_UINT32("unit", IDEDrive, dev.unit, -1),
DEFINE_BLOCK_PROPERTIES(IDEDrive, dev.conf),
DEFINE_PROP_STRING("ver", IDEDrive, dev.version),
DEFINE_PROP_STRING("serial", IDEDrive, dev.serial),
DEFINE_PROP_END_OF_LIST(),
}
};