mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
qemu: Fix variable sizing issues with 'bandwidth' argument of qemuBlockCommit
The patch moving the code didn't faithfully represent the typecasting
of the 'bandwidth' variable needed to properly convert from the legacy
'unsigned long' argument which resulted in a build failure on 32 bit
systems:
../src/qemu/qemu_block.c: In function ‘qemuBlockCommit’:
../src/qemu/qemu_block.c:3249:23: error: comparison is always false due to limited range of data type [-Werror=type-limits]
3249 | if (bandwidth > LLONG_MAX >> 20) {
| ^
Fix it by returning the check into qemuDomainBlockCommit as it's needed
only because of the legacy argument type in the old API and use
'unsigned long long' for qemuBlockCommit.
Fixes: f5a77198bf
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
64366c0056
commit
d9193ff92b
@ -3205,7 +3205,7 @@ qemuBlockExportAddNBD(virDomainObj *vm,
|
|||||||
* @baseSource: disk source within backing chain to commit data into
|
* @baseSource: disk source within backing chain to commit data into
|
||||||
* @topSource: disk source within backing chain with data we will commit
|
* @topSource: disk source within backing chain with data we will commit
|
||||||
* @top_parent: disk source that has @topSource as backing disk
|
* @top_parent: disk source that has @topSource as backing disk
|
||||||
* @bandwidth: bandwidth limit, flags determine the unit
|
* @bandwidth: bandwidth limit in bytes/s
|
||||||
* @asyncJob: qemu async job type
|
* @asyncJob: qemu async job type
|
||||||
* @autofinalize: virTristateBool controlling qemu block job finalization
|
* @autofinalize: virTristateBool controlling qemu block job finalization
|
||||||
* @flags: bitwise-OR of virDomainBlockCommitFlags
|
* @flags: bitwise-OR of virDomainBlockCommitFlags
|
||||||
@ -3227,7 +3227,7 @@ qemuBlockCommit(virDomainObj *vm,
|
|||||||
virStorageSource *baseSource,
|
virStorageSource *baseSource,
|
||||||
virStorageSource *topSource,
|
virStorageSource *topSource,
|
||||||
virStorageSource *top_parent,
|
virStorageSource *top_parent,
|
||||||
unsigned long bandwidth,
|
unsigned long long bandwidth,
|
||||||
virDomainAsyncJob asyncJob,
|
virDomainAsyncJob asyncJob,
|
||||||
virTristateBool autofinalize,
|
virTristateBool autofinalize,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
@ -3244,17 +3244,6 @@ qemuBlockCommit(virDomainObj *vm,
|
|||||||
if (virDomainObjCheckActive(vm) < 0)
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Convert bandwidth MiB to bytes, if necessary */
|
|
||||||
if (!(flags & VIR_DOMAIN_BLOCK_COMMIT_BANDWIDTH_BYTES)) {
|
|
||||||
if (bandwidth > LLONG_MAX >> 20) {
|
|
||||||
virReportError(VIR_ERR_OVERFLOW,
|
|
||||||
_("bandwidth must be less than %llu"),
|
|
||||||
LLONG_MAX >> 20);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
bandwidth <<= 20;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!qemuDomainDiskBlockJobIsSupported(disk))
|
if (!qemuDomainDiskBlockJobIsSupported(disk))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ qemuBlockCommit(virDomainObj *vm,
|
|||||||
virStorageSource *baseSource,
|
virStorageSource *baseSource,
|
||||||
virStorageSource *topSource,
|
virStorageSource *topSource,
|
||||||
virStorageSource *top_parent,
|
virStorageSource *top_parent,
|
||||||
unsigned long bandwidth,
|
unsigned long long bandwidth,
|
||||||
virDomainAsyncJob asyncJob,
|
virDomainAsyncJob asyncJob,
|
||||||
virTristateBool autofinalize,
|
virTristateBool autofinalize,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
@ -14994,6 +14994,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
|
|||||||
virStorageSource *topSource;
|
virStorageSource *topSource;
|
||||||
virStorageSource *baseSource = NULL;
|
virStorageSource *baseSource = NULL;
|
||||||
virStorageSource *top_parent = NULL;
|
virStorageSource *top_parent = NULL;
|
||||||
|
unsigned long long speed = bandwidth;
|
||||||
g_autoptr(qemuBlockJobData) job = NULL;
|
g_autoptr(qemuBlockJobData) job = NULL;
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW |
|
virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW |
|
||||||
@ -15011,6 +15012,17 @@ qemuDomainBlockCommit(virDomainPtr dom,
|
|||||||
if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
|
if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
/* Convert bandwidth MiB to bytes, if necessary */
|
||||||
|
if (!(flags & VIR_DOMAIN_BLOCK_COMMIT_BANDWIDTH_BYTES)) {
|
||||||
|
if (speed > LLONG_MAX >> 20) {
|
||||||
|
virReportError(VIR_ERR_OVERFLOW,
|
||||||
|
_("bandwidth must be less than %llu"),
|
||||||
|
LLONG_MAX >> 20);
|
||||||
|
goto endjob;
|
||||||
|
}
|
||||||
|
speed <<= 20;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(disk = qemuDomainDiskByName(vm->def, path)))
|
if (!(disk = qemuDomainDiskByName(vm->def, path)))
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
@ -15027,7 +15039,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
job = qemuBlockCommit(vm, disk, baseSource, topSource, top_parent,
|
job = qemuBlockCommit(vm, disk, baseSource, topSource, top_parent,
|
||||||
bandwidth, VIR_ASYNC_JOB_NONE, VIR_TRISTATE_BOOL_YES,
|
speed, VIR_ASYNC_JOB_NONE, VIR_TRISTATE_BOOL_YES,
|
||||||
flags);
|
flags);
|
||||||
if (job)
|
if (job)
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user