<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From 20a24d17eee82ab6a8e9945c7413b2cb21c89f36 Mon Sep 17 00:00:00 2001
From: Luiz Capitulino &lt;lcapitulino@redhat.com&gt;
Date: Mon, 22 Mar 2010 14:23:43 -0300
Subject: [PATCH 18/29] monitor: New argument type 'T'

RH-Author: Luiz Capitulino &lt;lcapitulino@redhat.com&gt;
Message-id: &lt;1269267825-8627-7-git-send-email-lcapitulino@redhat.com&gt;
Patchwork-id: 7970
O-Subject: [PATCH 6/8] monitor: New argument type 'T'
Bugzilla: 575821
RH-Acked-by: Markus Armbruster &lt;armbru@redhat.com&gt;
RH-Acked-by: Kevin Wolf &lt;kwolf@redhat.com&gt;
RH-Acked-by: Juan Quintela &lt;quintela@redhat.com&gt;

From: Markus Armbruster &lt;armbru@redhat.com&gt;

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 &lt;armbru@redhat.com&gt;
Signed-off-by: Anthony Liguori &lt;aliguori@us.ibm.com&gt;
(cherry picked from commit fccfb11e0d24ece016825ae064230a2a05d23ed8)
---
 monitor.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

Signed-off-by: Eduardo Habkost &lt;ehabkost@redhat.com&gt;
---
 monitor.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/monitor.c b/monitor.c
index e3cc4b6..6e45c09 100644
--- a/monitor.c
+++ b/monitor.c
@@ -79,6 +79,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 '/')
@@ -3714,6 +3717,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
             }
             break;
         case 'b':
+        case 'T':
             {
                 double val;
 
@@ -3728,7 +3732,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
                 if (get_double(mon, &amp;val, &amp;p) &lt; 0) {
                     goto fail;
                 }
-                if (*p) {
+                if (c == 'b' &amp;&amp; *p) {
                     switch (*p) {
                     case 'K': case 'k':
                         val *= 1 &lt;&lt; 10; p++; break;
@@ -3738,6 +3742,16 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
                         val *= 1 &lt;&lt; 30; p++; break;
                     }
                 }
+                if (c == 'T' &amp;&amp; p[0] &amp;&amp; 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 &amp;&amp; !qemu_isspace(*p)) {
                     monitor_printf(mon, "Unknown unit suffix\n");
                     goto fail;
@@ -4171,6 +4185,7 @@ static int check_arg(const CmdArgs *cmd_args, QDict *args)
             }
             break;
         case 'b':
+        case 'T':
             if (qobject_type(value) != QTYPE_QINT &amp;&amp; qobject_type(value) != QTYPE_QFLOAT) {
                 qemu_error_new(QERR_INVALID_PARAMETER_TYPE, name, "number");
                 return -1;
-- 
1.7.0.3

</pre></body></html>