summaryrefslogtreecommitdiffstats
path: root/hw/scsi-disk.c
diff options
context:
space:
mode:
authorMarkus Armbruster2012-07-11 15:08:39 +0200
committerKevin Wolf2012-07-17 16:48:32 +0200
commitb7eb0c9f95e50239ce5b5266373dc52c85e75299 (patch)
treeb82a0d11cbb8466b37c3684f2c873b78c52eef4b /hw/scsi-disk.c
parentblockdev: Don't limit DriveInfo serial to 20 characters (diff)
downloadqemu-b7eb0c9f95e50239ce5b5266373dc52c85e75299.tar.gz
qemu-b7eb0c9f95e50239ce5b5266373dc52c85e75299.tar.xz
qemu-b7eb0c9f95e50239ce5b5266373dc52c85e75299.zip
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/scsi-disk.c')
-rw-r--r--hw/scsi-disk.c31
1 files changed, 3 insertions, 28 deletions
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 39a07d7579..525816cb76 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());