diff options
author | Markus Armbruster <armbru@redhat.com> | 2010-01-25 14:23:07 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2010-02-03 12:36:26 -0600 |
commit | b0fbf7d3420f5f66be9728b1b070846bb054c872 (patch) | |
tree | 5ad542968e87a144f53366e45ab0a0df87f858e1 /migration.c | |
parent | fccfb11e0d24ece016825ae064230a2a05d23ed8 (diff) | |
download | qemu-b0fbf7d3420f5f66be9728b1b070846bb054c872.zip qemu-b0fbf7d3420f5f66be9728b1b070846bb054c872.tar.gz qemu-b0fbf7d3420f5f66be9728b1b070846bb054c872.tar.bz2 |
monitor: Use argument type 'T' for migrate_set_downtime
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 <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'migration.c')
-rw-r--r-- | migration.c | 15 |
1 files changed, 2 insertions, 13 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; } |