[libvirt PATCH 0/2] qemu: Add support for return-path migration capability

See 2/2 for more details about the capability. Jiri Denemark (2): qemu: Support enabling migration caps unless a flag is used qemu: Add support for return-path migration capability src/qemu/qemu_migration_params.c | 39 ++++++++++++++++++++++++-------- src/qemu/qemu_migration_params.h | 1 + 2 files changed, 31 insertions(+), 9 deletions(-) -- 2.34.1

So far we were enabling specific migration capabilities when a corresponding API flag is set. We need to generalize our code to be able to enable some migration capabilities unless a particular API flag is used. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/qemu/qemu_migration_params.c | 33 +++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c index 837ee6d635..dfe0253487 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -47,6 +47,11 @@ typedef enum { QEMU_MIGRATION_PARAM_TYPE_STRING, } qemuMigrationParamType; +typedef enum { + QEMU_MIGRATION_FLAG_REQUIRED, + QEMU_MIGRATION_FLAG_FORBIDDEN, +} qemuMigrationFlagMatch; + typedef struct _qemuMigrationParamValue qemuMigrationParamValue; struct _qemuMigrationParamValue { bool set; @@ -119,6 +124,7 @@ struct _qemuMigrationParamsAlwaysOnItem { typedef struct _qemuMigrationParamsFlagMapItem qemuMigrationParamsFlagMapItem; struct _qemuMigrationParamsFlagMapItem { + qemuMigrationFlagMatch match; virDomainMigrateFlags flag; qemuMigrationCapability cap; int party; /* bit-wise OR of qemuMigrationParty */ @@ -146,19 +152,23 @@ static const qemuMigrationParamsAlwaysOnItem qemuMigrationParamsAlwaysOn[] = { /* Translation from virDomainMigrateFlags to qemuMigrationCapability. */ static const qemuMigrationParamsFlagMapItem qemuMigrationParamsFlagMap[] = { - {VIR_MIGRATE_RDMA_PIN_ALL, + {QEMU_MIGRATION_FLAG_REQUIRED, + VIR_MIGRATE_RDMA_PIN_ALL, QEMU_MIGRATION_CAP_RDMA_PIN_ALL, QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION}, - {VIR_MIGRATE_AUTO_CONVERGE, + {QEMU_MIGRATION_FLAG_REQUIRED, + VIR_MIGRATE_AUTO_CONVERGE, QEMU_MIGRATION_CAP_AUTO_CONVERGE, QEMU_MIGRATION_SOURCE}, - {VIR_MIGRATE_POSTCOPY, + {QEMU_MIGRATION_FLAG_REQUIRED, + VIR_MIGRATE_POSTCOPY, QEMU_MIGRATION_CAP_POSTCOPY, QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION}, - {VIR_MIGRATE_PARALLEL, + {QEMU_MIGRATION_FLAG_REQUIRED, + VIR_MIGRATE_PARALLEL, QEMU_MIGRATION_CAP_MULTIFD, QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION}, }; @@ -553,13 +563,18 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params, return NULL; for (i = 0; i < G_N_ELEMENTS(qemuMigrationParamsFlagMap); i++) { - qemuMigrationCapability cap = qemuMigrationParamsFlagMap[i].cap; + const qemuMigrationParamsFlagMapItem *item = &qemuMigrationParamsFlagMap[i]; + int match; + + if (item->match == QEMU_MIGRATION_FLAG_REQUIRED) + match = item->flag; + else + match = 0; - if (qemuMigrationParamsFlagMap[i].party & party && - flags & qemuMigrationParamsFlagMap[i].flag) { + if (item->party & party && (flags & item->flag) == match) { VIR_DEBUG("Enabling migration capability '%s'", - qemuMigrationCapabilityTypeToString(cap)); - ignore_value(virBitmapSetBit(migParams->caps, cap)); + qemuMigrationCapabilityTypeToString(item->cap)); + ignore_value(virBitmapSetBit(migParams->caps, item->cap)); } } -- 2.34.1

On 12/13/21 15:29, Jiri Denemark wrote:
So far we were enabling specific migration capabilities when a corresponding API flag is set. We need to generalize our code to be able to enable some migration capabilities unless a particular API flag is used.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/qemu/qemu_migration_params.c | 33 +++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c index 837ee6d635..dfe0253487 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -47,6 +47,11 @@ typedef enum { QEMU_MIGRATION_PARAM_TYPE_STRING, } qemuMigrationParamType;
+typedef enum { + QEMU_MIGRATION_FLAG_REQUIRED, + QEMU_MIGRATION_FLAG_FORBIDDEN, +} qemuMigrationFlagMatch; + typedef struct _qemuMigrationParamValue qemuMigrationParamValue; struct _qemuMigrationParamValue { bool set; @@ -119,6 +124,7 @@ struct _qemuMigrationParamsAlwaysOnItem {
typedef struct _qemuMigrationParamsFlagMapItem qemuMigrationParamsFlagMapItem; struct _qemuMigrationParamsFlagMapItem { + qemuMigrationFlagMatch match; virDomainMigrateFlags flag; qemuMigrationCapability cap; int party; /* bit-wise OR of qemuMigrationParty */ @@ -146,19 +152,23 @@ static const qemuMigrationParamsAlwaysOnItem qemuMigrationParamsAlwaysOn[] = {
/* Translation from virDomainMigrateFlags to qemuMigrationCapability. */ static const qemuMigrationParamsFlagMapItem qemuMigrationParamsFlagMap[] = { - {VIR_MIGRATE_RDMA_PIN_ALL, + {QEMU_MIGRATION_FLAG_REQUIRED, + VIR_MIGRATE_RDMA_PIN_ALL, QEMU_MIGRATION_CAP_RDMA_PIN_ALL, QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION},
- {VIR_MIGRATE_AUTO_CONVERGE, + {QEMU_MIGRATION_FLAG_REQUIRED, + VIR_MIGRATE_AUTO_CONVERGE, QEMU_MIGRATION_CAP_AUTO_CONVERGE, QEMU_MIGRATION_SOURCE},
- {VIR_MIGRATE_POSTCOPY, + {QEMU_MIGRATION_FLAG_REQUIRED, + VIR_MIGRATE_POSTCOPY, QEMU_MIGRATION_CAP_POSTCOPY, QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION},
- {VIR_MIGRATE_PARALLEL, + {QEMU_MIGRATION_FLAG_REQUIRED, + VIR_MIGRATE_PARALLEL, QEMU_MIGRATION_CAP_MULTIFD, QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION}, }; @@ -553,13 +563,18 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params, return NULL;
for (i = 0; i < G_N_ELEMENTS(qemuMigrationParamsFlagMap); i++) { - qemuMigrationCapability cap = qemuMigrationParamsFlagMap[i].cap; + const qemuMigrationParamsFlagMapItem *item = &qemuMigrationParamsFlagMap[i]; + int match;
If you initialize this variable, then ..
+ + if (item->match == QEMU_MIGRATION_FLAG_REQUIRED) + match = item->flag; + else + match = 0;
.. this else branch can be dropped.
- if (qemuMigrationParamsFlagMap[i].party & party && - flags & qemuMigrationParamsFlagMap[i].flag) { + if (item->party & party && (flags & item->flag) == match) { VIR_DEBUG("Enabling migration capability '%s'", - qemuMigrationCapabilityTypeToString(cap)); - ignore_value(virBitmapSetBit(migParams->caps, cap)); + qemuMigrationCapabilityTypeToString(item->cap)); + ignore_value(virBitmapSetBit(migParams->caps, item->cap)); } }
Michal

When return-path is enabled, QEMU on the source host won't report completed migration until the destination QEMU sends a confirmation it successfully loaded all data. Libvirt would detect such situation in the Finish phase and report the error read from QEMU's stderr back to the source, but using return-path could give use a bit better error reporting with an earlier restart of vCPUs on the source. The capability is only enabled when the connection between QEMU processes on the source and destination hosts is bidirectional. In other words, only when VIR_MIGRATE_TUNNELLED is not set, because our tunnel only allows one-way communication from the source to the destination. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/qemu/qemu_migration_params.c | 6 ++++++ src/qemu/qemu_migration_params.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c index dfe0253487..d2e9c372a1 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -95,6 +95,7 @@ VIR_ENUM_IMPL(qemuMigrationCapability, "late-block-activate", "multifd", "dirty-bitmaps", + "return-path", ); @@ -171,6 +172,11 @@ static const qemuMigrationParamsFlagMapItem qemuMigrationParamsFlagMap[] = { VIR_MIGRATE_PARALLEL, QEMU_MIGRATION_CAP_MULTIFD, QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION}, + + {QEMU_MIGRATION_FLAG_FORBIDDEN, + VIR_MIGRATE_TUNNELLED, + QEMU_MIGRATION_CAP_RETURN_PATH, + QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION}, }; /* Translation from VIR_MIGRATE_PARAM_* typed parameters to diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h index f770bd2576..b4de8dda7b 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -40,6 +40,7 @@ typedef enum { QEMU_MIGRATION_CAP_LATE_BLOCK_ACTIVATE, QEMU_MIGRATION_CAP_MULTIFD, QEMU_MIGRATION_CAP_BLOCK_DIRTY_BITMAPS, + QEMU_MIGRATION_CAP_RETURN_PATH, QEMU_MIGRATION_CAP_LAST } qemuMigrationCapability; -- 2.34.1

On 12/13/21 15:29, Jiri Denemark wrote:
See 2/2 for more details about the capability.
Jiri Denemark (2): qemu: Support enabling migration caps unless a flag is used qemu: Add support for return-path migration capability
src/qemu/qemu_migration_params.c | 39 ++++++++++++++++++++++++-------- src/qemu/qemu_migration_params.h | 1 + 2 files changed, 31 insertions(+), 9 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal
participants (2)
-
Jiri Denemark
-
Michal Prívozník