qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, Dong Xu Wang <wdongxu@linux.vnet.ibm.com>,
	riegamaths@gmail.com
Subject: [Qemu-devel] [PATCH v3] qemu-img: correct size parsers and help message
Date: Wed, 18 Jul 2012 21:23:06 +0800	[thread overview]
Message-ID: <1342617786-22107-1-git-send-email-wdongxu@linux.vnet.ibm.com> (raw)

qemu-img not only suports k/K/M/G/T/b, but also supports m/g/t/B. So correct
it in help message.

Also use the same parser in parse_option_size function.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
CC: riegamaths@gmail.com
---
v1->v2: also correct error reporting.
v2->v3: use the same parser in parse_option_size function.

 qemu-img.c    |    9 +++++----
 qemu-option.c |    6 +++++-
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index 80cfb9b..7f2fde4 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -69,8 +69,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' or 'M' (megabyte, 1024k),\n"
+           "    'g' or 'G' (gigabyte, 1024M) and 't' or 'T' (terabyte, 1024G) are supported.\n"
+           "    'b' or '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"
@@ -341,8 +342,8 @@ 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("Invalid image size specified! You may use k/K, m/M, "
+                  "g/G or t/T suffixes for ");
             error_report("kilobytes, megabytes, gigabytes and terabytes.");
             ret = -1;
             goto out;
diff --git a/qemu-option.c b/qemu-option.c
index bb3886c..abc3b90 100644
--- a/qemu-option.c
+++ b/qemu-option.c
@@ -213,25 +213,29 @@ static void parse_option_size(const char *name, const char *value,
         sizef = strtod(value, &postfix);
         switch (*postfix) {
         case 'T':
+        case 't':
             sizef *= 1024;
             /* fall through */
         case 'G':
+        case 'g':
             sizef *= 1024;
             /* fall through */
         case 'M':
+        case 'm':
             sizef *= 1024;
             /* fall through */
         case 'K':
         case 'k':
             sizef *= 1024;
             /* fall through */
+        case 'B':
         case 'b':
         case '\0':
             *ret = (uint64_t) sizef;
             break;
         default:
             error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size");
-            error_printf_unless_qmp("You may use k, M, G or T suffixes for "
+            error_printf_unless_qmp("You may use K/k, M/m, G/g or T/t suffixes for "
                     "kilobytes, megabytes, gigabytes and terabytes.\n");
             return;
         }
-- 
1.7.1

             reply	other threads:[~2012-07-18 13:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-18 13:23 Dong Xu Wang [this message]
2012-07-18 13:32 ` [Qemu-devel] [PATCH v3] qemu-img: correct size parsers and help message Kevin Wolf
2012-07-18 13:34 ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1342617786-22107-1-git-send-email-wdongxu@linux.vnet.ibm.com \
    --to=wdongxu@linux.vnet.ibm.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=riegamaths@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).