aboutsummaryrefslogtreecommitdiff
path: root/hw/ide/qdev.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2010-06-01 20:32:32 +0200
committerKevin Wolf <kwolf@redhat.com>2010-06-04 11:43:39 +0200
commit6ced55a57d7f6e647d683b5c41df0c176594f824 (patch)
tree01eb5a4c7fcba7e64be32565b90942e176430d57 /hw/ide/qdev.c
parentd21357df9a2a6b7e6bb2f579d04877f3bd65c557 (diff)
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>
Diffstat (limited to 'hw/ide/qdev.c')
-rw-r--r--hw/ide/qdev.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 9ebb906cc3..5e549d9d2f 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -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(),
}
};