aboutsummaryrefslogtreecommitdiff
path: root/hw/scsi
diff options
context:
space:
mode:
authorRoman Kagan <rvkagan@yandex-team.ru>2020-05-29 01:55:10 +0300
committerKevin Wolf <kwolf@redhat.com>2020-06-17 14:53:40 +0200
commitc56ee92fcba8cc922b1b2188ac20614d20223db2 (patch)
tree5790ad5e71f651f85db76f612e39d2270b6510c3 /hw/scsi
parent6abee2608563599f783bf1305a8322ee7b447815 (diff)
block: consolidate blocksize properties consistency checks
Several block device properties related to blocksize configuration must be in certain relationship WRT each other: physical block must be no smaller than logical block; min_io_size, opt_io_size, and discard_granularity must be a multiple of a logical block. To ensure these requirements are met, add corresponding consistency checks to blkconf_blocksizes, adjusting its signature to communicate possible error to the caller. Also remove the now redundant consistency checks from the specific devices. Signed-off-by: Roman Kagan <rvkagan@yandex-team.ru> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Paul Durrant <paul@xen.org> Message-Id: <20200528225516.1676602-3-rvkagan@yandex-team.ru> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/scsi')
-rw-r--r--hw/scsi/scsi-disk.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 387503e11b..8ce68a9dd6 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2346,12 +2346,7 @@ static void scsi_realize(SCSIDevice *dev, Error **errp)
return;
}
- blkconf_blocksizes(&s->qdev.conf);
-
- if (s->qdev.conf.logical_block_size >
- s->qdev.conf.physical_block_size) {
- error_setg(errp,
- "logical_block_size > physical_block_size not supported");
+ if (!blkconf_blocksizes(&s->qdev.conf, errp)) {
return;
}
@@ -2436,7 +2431,9 @@ static void scsi_hd_realize(SCSIDevice *dev, Error **errp)
if (s->qdev.conf.blk) {
ctx = blk_get_aio_context(s->qdev.conf.blk);
aio_context_acquire(ctx);
- blkconf_blocksizes(&s->qdev.conf);
+ if (!blkconf_blocksizes(&s->qdev.conf, errp)) {
+ goto out;
+ }
}
s->qdev.blocksize = s->qdev.conf.logical_block_size;
s->qdev.type = TYPE_DISK;
@@ -2444,6 +2441,7 @@ static void scsi_hd_realize(SCSIDevice *dev, Error **errp)
s->product = g_strdup("QEMU HARDDISK");
}
scsi_realize(&s->qdev, errp);
+out:
if (ctx) {
aio_context_release(ctx);
}