mirror of https://gitee.com/openkylin/libvirt.git
qemuDomainBlockCopy: Check @granularity to be a power of two
https://bugzilla.redhat.com/show_bug.cgi?id=1206479 As described in virDomainBlockCopy() parameters description, the VIR_DOMAIN_BLOCK_COPY_GRANULARITY parameter may require the value to have some specific attributes (e.g. be a power of two or fall within a certain range). And in qemu, a power of two is required. However, our code does not check that and let qemu operation fail. Moreover, the virsh man page is not as exact as it could be in this respect. Signed-off-by: Luyao Huang <lhuang@redhat.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
184a927a0a
commit
20aca080f3
|
@ -16866,6 +16866,11 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *disk, const char *destxml,
|
||||||
}
|
}
|
||||||
bandwidth = param->value.ul;
|
bandwidth = param->value.ul;
|
||||||
} else if (STREQ(param->field, VIR_DOMAIN_BLOCK_COPY_GRANULARITY)) {
|
} 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;
|
granularity = param->value.ui;
|
||||||
} else if (STREQ(param->field, VIR_DOMAIN_BLOCK_COPY_BUF_SIZE)) {
|
} else if (STREQ(param->field, VIR_DOMAIN_BLOCK_COPY_BUF_SIZE)) {
|
||||||
buf_size = param->value.ul;
|
buf_size = param->value.ul;
|
||||||
|
|
|
@ -1039,10 +1039,10 @@ unlimited, but more likely would overflow; it is safer to use 0 for that
|
||||||
purpose. Specifying I<granularity> allows fine-tuning of the granularity that
|
purpose. Specifying I<granularity> allows fine-tuning of the granularity that
|
||||||
will be copied when a dirty region is detected; larger values trigger less
|
will be copied when a dirty region is detected; larger values trigger less
|
||||||
I/O overhead but may end up copying more data overall (the default value is
|
I/O overhead but may end up copying more data overall (the default value is
|
||||||
usually correct); this value must be a power of two. Specifying I<buf-size>
|
usually correct); hypervisors may restrict this to be a power of two or fall
|
||||||
will control how much data can be simultaneously in-flight during the copy;
|
within a certain range. Specifying I<buf-size> will control how much data can
|
||||||
larger values use more memory but may allow faster completion (the default
|
be simultaneously in-flight during the copy; larger values use more memory but
|
||||||
value is usually correct).
|
may allow faster completion (the default value is usually correct).
|
||||||
|
|
||||||
=item B<blockpull> I<domain> I<path> [I<bandwidth>] [I<base>]
|
=item B<blockpull> I<domain> I<path> [I<bandwidth>] [I<base>]
|
||||||
[I<--wait> [I<--verbose>] [I<--timeout> B<seconds>] [I<--async>]]
|
[I<--wait> [I<--verbose>] [I<--timeout> B<seconds>] [I<--async>]]
|
||||||
|
|
Loading…
Reference in New Issue