The current multifd packet size is 128 * 4kb. This change adds
an option to set the packet size. Both sender and receiver needs
to set the same packet size for things to work.
Signed-off-by: Hao Xiang <hao.xiang@bytedance.com>
---
migration/options.c | 36 ++++++++++++++++++++++++++++++++++++
migration/options.h | 1 +
qapi/migration.json | 21 ++++++++++++++++++---
3 files changed, 55 insertions(+), 3 deletions(-)
diff --git a/migration/options.c b/migration/options.c
index aceb391338..fafdeb69cd 100644
--- a/migration/options.c
+++ b/migration/options.c
@@ -84,6 +84,12 @@
*/
#define DEFAULT_MIGRATE_MULTIFD_NORMAL_PAGE_RATIO 101
+/*
+ * Parameter for multifd packet size.
+ */
+#define DEFAULT_MIGRATE_MULTIFD_PACKET_SIZE (128 * 4 * 1024)
+#define MAX_MIGRATE_MULTIFD_PACKET_SIZE (1023 * 4 * 1024)
+
#define DEFINE_PROP_MIG_CAP(name, x) \
DEFINE_PROP_BOOL(name, MigrationState, capabilities[x], false)
@@ -189,6 +195,9 @@ Property migration_properties[] = {
DEFINE_PROP_UINT8("multifd-normal-page-ratio", MigrationState,
parameters.multifd_normal_page_ratio,
DEFAULT_MIGRATE_MULTIFD_NORMAL_PAGE_RATIO),
+ DEFINE_PROP_SIZE("multifd-packet-size", MigrationState,
+ parameters.multifd_packet_size,
+ DEFAULT_MIGRATE_MULTIFD_PACKET_SIZE),
/* Migration capabilities */
DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE),
@@ -876,6 +885,13 @@ uint8_t migrate_multifd_normal_page_ratio(void)
return s->parameters.multifd_normal_page_ratio;
}
+uint64_t migrate_multifd_packet_size(void)
+{
+ MigrationState *s = migrate_get_current();
+
+ return s->parameters.multifd_packet_size;
+}
+
MultiFDCompression migrate_multifd_compression(void)
{
MigrationState *s = migrate_get_current();
@@ -1014,6 +1030,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp)
params->x_checkpoint_delay = s->parameters.x_checkpoint_delay;
params->has_block_incremental = true;
params->block_incremental = s->parameters.block_incremental;
+ params->has_multifd_packet_size = true;
+ params->multifd_packet_size = s->parameters.multifd_packet_size;
params->has_multifd_channels = true;
params->multifd_channels = s->parameters.multifd_channels;
params->has_multifd_compression = true;
@@ -1075,6 +1093,7 @@ void migrate_params_init(MigrationParameters *params)
params->has_downtime_limit = true;
params->has_x_checkpoint_delay = true;
params->has_block_incremental = true;
+ params->has_multifd_packet_size = true;
params->has_multifd_channels = true;
params->has_multifd_compression = true;
params->has_multifd_zlib_level = true;
@@ -1173,6 +1192,17 @@ bool migrate_params_check(MigrationParameters *params, Error **errp)
/* x_checkpoint_delay is now always positive */
+ if (params->has_multifd_packet_size &&
+ ((params->multifd_packet_size < DEFAULT_MIGRATE_MULTIFD_PACKET_SIZE) ||
+ (params->multifd_packet_size > MAX_MIGRATE_MULTIFD_PACKET_SIZE) ||
+ (params->multifd_packet_size % qemu_target_page_size() != 0))) {
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+ "multifd_packet_size",
+ "a value between 524288 and 4190208, "
+ "must be a multiple of guest VM's page size.");
+ return false;
+ }
+
if (params->has_multifd_channels && (params->multifd_channels < 1)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
"multifd_channels",
@@ -1354,6 +1384,9 @@ static void migrate_params_test_apply(MigrateSetParameters *params,
if (params->has_block_incremental) {
dest->block_incremental = params->block_incremental;
}
+ if (params->has_multifd_packet_size) {
+ dest->multifd_packet_size = params->multifd_packet_size;
+ }
if (params->has_multifd_channels) {
dest->multifd_channels = params->multifd_channels;
}
@@ -1499,6 +1532,9 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
" use blockdev-mirror with NBD instead");
s->parameters.block_incremental = params->block_incremental;
}
+ if (params->has_multifd_packet_size) {
+ s->parameters.multifd_packet_size = params->multifd_packet_size;
+ }
if (params->has_multifd_channels) {
s->parameters.multifd_channels = params->multifd_channels;
}
diff --git a/migration/options.h b/migration/options.h
index 21e3e7b0cf..5816f6dac2 100644
--- a/migration/options.h
+++ b/migration/options.h
@@ -96,6 +96,7 @@ const char *migrate_tls_hostname(void);
uint64_t migrate_xbzrle_cache_size(void);
const char *migrate_multifd_dsa_accel(void);
uint8_t migrate_multifd_normal_page_ratio(void);
+uint64_t migrate_multifd_packet_size(void);
/* parameters setters */
diff --git a/qapi/migration.json b/qapi/migration.json
index dedcdd076a..354f10a83f 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -888,6 +888,10 @@
# @multifd-normal-page-ratio: Test hook setting the normal page ratio.
# (Since 8.2)
#
+# @multifd-packet-size: Packet size in bytes used to migrate data.
+# The value needs to be a multiple of guest VM's page size.
+# The default value is 524288 and max value is 4190208. (Since 8.2)
+#
# Features:
#
# @deprecated: Member @block-incremental is deprecated. Use
@@ -922,7 +926,8 @@
{ 'name': 'x-vcpu-dirty-limit-period', 'features': ['unstable'] },
'vcpu-dirty-limit',
'mode',
- 'multifd-normal-page-ratio'] }
+ 'multifd-normal-page-ratio',
+ 'multifd-packet-size'] }
##
# @MigrateSetParameters:
@@ -1086,6 +1091,10 @@
# @multifd-normal-page-ratio: Test hook setting the normal page ratio.
# (Since 8.2)
#
+# @multifd-packet-size: Packet size in bytes used to migrate data.
+# The value needs to be a multiple of guest VM's page size.
+# The default value is 524288 and max value is 4190208. (Since 8.2)
+#
# Features:
#
# @deprecated: Member @block-incremental is deprecated. Use
@@ -1141,7 +1150,8 @@
'*vcpu-dirty-limit': 'uint64',
'*mode': 'MigMode',
'*multifd-dsa-accel': 'StrOrNull',
- '*multifd-normal-page-ratio': 'uint8'} }
+ '*multifd-normal-page-ratio': 'uint8',
+ '*multifd-packet-size' : 'uint64'} }
##
# @migrate-set-parameters:
@@ -1325,6 +1335,10 @@
# @multifd-normal-page-ratio: Test hook setting the normal page ratio.
# (Since 8.2)
#
+# @multifd-packet-size: Packet size in bytes used to migrate data.
+# The value needs to be a multiple of guest VM's page size.
+# The default value is 524288 and max value is 4190208. (Since 8.2)
+#
# Features:
#
# @deprecated: Member @block-incremental is deprecated. Use
@@ -1377,7 +1391,8 @@
'*vcpu-dirty-limit': 'uint64',
'*mode': 'MigMode',
'*multifd-dsa-accel': 'str',
- '*multifd-normal-page-ratio': 'uint8'} }
+ '*multifd-normal-page-ratio': 'uint8',
+ '*multifd-packet-size': 'uint64'} }
##
# @query-migrate-parameters:
--
2.30.2