summaryrefslogtreecommitdiffstats
path: root/hw/scsi-disk.c
diff options
context:
space:
mode:
authorChristoph Hellwig2010-03-04 14:20:17 +0100
committerAnthony Liguori2010-03-17 16:42:27 +0100
commit8cfacf079047c50d272ce64e45a78d816db8b36e (patch)
tree4ef370b2b6c6946af66e9bcdfa013a1e93b5079c /hw/scsi-disk.c
parentAvoid crash on '-usbdevice <device>' without parameters (diff)
downloadqemu-8cfacf079047c50d272ce64e45a78d816db8b36e.tar.gz
qemu-8cfacf079047c50d272ce64e45a78d816db8b36e.tar.xz
qemu-8cfacf079047c50d272ce64e45a78d816db8b36e.zip
block: add logical_block_size property
Add a logical block size attribute as various guest side tools only increase the filesystem sector size based on it, not the advisory physical block size. For scsi we already have support for a different logical block size in place for CDROMs that we can built upon. Only my recent block device characteristics VPD page needs some fixups. Note that we leave the logial block size for CDROMs hardcoded as the 2k value is expected for it in general. For virtio-blk we already have a feature flag claiming to support a variable logical block size that was added for the s390 kuli hypervisor. Interestingly it does not actually change the units in which the protocol works, which is still fixed at 512 bytes, but only communicates a different minimum I/O granularity. So all we need to do in virtio is to add a trap for unaligned I/O and round down the device size to the next multiple of the logical block size. IDE does not support any other logical block size than 512 bytes. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/scsi-disk.c')
-rw-r--r--hw/scsi-disk.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index da56d2bc1c..e64fbf11dd 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -396,8 +396,10 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf)
}
case 0xb0: /* block device characteristics */
{
- unsigned int min_io_size = s->qdev.conf.min_io_size >> 9;
- unsigned int opt_io_size = s->qdev.conf.opt_io_size >> 9;
+ unsigned int min_io_size =
+ s->qdev.conf.min_io_size / s->qdev.blocksize;
+ unsigned int opt_io_size =
+ s->qdev.conf.opt_io_size / s->qdev.blocksize;
/* required VPD size with unmap support */
outbuf[3] = buflen = 0x3c;
@@ -1036,11 +1038,12 @@ static int scsi_disk_initfn(SCSIDevice *dev)
}
if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM) {
- s->cluster_size = 4;
+ s->qdev.blocksize = 2048;
} else {
- s->cluster_size = 1;
+ s->qdev.blocksize = s->qdev.conf.logical_block_size;
}
- s->qdev.blocksize = 512 * s->cluster_size;
+ s->cluster_size = s->qdev.blocksize / 512;
+
s->qdev.type = TYPE_DISK;
bdrv_get_geometry(s->bs, &nb_sectors);
nb_sectors /= s->cluster_size;