From patchwork Wed Jan 2 15:15:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [15/18] qemu-img: report size overflow error message Date: Wed, 02 Jan 2013 05:15:53 -0000 From: Stefan Hajnoczi X-Patchwork-Id: 209069 Message-Id: <1357139756-11951-16-git-send-email-stefanha@redhat.com> To: Cc: Anthony Liguori , Stefan Hajnoczi , liguang From: liguang qemu-img will complain when qcow or qcow2 size overflow for 64 bits, report the right message in this condition. $./qemu-img create -f qcow2 /tmp/foo 0x10000000000000000 before change: qemu-img: Invalid image size specified! You may use k, M, G or T suffixes for qemu-img: kilobytes, megabytes, gigabytes and terabytes. after change: qemu-img: Image size must be less than 8 EiB! [Resolved conflict with a9300911 goto removal -- Stefan] Signed-off-by: liguang Signed-off-by: Stefan Hajnoczi --- qemu-img.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 69cc028..85d3740 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -348,9 +348,13 @@ static int img_create(int argc, char **argv) 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."); + if (sval == -ERANGE) { + error_report("Image size must be less than 8 EiB!"); + } else { + error_report("Invalid image size specified! You may use k, M, " + "G or T suffixes for "); + error_report("kilobytes, megabytes, gigabytes and terabytes."); + } return 1; } img_size = (uint64_t)sval;