qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-block] [RFC PATCH 33/56] block: Make block_resize size unsigned in


From: Markus Armbruster
Subject: [Qemu-block] [RFC PATCH 33/56] block: Make block_resize size unsigned in QAPI/QMP
Date: Mon, 7 Aug 2017 16:45:37 +0200

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 <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]