mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
qemu: Avoid deprecated migrate_set_speed QMP command
The same functionality can be achieved using migrate-set-parameters QMP command with max-bandwidth parameter. https://bugzilla.redhat.com/show_bug.cgi?id=1829545 Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
5fba42c21b
commit
92b8dbc66a
@ -14051,6 +14051,7 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom,
|
||||
qemuDomainObjPrivatePtr priv;
|
||||
bool postcopy = !!(flags & VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY);
|
||||
g_autoptr(qemuMigrationParams) migParams = NULL;
|
||||
bool bwParam;
|
||||
unsigned long long max;
|
||||
int ret = -1;
|
||||
|
||||
@ -14089,12 +14090,20 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom,
|
||||
|
||||
VIR_DEBUG("Setting migration bandwidth to %luMbs", bandwidth);
|
||||
|
||||
if (postcopy) {
|
||||
bwParam = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_PARAM_BANDWIDTH);
|
||||
|
||||
if (postcopy || bwParam) {
|
||||
qemuMigrationParam param;
|
||||
|
||||
if (!(migParams = qemuMigrationParamsNew()))
|
||||
goto endjob;
|
||||
|
||||
if (qemuMigrationParamsSetULL(migParams,
|
||||
QEMU_MIGRATION_PARAM_MAX_POSTCOPY_BANDWIDTH,
|
||||
if (postcopy)
|
||||
param = QEMU_MIGRATION_PARAM_MAX_POSTCOPY_BANDWIDTH;
|
||||
else
|
||||
param = QEMU_MIGRATION_PARAM_MAX_BANDWIDTH;
|
||||
|
||||
if (qemuMigrationParamsSetULL(migParams, param,
|
||||
bandwidth * 1024 * 1024) < 0)
|
||||
goto endjob;
|
||||
|
||||
@ -14108,10 +14117,11 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom,
|
||||
rc = qemuMonitorSetMigrationSpeed(priv->mon, bandwidth);
|
||||
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
|
||||
goto endjob;
|
||||
|
||||
priv->migMaxBandwidth = bandwidth;
|
||||
}
|
||||
|
||||
if (!postcopy)
|
||||
priv->migMaxBandwidth = bandwidth;
|
||||
|
||||
ret = 0;
|
||||
|
||||
endjob:
|
||||
|
@ -3495,6 +3495,7 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
|
||||
unsigned int cookieFlags = 0;
|
||||
bool abort_on_error = !!(flags & VIR_MIGRATE_ABORT_ON_ERROR);
|
||||
bool events = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
|
||||
bool bwParam = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_PARAM_BANDWIDTH);
|
||||
bool cancel = false;
|
||||
unsigned int waitFlags;
|
||||
virDomainDefPtr persistDef = NULL;
|
||||
@ -3582,6 +3583,11 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (bwParam &&
|
||||
qemuMigrationParamsSetULL(migParams, QEMU_MIGRATION_PARAM_MAX_BANDWIDTH,
|
||||
migrate_speed * 1024 * 1024) < 0)
|
||||
goto error;
|
||||
|
||||
if (qemuMigrationParamsApply(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
|
||||
migParams) < 0)
|
||||
goto error;
|
||||
@ -3644,7 +3650,8 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
|
||||
goto exit_monitor;
|
||||
}
|
||||
|
||||
if (qemuMonitorSetMigrationSpeed(priv->mon, migrate_speed) < 0)
|
||||
if (!bwParam &&
|
||||
qemuMonitorSetMigrationSpeed(priv->mon, migrate_speed) < 0)
|
||||
goto exit_monitor;
|
||||
|
||||
/* connect to the destination qemu if needed */
|
||||
@ -5299,24 +5306,41 @@ qemuMigrationSrcToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
|
||||
qemuDomainAsyncJob asyncJob)
|
||||
{
|
||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||
bool bwParam = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_PARAM_BANDWIDTH);
|
||||
int rc;
|
||||
int ret = -1;
|
||||
int pipeFD[2] = { -1, -1 };
|
||||
unsigned long saveMigBandwidth = priv->migMaxBandwidth;
|
||||
char *errbuf = NULL;
|
||||
virErrorPtr orig_err = NULL;
|
||||
g_autoptr(qemuMigrationParams) migParams = NULL;
|
||||
|
||||
if (qemuMigrationSetDBusVMState(driver, vm) < 0)
|
||||
return -1;
|
||||
|
||||
/* Increase migration bandwidth to unlimited since target is a file.
|
||||
* Failure to change migration speed is not fatal. */
|
||||
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
|
||||
qemuMonitorSetMigrationSpeed(priv->mon,
|
||||
QEMU_DOMAIN_MIG_BANDWIDTH_MAX);
|
||||
priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX;
|
||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||
if (bwParam) {
|
||||
if (!(migParams = qemuMigrationParamsNew()))
|
||||
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)
|
||||
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;
|
||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!virDomainObjIsActive(vm)) {
|
||||
@ -5397,11 +5421,20 @@ qemuMigrationSrcToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
|
||||
virErrorPreserveLast(&orig_err);
|
||||
|
||||
/* Restore max migration bandwidth */
|
||||
if (virDomainObjIsActive(vm) &&
|
||||
qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
|
||||
qemuMonitorSetMigrationSpeed(priv->mon, saveMigBandwidth);
|
||||
if (virDomainObjIsActive(vm)) {
|
||||
if (bwParam) {
|
||||
if (qemuMigrationParamsSetULL(migParams,
|
||||
QEMU_MIGRATION_PARAM_MAX_BANDWIDTH,
|
||||
saveMigBandwidth * 1024 * 1024) == 0)
|
||||
ignore_value(qemuMigrationParamsApply(driver, vm, asyncJob,
|
||||
migParams));
|
||||
} else {
|
||||
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
|
||||
qemuMonitorSetMigrationSpeed(priv->mon, saveMigBandwidth);
|
||||
ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
||||
}
|
||||
}
|
||||
priv->migMaxBandwidth = saveMigBandwidth;
|
||||
ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
||||
}
|
||||
|
||||
VIR_FORCE_CLOSE(pipeFD[0]);
|
||||
|
@ -3220,7 +3220,7 @@ mymain(void)
|
||||
DO_TEST_GEN_DEPRECATED(qemuMonitorJSONChangeMedia, true);
|
||||
DO_TEST_GEN(qemuMonitorJSONSaveVirtualMemory);
|
||||
DO_TEST_GEN(qemuMonitorJSONSavePhysicalMemory);
|
||||
DO_TEST_GEN_DEPRECATED(qemuMonitorJSONSetMigrationSpeed, false);
|
||||
DO_TEST_GEN_DEPRECATED(qemuMonitorJSONSetMigrationSpeed, true);
|
||||
DO_TEST_GEN_DEPRECATED(qemuMonitorJSONSetMigrationDowntime, false);
|
||||
DO_TEST_GEN(qemuMonitorJSONMigrate);
|
||||
DO_TEST_GEN(qemuMonitorJSONDump);
|
||||
|
Loading…
Reference in New Issue
Block a user