@@ -316,14 +316,16 @@ static BlockMeasureInfo *raw_measure(QemuOpts *opts, BlockDriverState *in_bs,
Error **errp)
{
BlockMeasureInfo *info;
- int64_t required;
+ int64_t size;
+ uint64_t required;
if (in_bs) {
- required = bdrv_getlength(in_bs);
- if (required < 0) {
- error_setg_errno(errp, -required, "Unable to get image size");
+ size = bdrv_getlength(in_bs);
+ if (size < 0) {
+ error_setg_errno(errp, -size, "Unable to get image size");
return NULL;
}
+ required = size;
} else {
required = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
BDRV_SECTOR_SIZE);
@@ -485,7 +485,7 @@
# Since: 2.10
##
{ 'struct': 'BlockMeasureInfo',
- 'data': {'required': 'int', 'fully-allocated': 'int'} }
+ 'data': {'required': 'size', 'fully-allocated': 'size'} }
##
# @query-block:
Sizes should use QAPI type 'size' (uint64_t). BlockMeasureInfo members @required and @fully-allocated are 'int' (int64_t). qcow2_measure() computes their values from qcow2_calc_prealloc_size(), @virtual_size and @required, all uint64_t (the former only since the previous commit). raw_measure() computes them either from bdrv_getlength() or from qemu_opt_get_size_del(). The former is int64_t, but we error out if it's negative. The latter is uint64_t. Change these BlockMeasureInfo members to 'size'. qemu-img now reports them correctly above 2^63-1 instead of their (negative) two's complement. Signed-off-by: Markus Armbruster <armbru@redhat.com> --- block/raw-format.c | 10 ++++++---- qapi/block-core.json | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-)