return ret;
}
+
+/* bandwidth in MiB/s per public API */
static int
qemuDomainBlockJobImpl(virDomainObjPtr vm,
virConnectPtr conn,
char *backingPath = NULL;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
bool save = false;
+ unsigned long long speed = bandwidth;
if (!virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
}
}
+ /* Convert bandwidth MiB to bytes */
+ if (speed > LLONG_MAX >> 20) {
+ virReportError(VIR_ERR_OVERFLOW,
+ _("bandwidth must be less than %llu"),
+ LLONG_MAX >> 20);
+ goto endjob;
+ }
+ speed <<= 20;
+
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorBlockJob(priv->mon, device, basePath, backingPath,
- bandwidth, mode, async);
+ speed, mode, async);
qemuDomainObjExitMonitor(driver, vm);
if (ret < 0) {
if (mode == BLOCK_JOB_ABORT && disk->mirror)
BLOCK_JOB_SPEED, flags);
}
+
+/* bandwidth in bytes/s */
static int
qemuDomainBlockCopy(virDomainObjPtr vm,
virConnectPtr conn,
const char *path,
const char *dest, const char *format,
- unsigned long bandwidth, unsigned int flags)
+ unsigned long long bandwidth, unsigned int flags)
{
virQEMUDriverPtr driver = conn->privateData;
qemuDomainObjPrivatePtr priv;
virDomainObjPtr vm;
const char *format = NULL;
int ret = -1;
+ unsigned long long speed = bandwidth;
virCheckFlags(VIR_DOMAIN_BLOCK_REBASE_SHALLOW |
VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT |
if (flags & VIR_DOMAIN_BLOCK_REBASE_COPY_RAW)
format = "raw";
+ /* Convert bandwidth MiB to bytes */
+ if (speed > LLONG_MAX >> 20) {
+ virReportError(VIR_ERR_OVERFLOW,
+ _("bandwidth must be less than %llu"),
+ LLONG_MAX >> 20);
+ goto cleanup;
+ }
+ speed <<= 20;
+
/* XXX: If we are doing a shallow copy but not reusing an external
* file, we should attempt to pre-create the destination with a
* relative backing chain instead of qemu's default of absolute */
char *basePath = NULL;
char *backingPath = NULL;
virStorageSourcePtr mirror = NULL;
+ unsigned long long speed = bandwidth;
/* XXX Add support for COMMIT_DELETE */
virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW |
goto endjob;
}
+ /* Convert bandwidth MiB to bytes */
+ if (speed > LLONG_MAX >> 20) {
+ virReportError(VIR_ERR_OVERFLOW,
+ _("bandwidth must be less than %llu"),
+ LLONG_MAX >> 20);
+ goto endjob;
+ }
+ speed <<= 20;
+
device = qemuDiskPathToAlias(vm, path, &idx);
if (!device)
goto endjob;
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorBlockCommit(priv->mon, device,
topPath, basePath, backingPath,
- bandwidth);
+ speed);
qemuDomainObjExitMonitor(driver, vm);
if (mirror) {
return ret;
}
-/* Start a drive-mirror block job. bandwidth is in MiB/sec. */
+/* Start a drive-mirror block job. bandwidth is in bytes/sec. */
int
qemuMonitorDriveMirror(qemuMonitorPtr mon,
const char *device, const char *file,
- const char *format, unsigned long bandwidth,
+ const char *format, unsigned long long bandwidth,
unsigned int flags)
{
int ret = -1;
- unsigned long long speed;
- VIR_DEBUG("mon=%p, device=%s, file=%s, format=%s, bandwidth=%ld, "
+ VIR_DEBUG("mon=%p, device=%s, file=%s, format=%s, bandwidth=%lld, "
"flags=%x",
mon, device, file, NULLSTR(format), bandwidth, flags);
- /* Convert bandwidth MiB to bytes - unfortunately the JSON QMP protocol is
- * limited to LLONG_MAX also for unsigned values */
- speed = bandwidth;
- if (speed > LLONG_MAX >> 20) {
- virReportError(VIR_ERR_OVERFLOW,
- _("bandwidth must be less than %llu"),
- LLONG_MAX >> 20);
- return -1;
- }
- speed <<= 20;
-
if (mon->json)
- ret = qemuMonitorJSONDriveMirror(mon, device, file, format, speed,
+ ret = qemuMonitorJSONDriveMirror(mon, device, file, format, bandwidth,
flags);
else
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
return ret;
}
-/* Start a block-commit block job. bandwidth is in MiB/sec. */
+/* Start a block-commit block job. bandwidth is in bytes/sec. */
int
qemuMonitorBlockCommit(qemuMonitorPtr mon, const char *device,
const char *top, const char *base,
const char *backingName,
- unsigned long bandwidth)
+ unsigned long long bandwidth)
{
int ret = -1;
- unsigned long long speed;
- VIR_DEBUG("mon=%p, device=%s, top=%s, base=%s, backingName=%s, bandwidth=%lu",
+ VIR_DEBUG("mon=%p, device=%s, top=%s, base=%s, backingName=%s, "
+ "bandwidth=%llu",
mon, device, top, base, NULLSTR(backingName), bandwidth);
- /* Convert bandwidth MiB to bytes - unfortunately the JSON QMP protocol is
- * limited to LLONG_MAX also for unsigned values */
- speed = bandwidth;
- if (speed > LLONG_MAX >> 20) {
- virReportError(VIR_ERR_OVERFLOW,
- _("bandwidth must be less than %llu"),
- LLONG_MAX >> 20);
- return -1;
- }
- speed <<= 20;
-
if (mon->json)
ret = qemuMonitorJSONBlockCommit(mon, device, top, base,
- backingName, speed);
+ backingName, bandwidth);
else
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("block-commit requires JSON monitor"));
return ret;
}
-/* bandwidth is in MiB/sec */
+/* bandwidth is in bytes/sec */
int
qemuMonitorBlockJob(qemuMonitorPtr mon,
const char *device,
const char *base,
const char *backingName,
- unsigned long bandwidth,
+ unsigned long long bandwidth,
qemuMonitorBlockJobCmd mode,
bool modern)
{
int ret = -1;
- unsigned long long speed;
- VIR_DEBUG("mon=%p, device=%s, base=%s, backingName=%s, bandwidth=%luM, "
+ VIR_DEBUG("mon=%p, device=%s, base=%s, backingName=%s, bandwidth=%lluB, "
"mode=%o, modern=%d",
mon, device, NULLSTR(base), NULLSTR(backingName),
bandwidth, mode, modern);
- /* Convert bandwidth MiB to bytes - unfortunately the JSON QMP protocol is
- * limited to LLONG_MAX also for unsigned values */
- speed = bandwidth;
- if (speed > LLONG_MAX >> 20) {
- virReportError(VIR_ERR_OVERFLOW,
- _("bandwidth must be less than %llu"),
- LLONG_MAX >> 20);
- return -1;
- }
- speed <<= 20;
-
if (mon->json)
ret = qemuMonitorJSONBlockJob(mon, device, base, backingName,
- speed, mode, modern);
+ bandwidth, mode, modern);
else
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("block jobs require JSON monitor"));