* @baseSource: disk source within backing chain to commit data into
* @topSource: disk source within backing chain with data we will commit
* @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
* @autofinalize: virTristateBool controlling qemu block job finalization
* @flags: bitwise-OR of virDomainBlockCommitFlags
virStorageSource *baseSource,
virStorageSource *topSource,
virStorageSource *top_parent,
- unsigned long bandwidth,
+ unsigned long long bandwidth,
virDomainAsyncJob asyncJob,
virTristateBool autofinalize,
unsigned int flags)
if (virDomainObjCheckActive(vm) < 0)
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))
return NULL;
virStorageSource *baseSource,
virStorageSource *topSource,
virStorageSource *top_parent,
- unsigned long bandwidth,
+ unsigned long long bandwidth,
virDomainAsyncJob asyncJob,
virTristateBool autofinalize,
unsigned int flags);
virStorageSource *topSource;
virStorageSource *baseSource = NULL;
virStorageSource *top_parent = NULL;
+ unsigned long long speed = bandwidth;
g_autoptr(qemuBlockJobData) job = NULL;
virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW |
if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
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)))
goto endjob;
goto endjob;
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);
if (job)
ret = 0;