From patchwork Wed Jan 2 15:15:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 209069 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 767382C0087 for ; Thu, 3 Jan 2013 03:11:17 +1100 (EST) Received: from localhost ([::1]:45190 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqQ4I-00029u-7e for incoming@patchwork.ozlabs.org; Wed, 02 Jan 2013 10:17:22 -0500 Received: from eggs.gnu.org ([208.118.235.92]:42635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqQ3l-0001T4-21 for qemu-devel@nongnu.org; Wed, 02 Jan 2013 10:16:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TqQ3h-0005gC-Nk for qemu-devel@nongnu.org; Wed, 02 Jan 2013 10:16:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:27533) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqQ3h-0005fW-Gx for qemu-devel@nongnu.org; Wed, 02 Jan 2013 10:16:45 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r02FGfeu003145 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 2 Jan 2013 10:16:42 -0500 Received: from localhost (ovpn-112-16.ams2.redhat.com [10.36.112.16]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r02FGe6Q011002; Wed, 2 Jan 2013 10:16:41 -0500 From: Stefan Hajnoczi To: Date: Wed, 2 Jan 2013 16:15:53 +0100 Message-Id: <1357139756-11951-16-git-send-email-stefanha@redhat.com> In-Reply-To: <1357139756-11951-1-git-send-email-stefanha@redhat.com> References: <1357139756-11951-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Anthony Liguori , Stefan Hajnoczi , liguang Subject: [Qemu-devel] [PATCH 15/18] qemu-img: report size overflow error message X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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;