From b7eb0c9f95e50239ce5b5266373dc52c85e75299 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 11 Jul 2012 15:08:39 +0200 Subject: hw/block-common: Factor out fall back to legacy -drive cyls=... Signed-off-by: Markus Armbruster Signed-off-by: Kevin Wolf --- hw/scsi-disk.c | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) (limited to 'hw/scsi-disk.c') diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 39a07d7..525816c 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -1737,7 +1737,6 @@ static void scsi_disk_unit_attention_reported(SCSIDevice *dev) static int scsi_initfn(SCSIDevice *dev) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev); - DriveInfo *dinfo; if (!s->qdev.conf.bs) { error_report("drive property not set"); @@ -1750,34 +1749,10 @@ static int scsi_initfn(SCSIDevice *dev) return -1; } - 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(s->qdev.conf.bs); - dev->conf.cyls = dinfo->cyls; - dev->conf.heads = dinfo->heads; - dev->conf.secs = dinfo->secs; - } - if (!dev->conf.cyls && !dev->conf.heads && !dev->conf.secs) { - hd_geometry_guess(s->qdev.conf.bs, - &dev->conf.cyls, &dev->conf.heads, &dev->conf.secs, - NULL); - } - if (dev->conf.cyls || dev->conf.heads || dev->conf.secs) { - if (dev->conf.cyls < 1 || dev->conf.cyls > 65535) { - error_report("cyls must be between 1 and 65535"); - return -1; - } - if (dev->conf.heads < 1 || dev->conf.heads > 255) { - error_report("heads must be between 1 and 255"); - return -1; - } - if (dev->conf.secs < 1 || dev->conf.secs > 255) { - error_report("secs must be between 1 and 255"); - return -1; - } - } - blkconf_serial(&s->qdev.conf, &s->serial); + if (blkconf_geometry(&dev->conf, NULL, 65535, 255, 255) < 0) { + return -1; + } if (!s->version) { s->version = g_strdup(qemu_get_version()); -- cgit v1.1