The 'max-bandwidth' field was added as argument of
'migrate-set-parameters' in qemu-2.8, thus all qemu version supported by
libvirt already use the new code path.
This patch assumes the presence and removes the legacy code paths.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_driver.c | 39 ++++++++++------------------
src/qemu/qemu_migration.c | 53 +++++++++++----------------------------
2 files changed, 28 insertions(+), 64 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index da95f947e7..a632945146 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13304,7 +13304,7 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom,
qemuDomainObjPrivate *priv;
bool postcopy = !!(flags & VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY);
g_autoptr(qemuMigrationParams) migParams = NULL;
- bool bwParam;
+ qemuMigrationParam param;
unsigned long long max;
int ret = -1;
@@ -13343,35 +13343,22 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom,
VIR_DEBUG("Setting migration bandwidth to %luMbs", bandwidth);
- bwParam = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_PARAM_BANDWIDTH);
- if (postcopy || bwParam) {
- qemuMigrationParam param;
-
- if (!(migParams = qemuMigrationParamsNew()))
- goto endjob;
-
- if (postcopy)
- param = QEMU_MIGRATION_PARAM_MAX_POSTCOPY_BANDWIDTH;
- else
- param = QEMU_MIGRATION_PARAM_MAX_BANDWIDTH;
+ if (!(migParams = qemuMigrationParamsNew()))
+ goto endjob;
- if (qemuMigrationParamsSetULL(migParams, param,
- bandwidth * 1024 * 1024) < 0)
- goto endjob;
+ if (postcopy)
+ param = QEMU_MIGRATION_PARAM_MAX_POSTCOPY_BANDWIDTH;
+ else
+ param = QEMU_MIGRATION_PARAM_MAX_BANDWIDTH;
- if (qemuMigrationParamsApply(driver, vm, VIR_ASYNC_JOB_NONE,
- migParams, 0) < 0)
- goto endjob;
- } else {
- int rc;
+ if (qemuMigrationParamsSetULL(migParams, param,
+ bandwidth * 1024 * 1024) < 0)
+ goto endjob;
- qemuDomainObjEnterMonitor(driver, vm);
- rc = qemuMonitorSetMigrationSpeed(priv->mon, bandwidth);
- qemuDomainObjExitMonitor(vm);
- if (rc < 0)
- goto endjob;
- }
+ if (qemuMigrationParamsApply(driver, vm, VIR_ASYNC_JOB_NONE,
+ migParams, 0) < 0)
+ goto endjob;
if (!postcopy)
priv->migMaxBandwidth = bandwidth;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 9c3fd41761..b12cb518ee 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -4697,7 +4697,6 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
virErrorPtr orig_err = NULL;
unsigned int cookieFlags = 0;
bool abort_on_error = !!(flags & VIR_MIGRATE_ABORT_ON_ERROR);
- bool bwParam = virQEMUCapsGet(priv->qemuCaps,
QEMU_CAPS_MIGRATION_PARAM_BANDWIDTH);
bool storageMigration = flags & (VIR_MIGRATE_NON_SHARED_DISK |
VIR_MIGRATE_NON_SHARED_INC);
bool cancel = false;
unsigned int waitFlags;
@@ -4795,8 +4794,7 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
goto error;
}
- if (bwParam &&
- qemuMigrationParamsSetULL(migParams, QEMU_MIGRATION_PARAM_MAX_BANDWIDTH,
+ if (qemuMigrationParamsSetULL(migParams, QEMU_MIGRATION_PARAM_MAX_BANDWIDTH,
priv->migMaxBandwidth * 1024 * 1024) < 0)
goto error;
@@ -4887,10 +4885,6 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
goto exit_monitor;
}
- if (!bwParam &&
- qemuMonitorSetMigrationSpeed(priv->mon, priv->migMaxBandwidth) < 0)
- goto exit_monitor;
-
rc = qemuMigrationSrcStart(vm, spec, migrate_flags, &fd);
qemuDomainObjExitMonitor(vm);
@@ -6880,7 +6874,6 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm,
virDomainAsyncJob asyncJob)
{
qemuDomainObjPrivate *priv = vm->privateData;
- bool bwParam = virQEMUCapsGet(priv->qemuCaps,
QEMU_CAPS_MIGRATION_PARAM_BANDWIDTH);
int rc;
int ret = -1;
int pipeFD[2] = { -1, -1 };
@@ -6894,27 +6887,18 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm,
/* Increase migration bandwidth to unlimited since target is a file.
* Failure to change migration speed is not fatal. */
- if (bwParam) {
- if (!(migParams = qemuMigrationParamsNew()))
- return -1;
+ if (!(migParams = qemuMigrationParamsNew()))
+ return -1;
- if (qemuMigrationParamsSetULL(migParams,
- QEMU_MIGRATION_PARAM_MAX_BANDWIDTH,
- QEMU_DOMAIN_MIG_BANDWIDTH_MAX * 1024 * 1024) <
0)
- return -1;
+ if (qemuMigrationParamsSetULL(migParams,
+ QEMU_MIGRATION_PARAM_MAX_BANDWIDTH,
+ QEMU_DOMAIN_MIG_BANDWIDTH_MAX * 1024 * 1024) < 0)
+ return -1;
- if (qemuMigrationParamsApply(driver, vm, asyncJob, migParams, 0) < 0)
- return -1;
+ if (qemuMigrationParamsApply(driver, vm, asyncJob, migParams, 0) < 0)
+ return -1;
- priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX;
- } else {
- if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
- qemuMonitorSetMigrationSpeed(priv->mon,
- QEMU_DOMAIN_MIG_BANDWIDTH_MAX);
- priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX;
- qemuDomainObjExitMonitor(vm);
- }
- }
+ priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX;
if (!virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -6994,18 +6978,11 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm,
/* Restore max migration bandwidth */
if (virDomainObjIsActive(vm)) {
- if (bwParam) {
- if (qemuMigrationParamsSetULL(migParams,
- QEMU_MIGRATION_PARAM_MAX_BANDWIDTH,
- saveMigBandwidth * 1024 * 1024) == 0)
- ignore_value(qemuMigrationParamsApply(driver, vm, asyncJob,
- migParams, 0));
- } else {
- if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
- qemuMonitorSetMigrationSpeed(priv->mon, saveMigBandwidth);
- qemuDomainObjExitMonitor(vm);
- }
- }
+ if (qemuMigrationParamsSetULL(migParams,
+ QEMU_MIGRATION_PARAM_MAX_BANDWIDTH,
+ saveMigBandwidth * 1024 * 1024) == 0)
+ ignore_value(qemuMigrationParamsApply(driver, vm, asyncJob,
+ migParams, 0));
priv->migMaxBandwidth = saveMigBandwidth;
}
--
2.36.1