Patchwork [v2] correct error message qemu-img reported

login
register
mail settings
Submitter liguang
Date Nov. 2, 2012, 3:34 a.m.
Message ID <1351827283-21239-1-git-send-email-lig.fnst@cn.fujitsu.com>
Download mbox | patch
Permalink /patch/196470/
State New
Headers show

Comments

liguang - Nov. 2, 2012, 3:34 a.m.
qemu-img will complain when qcow or qcow2
size overflow for 64 bits, report the right
message in this condition.

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
---
 qemu-img.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

Patch

diff --git a/qemu-img.c b/qemu-img.c
index f17f187..a81f45b 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -343,16 +343,21 @@  static int img_create(int argc, char **argv)
 
     /* Get image size, if specified */
     if (optind < argc) {
-        int64_t sval;
+        int64_t sval = 0;
         char *end;
         sval = strtosz_suffix(argv[optind++], &end, STRTOSZ_DEFSUFFIX_B);
-        if (sval < 0 || *end) {
-            error_report("Invalid image size specified! You may use k, M, G or "
-                  "T suffixes for ");
-            error_report("kilobytes, megabytes, gigabytes and terabytes.");
-            ret = -1;
-            goto out;
-        }
+	 if (sval < 0) {
+	     error_report("image size is too large!\n");
+             ret = -1;
+             goto out;
+         }
+	 if (*end) {
+	     error_report("Invalid image size specified! You may use k, M, G or "
+		   "T suffixes for ");
+	     error_report("kilobytes, megabytes, gigabytes and terabytes.");
+	     ret = -1;
+             goto out;
+	 }
         img_size = (uint64_t)sval;
     }