summaryrefslogtreecommitdiff
path: root/hw/ide/qdev.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2012-07-11 15:08:39 +0200
committerKevin Wolf <kwolf@redhat.com>2012-07-17 16:48:32 +0200
commitb7eb0c9f95e50239ce5b5266373dc52c85e75299 (patch)
treeb82a0d11cbb8466b37c3684f2c873b78c52eef4b /hw/ide/qdev.c
parent577d0a38070d1d6c4c7fab5c2054380770b1ec6b (diff)
downloadqemu-b7eb0c9f95e50239ce5b5266373dc52c85e75299.tar.gz
hw/block-common: Factor out fall back to legacy -drive cyls=...
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.c19
1 files changed, 2 insertions, 17 deletions
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 7fe803c85f..22e58dfc8a 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -142,7 +142,6 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
{
IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus);
IDEState *s = bus->ifs + dev->unit;
- DriveInfo *dinfo;
if (dev->conf.discard_granularity && dev->conf.discard_granularity != 512) {
error_report("discard_granularity must be 512 for ide");
@@ -150,22 +149,8 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
}
blkconf_serial(&dev->conf, &dev->serial);
-
- if (!dev->conf.cyls && !dev->conf.heads && !dev->conf.secs) {
- /* try to fall back to value set with legacy -drive cyls=... */
- dinfo = drive_get_by_blockdev(dev->conf.bs);
- dev->conf.cyls = dinfo->cyls;
- dev->conf.heads = dinfo->heads;
- dev->conf.secs = dinfo->secs;
- dev->chs_trans = dinfo->trans;
- }
- if (!dev->conf.cyls && !dev->conf.heads && !dev->conf.secs) {
- hd_geometry_guess(dev->conf.bs,
- &dev->conf.cyls, &dev->conf.heads, &dev->conf.secs,
- &dev->chs_trans);
- } else if (dev->chs_trans == BIOS_ATA_TRANSLATION_AUTO) {
- dev->chs_trans = hd_bios_chs_auto_trans(dev->conf.cyls,
- dev->conf.heads, dev->conf.secs);
+ if (blkconf_geometry(&dev->conf, &dev->chs_trans, 65536, 16, 255) < 0) {
+ return -1;
}
if (ide_init_drive(s, dev->conf.bs, kind,