]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Avoid overflow when setting migration speed
authorJiri Denemark <jdenemar@redhat.com>
Fri, 11 Apr 2014 09:24:51 +0000 (11:24 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 14 Apr 2014 11:42:48 +0000 (13:42 +0200)
When passing migration bandwidth to QEMU, we multiply it by 1024 * 1024
to convert the speed to B/s and the result still needs to fit in
int64_t.

https://bugzilla.redhat.com/show_bug.cgi?id=1083483

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_monitor.c

index 5a5a59ba1e3474b138bc9c1428f27d10a07699f5..912bea182421e301814106b26120ce93c26f8f1f 100644 (file)
@@ -2047,6 +2047,13 @@ int qemuMonitorSetMigrationSpeed(qemuMonitorPtr mon,
         return -1;
     }
 
+    if (bandwidth > QEMU_DOMAIN_MIG_BANDWIDTH_MAX) {
+        virReportError(VIR_ERR_OVERFLOW,
+                       _("bandwidth must be less than %llu"),
+                       QEMU_DOMAIN_MIG_BANDWIDTH_MAX + 1ULL);
+        return -1;
+    }
+
     if (mon->json)
         ret = qemuMonitorJSONSetMigrationSpeed(mon, bandwidth);
     else