[PATCH] qemu: add a value check for granularity

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

>From our manual of virsh and qemu side code, we know this
value must be power of 2, so instead of let qemu output error,
we can add a check when we file this value in qemuDomainBlockCopy.

Signed-off-by: Luyao Huang <lhuang@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2c55fb0..6d63317 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16871,6 +16871,11 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *disk, const char *destxml,
             }
             bandwidth = param->value.ul;
         } else if (STREQ(param->field, VIR_DOMAIN_BLOCK_COPY_GRANULARITY)) {
+            if (param->value.ui != VIR_ROUND_UP_POWER_OF_TWO(param->value.ui)) {
+                virReportError(VIR_ERR_INVALID_ARG, "%s",
+                               _("granularity must be power of 2"));
+                goto cleanup;
+            }
             granularity = param->value.ui;
         } else if (STREQ(param->field, VIR_DOMAIN_BLOCK_COPY_BUF_SIZE)) {
             buf_size = param->value.ul;
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]