mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-09 13:57:27 +03:00
qemu: Check supported caps in qemuMigrationParamsCheck
Instead of checking each capability at the time we want to set it in qemuMigrationParamsSetCapability we can check all of them at once in qemuMigrationParamsCheck. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
2943c52e39
commit
657980693c
@ -2398,7 +2398,8 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
|
||||
migParams) < 0)
|
||||
goto stopjob;
|
||||
|
||||
if (qemuMigrationParamsCheck(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
|
||||
if (qemuMigrationParamsCheck(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN,
|
||||
migParams) < 0)
|
||||
goto stopjob;
|
||||
|
||||
/* Migrations using TLS need to add the "tls-creds-x509" object and
|
||||
@ -3360,7 +3361,8 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
|
||||
true, migParams) < 0)
|
||||
goto error;
|
||||
|
||||
if (qemuMigrationParamsCheck(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
|
||||
if (qemuMigrationParamsCheck(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
|
||||
migParams) < 0)
|
||||
goto error;
|
||||
|
||||
if (flags & VIR_MIGRATE_TLS) {
|
||||
|
@ -182,23 +182,11 @@ qemuMigrationParamsApply(virQEMUDriverPtr driver,
|
||||
|
||||
|
||||
int
|
||||
qemuMigrationParamsSetCapability(virDomainObjPtr vm,
|
||||
qemuMigrationParamsSetCapability(virDomainObjPtr vm ATTRIBUTE_UNUSED,
|
||||
qemuMonitorMigrationCaps capability,
|
||||
bool state,
|
||||
qemuMigrationParamsPtr migParams)
|
||||
{
|
||||
if (!qemuMigrationCapsGet(vm, capability)) {
|
||||
if (!state) {
|
||||
/* Unsupported but we want it off anyway */
|
||||
return 0;
|
||||
}
|
||||
|
||||
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,
|
||||
_("Migration option '%s' is not supported by QEMU binary"),
|
||||
qemuMonitorMigrationCapsTypeToString(capability));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (state)
|
||||
ignore_value(virBitmapSetBit(migParams->caps, capability));
|
||||
else
|
||||
@ -413,16 +401,33 @@ qemuMigrationParamsResetTLS(virQEMUDriverPtr driver,
|
||||
*
|
||||
* Check supported migration parameters and keep their original values in
|
||||
* qemuDomainJobObj so that we can properly reset them at the end of migration.
|
||||
* Reports an error if any of the currently used capabilities in @migParams
|
||||
* are unsupported by QEMU.
|
||||
*/
|
||||
int
|
||||
qemuMigrationParamsCheck(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
int asyncJob)
|
||||
int asyncJob,
|
||||
qemuMigrationParamsPtr migParams)
|
||||
{
|
||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||
qemuMigrationParamsPtr origParams = NULL;
|
||||
qemuMonitorMigrationCaps cap;
|
||||
int ret = -1;
|
||||
|
||||
for (cap = 0; cap < QEMU_MONITOR_MIGRATION_CAPS_LAST; cap++) {
|
||||
bool state = false;
|
||||
|
||||
ignore_value(virBitmapGetBit(migParams->caps, cap, &state));
|
||||
|
||||
if (state && !qemuMigrationCapsGet(vm, cap)) {
|
||||
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,
|
||||
_("Migration option '%s' is not supported by QEMU binary"),
|
||||
qemuMonitorMigrationCapsTypeToString(cap));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
||||
return -1;
|
||||
|
||||
|
@ -101,7 +101,8 @@ qemuMigrationParamsSetCompression(virDomainObjPtr vm,
|
||||
int
|
||||
qemuMigrationParamsCheck(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
int asyncJob);
|
||||
int asyncJob,
|
||||
qemuMigrationParamsPtr migParams);
|
||||
|
||||
void
|
||||
qemuMigrationParamsReset(virQEMUDriverPtr driver,
|
||||
|
Loading…
x
Reference in New Issue
Block a user