diff options
author | Roman Kagan | 2020-05-29 00:55:14 +0200 |
---|---|---|
committer | Kevin Wolf | 2020-06-17 14:53:40 +0200 |
commit | 4f44bbc5bba0858d34b1aa356397847696276546 (patch) | |
tree | 7868dd3a14f9f99742f470263a61d1049d2b00e4 /hw/block/block.c | |
parent | qdev-properties: make blocksize accept size suffixes (diff) | |
download | qemu-4f44bbc5bba0858d34b1aa356397847696276546.tar.gz qemu-4f44bbc5bba0858d34b1aa356397847696276546.tar.xz qemu-4f44bbc5bba0858d34b1aa356397847696276546.zip |
block: make BlockConf size props 32bit and accept size suffixes
Convert all size-related properties in BlockConf to 32bit. This will
accommodate bigger block sizes (in a followup patch). This also allows
to make them all accept size suffixes, either via DEFINE_PROP_BLOCKSIZE
or via DEFINE_PROP_SIZE32.
Also, since min_io_size is exposed to the guest by scsi and virtio-blk
devices as an uint16_t in units of logical blocks, introduce an
additional check in blkconf_blocksizes to prevent its silent truncation.
Signed-off-by: Roman Kagan <rvkagan@yandex-team.ru>
Message-Id: <20200528225516.1676602-7-rvkagan@yandex-team.ru>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/block/block.c')
-rw-r--r-- | hw/block/block.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/hw/block/block.c b/hw/block/block.c index b22207c921..1e34573da7 100644 --- a/hw/block/block.c +++ b/hw/block/block.c @@ -96,6 +96,16 @@ bool blkconf_blocksizes(BlockConf *conf, Error **errp) return false; } + /* + * all devices which support min_io_size (scsi and virtio-blk) expose it to + * the guest as a uint16_t in units of logical blocks + */ + if (conf->min_io_size / conf->logical_block_size > UINT16_MAX) { + error_setg(errp, "min_io_size must not exceed %u logical blocks", + UINT16_MAX); + return false; + } + if (!QEMU_IS_ALIGNED(conf->opt_io_size, conf->logical_block_size)) { error_setg(errp, "opt_io_size must be a multiple of logical_block_size"); |