From patchwork Tue Oct 12 11:10:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jes Sorensen X-Patchwork-Id: 67539 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9E5CAB70EB for ; Tue, 12 Oct 2010 22:23:50 +1100 (EST) Received: from localhost ([127.0.0.1]:55720 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P5cxP-0002Dt-FF for incoming@patchwork.ozlabs.org; Tue, 12 Oct 2010 07:23:47 -0400 Received: from [140.186.70.92] (port=43236 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P5csj-00006P-5i for qemu-devel@nongnu.org; Tue, 12 Oct 2010 07:19:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P5ckN-0004Xj-Hb for qemu-devel@nongnu.org; Tue, 12 Oct 2010 07:10:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28346) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P5ckN-0004XE-B1 for qemu-devel@nongnu.org; Tue, 12 Oct 2010 07:10:19 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9CBAGGc003177 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 12 Oct 2010 07:10:16 -0400 Received: from localhost6.localdomain6 (ovpn-113-72.phx2.redhat.com [10.3.113.72]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o9CBACVq022221; Tue, 12 Oct 2010 07:10:16 -0400 From: Jes.Sorensen@redhat.com To: qemu-devel@nongnu.org Date: Tue, 12 Oct 2010 13:10:07 +0200 Message-Id: <1286881809-11917-3-git-send-email-Jes.Sorensen@redhat.com> In-Reply-To: <1286881809-11917-1-git-send-email-Jes.Sorensen@redhat.com> References: <1286881809-11917-1-git-send-email-Jes.Sorensen@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: pbonzini@redhat.com, armbru@redhat.com Subject: [Qemu-devel] [PATCH 2/4] Add support for 'o' octet (bytes) format as monitor parameter. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jes Sorensen Octet format relies on strtosz 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 | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-) diff --git a/monitor.c b/monitor.c index fbb678d..b0ea5a3 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 @@ -3699,6 +3704,29 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, qdict_put(qdict, key, qint_from_int(val)); } break; + case 'o': + { + ssize_t val; + char *end; + + while (qemu_isspace(*p)) { + p++; + } + if (*typestr == '?') { + typestr++; + if (*p == '\0') { + break; + } + } + val = strtosz(p, &end); + if (val < 0) { + monitor_printf(mon, "invalid size\n"); + goto fail; + } + qdict_put(qdict, key, qint_from_int(val)); + p = end; + } + break; case 'f': case 'T': { @@ -4196,6 +4224,7 @@ static int check_client_args_type(const QDict *client_args, case 'i': case 'l': case 'M': + case 'o': if (qobject_type(client_arg) != QTYPE_QINT) { qerror_report(QERR_INVALID_PARAMETER_TYPE, client_arg_name, "int");