]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: blockcopy: Add check for bandwidth
authorPeter Krempa <pkrempa@redhat.com>
Mon, 19 Feb 2018 08:21:29 +0000 (09:21 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 19 Feb 2018 14:25:00 +0000 (15:25 +0100)
QEMU code does not work well with too big numbers on the JSON monitor so
our monitor code supports sending only numbers up to LLONG_MAX. Avoid a
weird error message by limiting the size of the 'bandwidth' parameter
for block copy.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_driver.c

index ce25e7a08820c20d74bbc9316717c617476f951b..efac4ed4425f5c90c8ba42d9d6006e2d2ba971c7 100644 (file)
@@ -17182,6 +17182,14 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
         goto cleanup;
     }
 
+    if (bandwidth > LLONG_MAX) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("bandwidth must be less than "
+                         "'%llu' bytes/s (%llu MiB/s)"),
+                       LLONG_MAX, LLONG_MAX >> 20);
+        goto cleanup;
+    }
+
     if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
         goto cleanup;