diff options
author | Markus Armbruster <armbru@redhat.com> | 2010-06-01 20:32:32 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2010-06-04 11:43:39 +0200 |
commit | 6ced55a57d7f6e647d683b5c41df0c176594f824 (patch) | |
tree | 01eb5a4c7fcba7e64be32565b90942e176430d57 /hw/ide/core.c | |
parent | d21357df9a2a6b7e6bb2f579d04877f3bd65c557 (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/core.c')
-rw-r--r-- | hw/ide/core.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/hw/ide/core.c b/hw/ide/core.c index d3328cd02f..70af1b6043 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -2596,7 +2596,8 @@ void ide_bus_reset(IDEBus *bus) ide_clear_hob(bus); } -void ide_init_drive(IDEState *s, DriveInfo *dinfo, const char *version) +void ide_init_drive(IDEState *s, DriveInfo *dinfo, + const char *version, const char *serial) { int cylinders, heads, secs; uint64_t nb_sectors; @@ -2618,9 +2619,9 @@ void ide_init_drive(IDEState *s, DriveInfo *dinfo, const char *version) s->is_cdrom = 1; bdrv_set_change_cb(s->bs, cdrom_change_cb, s); } - strncpy(s->drive_serial_str, drive_get_serial(s->bs), - sizeof(s->drive_serial_str)); - if (!*s->drive_serial_str) { + if (serial && *serial) { + strncpy(s->drive_serial_str, serial, sizeof(s->drive_serial_str)); + } else { snprintf(s->drive_serial_str, sizeof(s->drive_serial_str), "QM%05d", s->drive_serial); } @@ -2669,7 +2670,7 @@ void ide_init2_with_non_qdev_drives(IDEBus *bus, DriveInfo *hd0, dinfo = i == 0 ? hd0 : hd1; ide_init1(bus, i); if (dinfo) { - ide_init_drive(&bus->ifs[i], dinfo, NULL); + ide_init_drive(&bus->ifs[i], dinfo, NULL, dinfo->serial); } else { ide_reset(&bus->ifs[i]); } |