diff options
author | Markus Armbruster <armbru@redhat.com> | 2012-07-11 15:08:39 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2012-07-17 16:48:32 +0200 |
commit | b7eb0c9f95e50239ce5b5266373dc52c85e75299 (patch) | |
tree | b82a0d11cbb8466b37c3684f2c873b78c52eef4b /hw/virtio-blk.c | |
parent | 577d0a38070d1d6c4c7fab5c2054380770b1ec6b (diff) |
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/virtio-blk.c')
-rw-r--r-- | hw/virtio-blk.c | 31 |
1 files changed, 3 insertions, 28 deletions
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index ba087bc17f..f21757ed55 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -589,7 +589,6 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, VirtIOBlkConf *blk) { VirtIOBlock *s; static int virtio_blk_id; - DriveInfo *dinfo; if (!blk->conf.bs) { error_report("drive property not set"); @@ -601,6 +600,9 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, VirtIOBlkConf *blk) } blkconf_serial(&blk->conf, &blk->serial); + if (blkconf_geometry(&blk->conf, NULL, 65535, 255, 255) < 0) { + return NULL; + } s = (VirtIOBlock *)virtio_common_init("virtio-blk", VIRTIO_ID_BLOCK, sizeof(struct virtio_blk_config), @@ -615,33 +617,6 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, VirtIOBlkConf *blk) s->rq = NULL; s->sector_mask = (s->conf->logical_block_size / BDRV_SECTOR_SIZE) - 1; - if (!blk->conf.cyls && !blk->conf.heads && !blk->conf.secs) { - /* try to fall back to value set with legacy -drive cyls=... */ - dinfo = drive_get_by_blockdev(blk->conf.bs); - blk->conf.cyls = dinfo->cyls; - blk->conf.heads = dinfo->heads; - blk->conf.secs = dinfo->secs; - } - if (!blk->conf.cyls && !blk->conf.heads && !blk->conf.secs) { - hd_geometry_guess(s->bs, - &blk->conf.cyls, &blk->conf.heads, &blk->conf.secs, - NULL); - } - if (blk->conf.cyls || blk->conf.heads || blk->conf.secs) { - if (blk->conf.cyls < 1 || blk->conf.cyls > 65535) { - error_report("cyls must be between 1 and 65535"); - return NULL; - } - if (blk->conf.heads < 1 || blk->conf.heads > 255) { - error_report("heads must be between 1 and 255"); - return NULL; - } - if (blk->conf.secs < 1 || blk->conf.secs > 255) { - error_report("secs must be between 1 and 255"); - return NULL; - } - } - s->vq = virtio_add_queue(&s->vdev, 128, virtio_blk_handle_output); qemu_add_vm_change_state_handler(virtio_blk_dma_restart_cb, s); |