Most migration capabilities are directly connected with virDomainMigrateFlags so qemuMigrationParamsFromFlags can automatically enable them. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- src/qemu/qemu_migration.c | 30 ----------------------- src/qemu/qemu_migration_params.c | 42 +++++++++++++++++++++++++++----- src/qemu/qemu_migration_params.h | 6 ----- 3 files changed, 36 insertions(+), 42 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index bb8f506659..1c614f8c0d 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2388,18 +2388,6 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, goto stopjob; } - if (qemuMigrationParamsSetCapability(vm, - QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL, - flags & VIR_MIGRATE_RDMA_PIN_ALL, - migParams) < 0) - goto stopjob; - - if (qemuMigrationParamsSetCapability(vm, - QEMU_MONITOR_MIGRATION_CAPS_POSTCOPY, - flags & VIR_MIGRATE_POSTCOPY, - migParams) < 0) - goto stopjob; - if (qemuMigrationParamsCheck(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN, migParams) < 0) goto stopjob; @@ -3344,24 +3332,6 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver, if (qemuMigrationParamsSetCompression(vm, compression, migParams) < 0) goto error; - if (qemuMigrationParamsSetCapability(vm, - QEMU_MONITOR_MIGRATION_CAPS_AUTO_CONVERGE, - flags & VIR_MIGRATE_AUTO_CONVERGE, - migParams) < 0) - goto error; - - if (qemuMigrationParamsSetCapability(vm, - QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL, - flags & VIR_MIGRATE_RDMA_PIN_ALL, - migParams) < 0) - goto error; - - if (qemuMigrationParamsSetCapability(vm, - QEMU_MONITOR_MIGRATION_CAPS_POSTCOPY, - flags & VIR_MIGRATE_POSTCOPY, - migParams) < 0) - goto error; - if (qemuMigrationParamsCheck(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT, migParams) < 0) goto error; diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c index 3837bf5b68..9d2ac6bee5 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -49,6 +49,13 @@ struct _qemuMigrationParamsAlwaysOnItem { int party; /* bit-wise OR of qemuMigrationParty */ }; +typedef struct _qemuMigrationParamsFlagMapItem qemuMigrationParamsFlagMapItem; +struct _qemuMigrationParamsFlagMapItem { + virDomainMigrateFlags flag; + qemuMonitorMigrationCaps cap; + int party; /* bit-wise OR of qemuMigrationParty */ +}; + /* Migration capabilities which should always be enabled as long as they * are supported by QEMU. */ static const qemuMigrationParamsAlwaysOnItem qemuMigrationParamsAlwaysOn[] = { @@ -56,6 +63,21 @@ static const qemuMigrationParamsAlwaysOnItem qemuMigrationParamsAlwaysOn[] = { QEMU_MIGRATION_SOURCE}, }; +/* Translation from virDomainMigrateFlags to qemuMonitorMigrationCaps. */ +static const qemuMigrationParamsFlagMapItem qemuMigrationParamsFlagMap[] = { + {VIR_MIGRATE_RDMA_PIN_ALL, + QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL, + QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION}, + + {VIR_MIGRATE_AUTO_CONVERGE, + QEMU_MONITOR_MIGRATION_CAPS_AUTO_CONVERGE, + QEMU_MIGRATION_SOURCE}, + + {VIR_MIGRATE_POSTCOPY, + QEMU_MONITOR_MIGRATION_CAPS_POSTCOPY, + QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION}, +}; + static qemuMigrationParamsPtr qemuMigrationParamsNew(void) @@ -97,12 +119,18 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params, qemuMigrationParty party) { qemuMigrationParamsPtr migParams; + size_t i; if (!(migParams = qemuMigrationParamsNew())) return NULL; - if (!params) - return migParams; + for (i = 0; i < ARRAY_CARDINALITY(qemuMigrationParamsFlagMap); i++) { + if (qemuMigrationParamsFlagMap[i].party & party && + flags & qemuMigrationParamsFlagMap[i].flag) { + ignore_value(virBitmapSetBit(migParams->caps, + qemuMigrationParamsFlagMap[i].cap)); + } + } #define GET(PARAM, VAR) \ do { \ @@ -116,9 +144,11 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params, migParams->params.VAR ## _set = true; \ } while (0) - if (party == QEMU_MIGRATION_SOURCE) { - GET(AUTO_CONVERGE_INITIAL, cpuThrottleInitial); - GET(AUTO_CONVERGE_INCREMENT, cpuThrottleIncrement); + if (params) { + if (party == QEMU_MIGRATION_SOURCE) { + GET(AUTO_CONVERGE_INITIAL, cpuThrottleInitial); + GET(AUTO_CONVERGE_INCREMENT, cpuThrottleIncrement); + } } #undef GET @@ -197,7 +227,7 @@ qemuMigrationParamsApply(virQEMUDriverPtr driver, } -int +static int qemuMigrationParamsSetCapability(virDomainObjPtr vm ATTRIBUTE_UNUSED, qemuMonitorMigrationCaps capability, bool state, diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h index a483211bdd..a734455b36 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -71,12 +71,6 @@ qemuMigrationParamsApply(virQEMUDriverPtr driver, int asyncJob, qemuMigrationParamsPtr migParams); -int -qemuMigrationParamsSetCapability(virDomainObjPtr vm, - qemuMonitorMigrationCaps capability, - bool state, - qemuMigrationParamsPtr migParams); - int qemuMigrationParamsEnableTLS(virQEMUDriverPtr driver, virDomainObjPtr vm, -- 2.17.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list