From patchwork Wed Jan 20 16:08:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [v2,7/8] monitor: Use argument type 'T' for migrate_set_downtime() Date: Wed, 20 Jan 2010 06:08:21 -0000 From: Markus Armbruster X-Patchwork-Id: 43302 Message-Id: <1264003702-17329-8-git-send-email-armbru@redhat.com> To: qemu-devel@nongnu.org Before, it used type 's', which strips quotes and interprets escapes, and is quite inappropriate for QMP. Signed-off-by: Markus Armbruster --- migration.c | 15 ++------------- qemu-monitor.hx | 2 +- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/migration.c b/migration.c index e8802ba..c7763f6 100644 --- a/migration.c +++ b/migration.c @@ -134,21 +134,10 @@ uint64_t migrate_max_downtime(void) void do_migrate_set_downtime(Monitor *mon, const QDict *qdict) { - char *ptr; double d; - const char *value = qdict_get_str(qdict, "value"); - - d = strtod(value, &ptr); - if (!strcmp(ptr,"ms")) { - d *= 1000000; - } else if (!strcmp(ptr,"us")) { - d *= 1000; - } else if (!strcmp(ptr,"ns")) { - } else { - /* all else considered to be seconds */ - d *= 1000000000; - } + d = qdict_get_double(qdict, "value") / 1e9; + d = MAX(0, MIN(UINT64_MAX, d)); max_downtime = (uint64_t)d; } diff --git a/qemu-monitor.hx b/qemu-monitor.hx index 20c356a..61b99ba 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -774,7 +774,7 @@ ETEXI { .name = "migrate_set_downtime", - .args_type = "value:s", + .args_type = "value:T", .params = "value", .help = "set maximum tolerated downtime (in seconds) for migrations", .mhandler.cmd = do_migrate_set_downtime,