]> git.proxmox.com Git - qemu.git/commitdiff
monitor: Use argument type 'b' for migrate_set_speed
authorMarkus Armbruster <armbru@redhat.com>
Mon, 25 Jan 2010 13:23:04 +0000 (14:23 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Wed, 3 Feb 2010 18:36:26 +0000 (12:36 -0600)
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>
migration.c
qemu-monitor.hx

index 598f8df5c4cfe4cd3c00f33862574baaaf514efd..6abdc6514954d34ce5cfdf18ac442dfbab8bda43 100644 (file)
@@ -109,23 +109,11 @@ void do_migrate_cancel(Monitor *mon, const QDict *qdict, QObject **ret_data)
 void do_migrate_set_speed(Monitor *mon, const QDict *qdict)
 {
     double d;
-    char *ptr;
     FdMigrationState *s;
-    const char *value = qdict_get_str(qdict, "value");
-
-    d = strtod(value, &ptr);
-    switch (*ptr) {
-    case 'G': case 'g':
-        d *= 1024;
-    case 'M': case 'm':
-        d *= 1024;
-    case 'K': case 'k':
-        d *= 1024;
-    default:
-        break;
-    }
 
-    max_throttle = (uint32_t)d;
+    d = qdict_get_double(qdict, "value");
+    d = MAX(0, MIN(UINT32_MAX, d));
+    max_throttle = d;
 
     s = migrate_to_fms(current_migration);
     if (s && s->file) {
index b51bb47f2539e34a70772bcf5a1651d0371f97ef..b30301e7d5fb52b0d7fbc3470fa5f0039e105e94 100644 (file)
@@ -761,7 +761,7 @@ ETEXI
 
     {
         .name       = "migrate_set_speed",
-        .args_type  = "value:s",
+        .args_type  = "value:b",
         .params     = "value",
         .help       = "set maximum speed (in bytes) for migrations",
         .mhandler.cmd = do_migrate_set_speed,