Sizes should use QAPI type 'size' (uint64_t). block_resize parameter @size is 'int' (int64_t). qmp_block_resize() ensures it's non-negative before it passes it on to blk_truncate().
Change parameter @size to 'size', and update the range check accordingly. Just cleanup; block_resize accepts the same size values as before. Signed-off-by: Markus Armbruster <arm...@redhat.com> --- blockdev.c | 7 ++++--- qapi/block-core.json | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/blockdev.c b/blockdev.c index 960c5be..98dbe51 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2916,7 +2916,7 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict) void qmp_block_resize(bool has_device, const char *device, bool has_node_name, const char *node_name, - int64_t size, Error **errp) + uint64_t size, Error **errp) { Error *local_err = NULL; BlockBackend *blk = NULL; @@ -2940,8 +2940,9 @@ void qmp_block_resize(bool has_device, const char *device, goto out; } - if (size < 0) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "size", "a >0 size"); + if (size > INT64_MAX) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "size", + "a size less than 8EiB"); goto out; } diff --git a/qapi/block-core.json b/qapi/block-core.json index 1e26cb0..2e0d53c 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1009,7 +1009,7 @@ ## { 'command': 'block_resize', 'data': { '*device': 'str', '*node-name': 'str', - 'size': 'int' }} + 'size': 'size' }} ## # @NewImageMode: -- 2.7.5