[libvirt] [PATCH] qemu: Avoid overflow when setting migration speed

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 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 5a5a59b..912bea1 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -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 -- 1.9.2

On 04/11/2014 04:52 AM, Jiri Denemark wrote:
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 | 7 +++++++ 1 file changed, 7 insertions(+)
ACK -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Fri, Apr 11, 2014 at 08:31:51 -0600, Eric Blake wrote:
On 04/11/2014 04:52 AM, Jiri Denemark wrote:
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 | 7 +++++++ 1 file changed, 7 insertions(+)
ACK
Thanks, pushed. Jirka
participants (2)
-
Eric Blake
-
Jiri Denemark