From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NZOuZ-00011l-1h for qemu-devel@nongnu.org; Mon, 25 Jan 2010 08:23:23 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NZOuS-0000uo-QD for qemu-devel@nongnu.org; Mon, 25 Jan 2010 08:23:20 -0500 Received: from [199.232.76.173] (port=42844 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZOuR-0000uL-LZ for qemu-devel@nongnu.org; Mon, 25 Jan 2010 08:23:16 -0500 Received: from oxygen.pond.sub.org ([213.239.205.148]:60573) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NZOuQ-0003U5-R4 for qemu-devel@nongnu.org; Mon, 25 Jan 2010 08:23:15 -0500 Received: from blackfin.pond.sub.org (pD9E3A875.dip.t-dialin.net [217.227.168.117]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 671DF2E2AF4 for ; Mon, 25 Jan 2010 14:22:57 +0100 (CET) From: Markus Armbruster Date: Mon, 25 Jan 2010 14:23:07 +0100 Message-Id: <1264425788-8245-8-git-send-email-armbru@redhat.com> In-Reply-To: <1264425788-8245-1-git-send-email-armbru@redhat.com> References: <1264425788-8245-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH v3 7/8] monitor: Use argument type 'T' for migrate_set_downtime List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Before, it used type 's', which strips quotes and interprets escapes, and is quite inappropriate for QMP. Negative arguments are no flushed to zero. Before, they were cast to uint32_t, which wrecked the sign. Ridiculously large arguments including infinities are now rejected. Before, they were interpreted as zero. Same for NaN. 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 cd8d9e6..7551953 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 2354e4f..9257d9c 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -775,7 +775,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, -- 1.6.6