Received: from [140.186.70.92] (port=43009 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0X4Y-0000Cp-Cw for qemu-devel@nongnu.org; Tue, 28 Sep 2010 06:06:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P0X4X-0001Zl-1T for qemu-devel@nongnu.org; Tue, 28 Sep 2010 06:06:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12488) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P0X4W-0001Zc-QQ for qemu-devel@nongnu.org; Tue, 28 Sep 2010 06:06:05 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8SA63ZV012017 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 28 Sep 2010 06:06:04 -0400 From: Markus Armbruster Subject: Re: [Qemu-devel] [PATCH 3/5] Add support for 'o' octet (bytes) format as monitor parameter. References: <1284648749-18479-1-git-send-email-Jes.Sorensen@redhat.com> <1284648749-18479-4-git-send-email-Jes.Sorensen@redhat.com> Date: Tue, 28 Sep 2010 12:06:01 +0200 In-Reply-To: <1284648749-18479-4-git-send-email-Jes.Sorensen@redhat.com> (Jes Sorensen's message of "Thu, 16 Sep 2010 16:52:27 +0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jes.Sorensen@redhat.com Cc: pbonzini@redhat.com, qemu-devel@nongnu.org Jes.Sorensen@redhat.com writes: > From: Jes Sorensen > > Octet format relies on strtobytes which supports K/k, M/m, G/g, T/t > suffixes and unit support for humans, like 1.3G > > Signed-off-by: Jes Sorensen > --- > monitor.c | 27 +++++++++++++++++++++++++++ > 1 files changed, 27 insertions(+), 0 deletions(-) > > diff --git a/monitor.c b/monitor.c > index e602480..3630061 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -78,6 +78,11 @@ > * 'l' target long (32 or 64 bit) > * 'M' just like 'l', except 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 > * 'f' double > * user mode accepts an optional G, g, M, m, K, k suffix, > * which multiplies the value by 2^30 for suffixes G and > @@ -3594,6 +3599,28 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, > qdict_put(qdict, key, qint_from_int(val)); > } > break; > + case 'o': > + { > + int64_t val; > + char *end; > + > + while (qemu_isspace(*p)) > + p++; > + if (*typestr == '?') { > + typestr++; > + if (*p == '\0') { > + break; > + } > + } > + val = strtobytes(p, &end); > + if (!val) { > + monitor_printf(mon, "invalid size\n"); > + goto fail; > + } > + qdict_put(qdict, key, qint_from_int(val)); > + p = end; > + } > + break; > case 'f': > case 'T': > { This is incomplete, you need to update check_client_args_type() as well. Testing with QMP should have made that obvious.