From patchwork Fri Jun 7 11:58:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 249696 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E9E6E2C008F for ; Fri, 7 Jun 2013 22:39:17 +1000 (EST) Received: from localhost ([::1]:40810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkvMG-0003Zg-66 for incoming@patchwork.ozlabs.org; Fri, 07 Jun 2013 08:01:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkvJt-0000hs-AK for qemu-devel@nongnu.org; Fri, 07 Jun 2013 07:59:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkvJp-0004DZ-81 for qemu-devel@nongnu.org; Fri, 07 Jun 2013 07:59:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8174) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkvJp-0004DE-0N for qemu-devel@nongnu.org; Fri, 07 Jun 2013 07:58:57 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r57BwuNO007905 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 7 Jun 2013 07:58:56 -0400 Received: from localhost (ovpn-112-30.ams2.redhat.com [10.36.112.30]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r57Bws35011110; Fri, 7 Jun 2013 07:58:55 -0400 From: Stefan Hajnoczi To: Date: Fri, 7 Jun 2013 13:58:22 +0200 Message-Id: <1370606325-10680-4-git-send-email-stefanha@redhat.com> In-Reply-To: <1370606325-10680-1-git-send-email-stefanha@redhat.com> References: <1370606325-10680-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Anthony Liguori , Stefan Hajnoczi Subject: [Qemu-devel] [PULL 03/26] cutils: Support 'P' and 'E' suffixes in strtosz() 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: Kevin Wolf Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Signed-off-by: Stefan Hajnoczi --- include/qemu-common.h | 2 ++ monitor.c | 8 ++++---- qemu-img.c | 10 ++++++---- tests/qemu-iotests/049.out | 8 ++++---- util/cutils.c | 4 ++++ 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/include/qemu-common.h b/include/qemu-common.h index cb82ef3..d95ea1e 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -191,6 +191,8 @@ int parse_uint_full(const char *s, unsigned long long *value, int base); * A-Z, as strtosz() will use qemu_toupper() on the given argument * prior to comparison. */ +#define STRTOSZ_DEFSUFFIX_EB 'E' +#define STRTOSZ_DEFSUFFIX_PB 'P' #define STRTOSZ_DEFSUFFIX_TB 'T' #define STRTOSZ_DEFSUFFIX_GB 'G' #define STRTOSZ_DEFSUFFIX_MB 'M' diff --git a/monitor.c b/monitor.c index eefc7f0..9d279b8 100644 --- a/monitor.c +++ b/monitor.c @@ -93,10 +93,10 @@ * 'M' Non-negative target long (32 or 64 bit), in user mode the * value is multiplied by 2^20 (think Mebibyte) * 'o' octets (aka bytes) - * user mode accepts an optional T, t, G, g, M, m, K, k - * suffix, which multiplies the value by 2^40 for - * suffixes T and t, 2^30 for suffixes G and g, 2^20 for - * M and m, 2^10 for K and k + * user mode accepts an optional E, e, P, p, T, t, G, g, M, m, + * K, k suffix, which multiplies the value by 2^60 for suffixes E + * and e, 2^50 for suffixes P and p, 2^40 for suffixes T and t, + * 2^30 for suffixes G and g, 2^20 for M and m, 2^10 for K and k * 'T' double * user mode accepts an optional ms, us, ns suffix, * which divides the value by 1e3, 1e6, 1e9, respectively diff --git a/qemu-img.c b/qemu-img.c index 82c7977..e089c78 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -85,8 +85,9 @@ static void help(void) " options are: 'none', 'writeback' (default, except for convert), 'writethrough',\n" " 'directsync' and 'unsafe' (default for convert)\n" " 'size' is the disk image size in bytes. Optional suffixes\n" - " 'k' or 'K' (kilobyte, 1024), 'M' (megabyte, 1024k), 'G' (gigabyte, 1024M)\n" - " and T (terabyte, 1024G) are supported. 'b' is ignored.\n" + " 'k' or 'K' (kilobyte, 1024), 'M' (megabyte, 1024k), 'G' (gigabyte, 1024M),\n" + " 'T' (terabyte, 1024G), 'P' (petabyte, 1024T) and 'E' (exabyte, 1024P) are\n" + " supported. 'b' is ignored.\n" " 'output_filename' is the destination disk image filename\n" " 'output_fmt' is the destination format\n" " 'options' is a comma separated list of format specific options in a\n" @@ -387,8 +388,9 @@ static int img_create(int argc, char **argv) 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."); + "G, T, P or E suffixes for "); + error_report("kilobytes, megabytes, gigabytes, terabytes, " + "petabytes and exabytes."); } return 1; } diff --git a/tests/qemu-iotests/049.out b/tests/qemu-iotests/049.out index 72db13f..d2f0efe 100644 --- a/tests/qemu-iotests/049.out +++ b/tests/qemu-iotests/049.out @@ -108,15 +108,15 @@ qemu-img: Formatting or formatting option not supported for file format 'qcow2' Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=-1024 encryption=off cluster_size=65536 lazy_refcounts=off qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- 1kilobyte -qemu-img: Invalid image size specified! You may use k, M, G or T suffixes for -qemu-img: kilobytes, megabytes, gigabytes and terabytes. +qemu-img: Invalid image size specified! You may use k, M, G, T, P or E suffixes for +qemu-img: kilobytes, megabytes, gigabytes, terabytes, petabytes and exabytes. qemu-img create -f qcow2 -o size=1kilobyte TEST_DIR/t.qcow2 Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 encryption=off cluster_size=65536 lazy_refcounts=off qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- foobar -qemu-img: Invalid image size specified! You may use k, M, G or T suffixes for -qemu-img: kilobytes, megabytes, gigabytes and terabytes. +qemu-img: Invalid image size specified! You may use k, M, G, T, P or E suffixes for +qemu-img: kilobytes, megabytes, gigabytes, terabytes, petabytes and exabytes. qemu-img create -f qcow2 -o size=foobar TEST_DIR/t.qcow2 qemu-img: Parameter 'size' expects a size diff --git a/util/cutils.c b/util/cutils.c index a165819..8f28896 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -267,6 +267,10 @@ static int64_t suffix_mul(char suffix, int64_t unit) return unit * unit * unit; case STRTOSZ_DEFSUFFIX_TB: return unit * unit * unit * unit; + case STRTOSZ_DEFSUFFIX_PB: + return unit * unit * unit * unit * unit; + case STRTOSZ_DEFSUFFIX_EB: + return unit * unit * unit * unit * unit * unit; } return -1; }