[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 4/5] virtio-blk: Fix geometry sector calculation
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 4/5] virtio-blk: Fix geometry sector calculation |
Date: |
Wed, 30 May 2012 15:37:15 +0200 |
From: Christian Borntraeger <address@hidden>
Currently the sector value for the geometry is masked, even if the
user usesa command line parameter that explicitely gives a number.
This breaks dasd devices on s390. A dasd device can have
a physical block size of 4096 (== same for logical block size)
and a typcial geometry of 15 heads and 12 sectors per cyl.
The ibm partition detection relies on a correct geometry
reported by the device. Unfortunately the current code changes
12 to 8. This would be necessary if the total size is
not a multiple of logical sector size, but for dasd this
is not the case.
This patch checks the device size and only applies sector
mask if necessary.
Signed-off-by: Christian Borntraeger <address@hidden>
CC: Christoph Hellwig <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
hw/virtio-blk.c | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 60750cb..fe07746 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -491,7 +491,22 @@ static void virtio_blk_update_config(VirtIODevice *vdev,
uint8_t *config)
stw_raw(&blkcfg.min_io_size, s->conf->min_io_size / blk_size);
stw_raw(&blkcfg.opt_io_size, s->conf->opt_io_size / blk_size);
blkcfg.heads = heads;
- blkcfg.sectors = secs & ~s->sector_mask;
+ /*
+ * We must ensure that the block device capacity is a multiple of
+ * the logical block size. If that is not the case, lets use
+ * sector_mask to adopt the geometry to have a correct picture.
+ * For those devices where the capacity is ok for the given geometry
+ * we dont touch the sector value of the geometry, since some devices
+ * (like s390 dasd) need a specific value. Here the capacity is already
+ * cyls*heads*secs*blk_size and the sector value is not block size
+ * divided by 512 - instead it is the amount of blk_size blocks
+ * per track (cylinder).
+ */
+ if (bdrv_getlength(s->bs) / heads / secs % blk_size) {
+ blkcfg.sectors = secs & ~s->sector_mask;
+ } else {
+ blkcfg.sectors = secs;
+ }
blkcfg.size_max = 0;
blkcfg.physical_block_exp = get_physical_block_exp(s->conf);
blkcfg.alignment_offset = 0;
--
1.7.6.5
- [Qemu-devel] [PATCH 2/5] qcow2: Limit COW to where it's needed, (continued)
- [Qemu-devel] [PATCH 2/5] qcow2: Limit COW to where it's needed, Kevin Wolf, 2012/05/07
- [Qemu-devel] [PATCH 3/5] block: make bdrv_create adopt coroutine, Kevin Wolf, 2012/05/07
- [Qemu-devel] [PATCH 4/5] qcow2: lock on prealloc, Kevin Wolf, 2012/05/07
- [Qemu-devel] [PATCH 5/5] fdc: simplify media change handling, Kevin Wolf, 2012/05/07
- Re: [Qemu-devel] [PULL 0/5] Block patches for 1.1, Anthony Liguori, 2012/05/08
- [Qemu-devel] [PULL 0/5] Block patches for 1.1, Kevin Wolf, 2012/05/30
- [Qemu-devel] [PATCH 2/5] sheepdog: fix return value of do_load_save_vm_state, Kevin Wolf, 2012/05/30
- [Qemu-devel] [PATCH 3/5] block: prevent snapshot mode $TMPDIR symlink attack, Kevin Wolf, 2012/05/30
- [Qemu-devel] [PATCH 5/5] ahci: SATA FIS is 20 bytes, not 0x20, Kevin Wolf, 2012/05/30
- [Qemu-devel] [PATCH 1/5] virtio: Fix compiler warning for non Linux hosts, Kevin Wolf, 2012/05/30
- [Qemu-devel] [PATCH 4/5] virtio-blk: Fix geometry sector calculation,
Kevin Wolf <=
- Re: [Qemu-devel] [PULL 0/5] Block patches for 1.1, Anthony Liguori, 2012/05/30