[PATCH v2 0/3] qemu: Add support for avail-switchover-bandwidth migration parameter

See documentation in 1/3 for details. Jiri Denemark (3): Add a migration parameter for available bandwidth in switchover virsh migrate: Add --available-switchover-bandwidth option qemu: Add support for avail-switchover-bandwidth migration parameter docs/manpages/virsh.rst | 12 ++++++++++++ include/libvirt/libvirt-domain.h | 18 ++++++++++++++++++ src/qemu/qemu_migration.h | 1 + src/qemu/qemu_migration_params.c | 9 +++++++++ src/qemu/qemu_migration_params.h | 1 + tools/virsh-domain.c | 13 +++++++++++++ 6 files changed, 54 insertions(+) -- 2.48.1

The new VIR_MIGRATE_PARAM_BANDWIDTH_AVAIL_SWITCHOVER parameter can be used to override the estimated bandwidth that can be used for transferring guest memory and device state once virtual CPUs are stopped. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- include/libvirt/libvirt-domain.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index 2a4b81f4df..74016c6c46 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -1206,6 +1206,24 @@ typedef enum { */ # define VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY "bandwidth.postcopy" +/** + * VIR_MIGRATE_PARAM_BANDWIDTH_AVAIL_SWITCHOVER: + * + * virDomainMigrate* params field: the bandwidth (in MiB/s) available for the + * final phase of (pre-copy) migration during which CPUs are stopped and all + * the remaining memory and device state is transferred. Knowing this bandwidth + * is important for accurate estimation of the domain downtime and deciding + * the right moment for switching over. Normally this would be estimated based + * on the bandwidth used by migration, but this could be lower than the actual + * available bandwidth. Using this parameter to override the computed value may + * help with migration convergence when the migration would keep iterating over + * and over thinking there's not enough bandwidth to comply with the configured + * maximum downtime. + * + * Since: 11.1.0 + */ +# define VIR_MIGRATE_PARAM_BANDWIDTH_AVAIL_SWITCHOVER "bandwidth.avail.switchover" + /** * VIR_MIGRATE_PARAM_GRAPHICS_URI: * -- 2.48.1

Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- docs/manpages/virsh.rst | 12 ++++++++++++ tools/virsh-domain.c | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index e801037c04..bf0436621b 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -3407,6 +3407,7 @@ migrate [--parallel [--parallel-connections connections]] [--bandwidth bandwidth] [--tls-destination hostname] [--disks-uri URI] [--copy-storage-synchronous-writes] + [--available-switchover-bandwidth bandwidth] Migrate domain to another host. Add *--live* for live migration; <--p2p> for peer-2-peer migration; *--direct* for direct migration; or *--tunnelled* @@ -3663,6 +3664,17 @@ the context of the existing socket because it is different from the file representation of the socket and the context is chosen by its creator (usually by using *setsockcreatecon{,_raw}()* functions). +Optional *--available-switchover-bandwidth* overrides the automatically +computed bandwidth (in MiB/s) available for the final phase of (pre-copy) +migration during which CPUs are stopped and all the remaining memory and device +state is transferred. Knowing this bandwidth is important for accurate +estimation of the domain downtime and deciding the right moment for switching +over. Normally this would be estimated based on the bandwidth used by +migration, but this could be lower than the actual available bandwidth. Using +this option may help with migration convergence when the migration would keep +iterating over and over thinking there's not enough bandwidth to comply with +the configured maximum downtime. + migrate-compcache ----------------- diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 546db955a9..f3da2f903f 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -10788,6 +10788,10 @@ static const vshCmdOptDef opts_migrate[] = { .type = VSH_OT_INT, .help = N_("compress level for zstd compression") }, + {.name = "available-switchover-bandwidth", + .type = VSH_OT_INT, + .help = N_("bandwidth (in MiB/s) available for the final phase of migration") + }, {.name = NULL} }; @@ -11102,6 +11106,15 @@ doMigrate(void *opaque) VIR_MIGRATE_PARAM_TLS_DESTINATION, opt) < 0) goto save_error; + if ((rv = vshCommandOptULongLong(ctl, cmd, "available-switchover-bandwidth", &ullOpt)) < 0) { + goto out; + } else if (rv > 0) { + if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams, + VIR_MIGRATE_PARAM_BANDWIDTH_AVAIL_SWITCHOVER, + ullOpt) < 0) + goto save_error; + } + if (flags & VIR_MIGRATE_PEER2PEER || vshCommandOptBool(cmd, "direct")) { if (virDomainMigrateToURI3(dom, desturi, params, nparams, flags) == 0) data->ret = 0; -- 2.48.1

Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/qemu/qemu_migration.h | 1 + src/qemu/qemu_migration_params.c | 9 +++++++++ src/qemu/qemu_migration_params.h | 1 + 3 files changed, 11 insertions(+) diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index 4b7ef9688a..efe1b9e88a 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -92,6 +92,7 @@ VIR_MIGRATE_PARAM_COMPRESSION_ZSTD_LEVEL, VIR_TYPED_PARAM_INT, \ VIR_MIGRATE_PARAM_TLS_DESTINATION, VIR_TYPED_PARAM_STRING, \ VIR_MIGRATE_PARAM_DISKS_URI, VIR_TYPED_PARAM_STRING, \ + VIR_MIGRATE_PARAM_BANDWIDTH_AVAIL_SWITCHOVER, VIR_TYPED_PARAM_ULLONG, \ NULL diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c index 98822012cc..c10660d6f2 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -128,6 +128,7 @@ VIR_ENUM_IMPL(qemuMigrationParam, "multifd-compression", "multifd-zlib-level", "multifd-zstd-level", + "avail-switchover-bandwidth", ); typedef struct _qemuMigrationParamsAlwaysOnItem qemuMigrationParamsAlwaysOnItem; @@ -266,6 +267,11 @@ static const qemuMigrationParamsTPMapItem qemuMigrationParamsTPMap[] = { {.typedParam = VIR_MIGRATE_PARAM_TLS_DESTINATION, .param = QEMU_MIGRATION_PARAM_TLS_HOSTNAME, .party = QEMU_MIGRATION_SOURCE}, + + {.typedParam = VIR_MIGRATE_PARAM_BANDWIDTH_AVAIL_SWITCHOVER, + .unit = 1024 * 1024, /* MiB/s */ + .param = QEMU_MIGRATION_PARAM_AVAIL_SWITCHOVER_BANDWIDTH, + .party = QEMU_MIGRATION_SOURCE}, }; static const qemuMigrationParamInfoItem qemuMigrationParamInfo[] = { @@ -318,6 +324,9 @@ static const qemuMigrationParamInfoItem qemuMigrationParamInfo[] = { [QEMU_MIGRATION_PARAM_MULTIFD_ZSTD_LEVEL] = { .type = QEMU_MIGRATION_PARAM_TYPE_INT, }, + [QEMU_MIGRATION_PARAM_AVAIL_SWITCHOVER_BANDWIDTH] = { + .type = QEMU_MIGRATION_PARAM_TYPE_ULL, + }, }; G_STATIC_ASSERT(G_N_ELEMENTS(qemuMigrationParamInfo) == QEMU_MIGRATION_PARAM_LAST); diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h index df67f1fb92..17fc63f527 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -64,6 +64,7 @@ typedef enum { QEMU_MIGRATION_PARAM_MULTIFD_COMPRESSION, QEMU_MIGRATION_PARAM_MULTIFD_ZLIB_LEVEL, QEMU_MIGRATION_PARAM_MULTIFD_ZSTD_LEVEL, + QEMU_MIGRATION_PARAM_AVAIL_SWITCHOVER_BANDWIDTH, QEMU_MIGRATION_PARAM_LAST } qemuMigrationParam; -- 2.48.1

On 1/23/25 11:52, Jiri Denemark wrote:
See documentation in 1/3 for details.
Jiri Denemark (3): Add a migration parameter for available bandwidth in switchover virsh migrate: Add --available-switchover-bandwidth option qemu: Add support for avail-switchover-bandwidth migration parameter
docs/manpages/virsh.rst | 12 ++++++++++++ include/libvirt/libvirt-domain.h | 18 ++++++++++++++++++ src/qemu/qemu_migration.h | 1 + src/qemu/qemu_migration_params.c | 9 +++++++++ src/qemu/qemu_migration_params.h | 1 + tools/virsh-domain.c | 13 +++++++++++++ 6 files changed, 54 insertions(+)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal
participants (2)
-
Jiri Denemark
-
Michal Prívozník