qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v3 6/8] monitor: New argument type 'T'
Date: Mon, 25 Jan 2010 14:23:06 +0100	[thread overview]
Message-ID: <1264425788-8245-7-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1264425788-8245-1-git-send-email-armbru@redhat.com>

This is a double value with optional suffixes ms, us, ns.  We'll need
this to get migrate_set_downtime() QMP-ready.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 monitor.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/monitor.c b/monitor.c
index 6325404..a9d0c8a 100644
--- a/monitor.c
+++ b/monitor.c
@@ -75,6 +75,9 @@
  *              user mode accepts an optional G, g, M, m, K, k suffix,
  *              which multiplies the value by 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
  * '/'          optional gdb-like print format (like "/10x")
  *
  * '?'          optional type (for all types, except '/')
@@ -3543,6 +3546,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
             }
             break;
         case 'b':
+        case 'T':
             {
                 double val;
 
@@ -3557,7 +3561,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
                 if (get_double(mon, &val, &p) < 0) {
                     goto fail;
                 }
-                if (*p) {
+                if (c == 'b' && *p) {
                     switch (*p) {
                     case 'K': case 'k':
                         val *= 1 << 10; p++; break;
@@ -3567,6 +3571,16 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
                         val *= 1 << 30; p++; break;
                     }
                 }
+                if (c == 'T' && p[0] && p[1] == 's') {
+                    switch (*p) {
+                    case 'm':
+                        val /= 1e3; p += 2; break;
+                    case 'u':
+                        val /= 1e6; p += 2; break;
+                    case 'n':
+                        val /= 1e9; p += 2; break;
+                    }
+                }
                 if (*p && !qemu_isspace(*p)) {
                     monitor_printf(mon, "Unknown unit suffix\n");
                     goto fail;
@@ -3981,6 +3995,7 @@ static int check_arg(const CmdArgs *cmd_args, QDict *args)
             }
             break;
         case 'b':
+        case 'T':
             if (qobject_type(value) != QTYPE_QINT && qobject_type(value) != QTYPE_QFLOAT) {
                 qemu_error_new(QERR_INVALID_PARAMETER_TYPE, name, "number");
                 return -1;
-- 
1.6.6

  parent reply	other threads:[~2010-01-25 13:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-25 13:23 [Qemu-devel] [PATCH v3 0/8] Convert migrate_set_speed, migrate_set_downtime to QObject Markus Armbruster
2010-01-25 13:23 ` [Qemu-devel] [PATCH v3 1/8] monitor: Document argument type 'M' Markus Armbruster
2010-02-03 18:37   ` Anthony Liguori
2010-01-25 13:23 ` [Qemu-devel] [PATCH v3 2/8] QDict: New qdict_get_double() Markus Armbruster
2010-01-26 20:58   ` Anthony Liguori
2010-01-27 16:16     ` [Qemu-devel] [PATCH v4 " Markus Armbruster
2010-01-25 13:23 ` [Qemu-devel] [PATCH v3 3/8] monitor: New argument type 'b' Markus Armbruster
2010-01-25 13:23 ` [Qemu-devel] [PATCH v3 4/8] monitor: Use argument type 'b' for migrate_set_speed Markus Armbruster
2010-01-25 13:23 ` [Qemu-devel] [PATCH v3 5/8] monitor: convert do_migrate_set_speed() to QObject Markus Armbruster
2010-01-25 13:23 ` Markus Armbruster [this message]
2010-01-25 13:23 ` [Qemu-devel] [PATCH v3 7/8] monitor: Use argument type 'T' for migrate_set_downtime Markus Armbruster
2010-01-25 13:23 ` [Qemu-devel] [PATCH v3 8/8] monitor: convert do_migrate_set_downtime() to QObject Markus Armbruster
2010-01-25 14:16 ` [Qemu-devel] [PATCH v3 0/8] Convert migrate_set_speed, migrate_set_downtime " Luiz Capitulino

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=1264425788-8245-7-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).