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(a)redhat.com>
---
src/qemu/qemu_migration.c | 6 ++++--
src/qemu/qemu_migration_params.c | 33 ++++++++++++++++++--------------
src/qemu/qemu_migration_params.h | 3 ++-
3 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 3f443a756b..eb544bbb77 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -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) {
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index faaaa29cc9..a7b5ce385e 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -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;
diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h
index 4cb70f62a4..7ca667a507 100644
--- a/src/qemu/qemu_migration_params.h
+++ b/src/qemu/qemu_migration_params.h
@@ -101,7 +101,8 @@ qemuMigrationParamsSetCompression(virDomainObjPtr vm,
int
qemuMigrationParamsCheck(virQEMUDriverPtr driver,
virDomainObjPtr vm,
- int asyncJob);
+ int asyncJob,
+ qemuMigrationParamsPtr migParams);
void
qemuMigrationParamsReset(virQEMUDriverPtr driver,
--
2.17.0