Skip to contentSkip to conversation

correct error message qemu-img reported

PATCH New liguang 1 participant 1 message Nov 2, 2012

lore
Share & tools
lore

liguang

author
#0 lore raw

PATCH 1/1 correct error message qemu-img reported

qemu-img will complain when qcow or qcow2
size overflow for 64 bits, report the right
message in this condition.

---
 qemu-img.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)
qemu-img.c +9 -7
index f17f187..2a45427 100644
@@ -343,15 +343,17 @@ 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");
+	 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;
     }
Signature · 1 line
1.7.1