|
|
4841a6 |
From 2a84bf822cae38f67458043cd379a22e0fd22485 Mon Sep 17 00:00:00 2001
|
|
|
719b13 |
From: Leonardo Bras <leobras@redhat.com>
|
|
|
719b13 |
Date: Wed, 18 May 2022 02:52:25 -0300
|
|
|
4841a6 |
Subject: [PATCH 19/37] migration: Add zero-copy-send parameter for QMP/HMP for
|
|
|
719b13 |
Linux
|
|
|
719b13 |
MIME-Version: 1.0
|
|
|
719b13 |
Content-Type: text/plain; charset=UTF-8
|
|
|
719b13 |
Content-Transfer-Encoding: 8bit
|
|
|
719b13 |
|
|
|
719b13 |
RH-Author: Leonardo Brás <leobras@redhat.com>
|
|
|
4841a6 |
RH-MergeRequest: 191: MSG_ZEROCOPY + Multifd @ rhel8.7
|
|
|
4841a6 |
RH-Commit: [19/26] 44ec703088cad75fd6e504958527e81d3261c9df
|
|
|
4841a6 |
RH-Bugzilla: 2072049
|
|
|
719b13 |
RH-Acked-by: Peter Xu <peterx@redhat.com>
|
|
|
4841a6 |
RH-Acked-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
4841a6 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
719b13 |
|
|
|
719b13 |
Add property that allows zero-copy migration of memory pages
|
|
|
719b13 |
on the sending side, and also includes a helper function
|
|
|
719b13 |
migrate_use_zero_copy_send() to check if it's enabled.
|
|
|
719b13 |
|
|
|
719b13 |
No code is introduced to actually do the migration, but it allow
|
|
|
719b13 |
future implementations to enable/disable this feature.
|
|
|
719b13 |
|
|
|
719b13 |
On non-Linux builds this parameter is compiled-out.
|
|
|
719b13 |
|
|
|
719b13 |
Signed-off-by: Leonardo Bras <leobras@redhat.com>
|
|
|
719b13 |
Reviewed-by: Peter Xu <peterx@redhat.com>
|
|
|
719b13 |
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
719b13 |
Reviewed-by: Juan Quintela <quintela@redhat.com>
|
|
|
719b13 |
Acked-by: Markus Armbruster <armbru@redhat.com>
|
|
|
719b13 |
Message-Id: <20220513062836.965425-5-leobras@redhat.com>
|
|
|
719b13 |
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
719b13 |
(cherry picked from commit abb6295b3ace5d17c3a65936913fc346616dbf14)
|
|
|
719b13 |
Signed-off-by: Leonardo Bras <leobras@redhat.com>
|
|
|
719b13 |
---
|
|
|
719b13 |
migration/migration.c | 32 ++++++++++++++++++++++++++++++++
|
|
|
719b13 |
migration/migration.h | 5 +++++
|
|
|
719b13 |
migration/socket.c | 11 +++++++++--
|
|
|
719b13 |
monitor/hmp-cmds.c | 6 ++++++
|
|
|
719b13 |
qapi/migration.json | 24 ++++++++++++++++++++++++
|
|
|
719b13 |
5 files changed, 76 insertions(+), 2 deletions(-)
|
|
|
719b13 |
|
|
|
719b13 |
diff --git a/migration/migration.c b/migration/migration.c
|
|
|
719b13 |
index 8a13294da6..b0fc3f68bd 100644
|
|
|
719b13 |
--- a/migration/migration.c
|
|
|
719b13 |
+++ b/migration/migration.c
|
|
|
719b13 |
@@ -888,6 +888,10 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp)
|
|
|
719b13 |
params->multifd_zlib_level = s->parameters.multifd_zlib_level;
|
|
|
719b13 |
params->has_multifd_zstd_level = true;
|
|
|
719b13 |
params->multifd_zstd_level = s->parameters.multifd_zstd_level;
|
|
|
719b13 |
+#ifdef CONFIG_LINUX
|
|
|
719b13 |
+ params->has_zero_copy_send = true;
|
|
|
719b13 |
+ params->zero_copy_send = s->parameters.zero_copy_send;
|
|
|
719b13 |
+#endif
|
|
|
719b13 |
params->has_xbzrle_cache_size = true;
|
|
|
719b13 |
params->xbzrle_cache_size = s->parameters.xbzrle_cache_size;
|
|
|
719b13 |
params->has_max_postcopy_bandwidth = true;
|
|
|
719b13 |
@@ -1541,6 +1545,11 @@ static void migrate_params_test_apply(MigrateSetParameters *params,
|
|
|
719b13 |
if (params->has_multifd_compression) {
|
|
|
719b13 |
dest->multifd_compression = params->multifd_compression;
|
|
|
719b13 |
}
|
|
|
719b13 |
+#ifdef CONFIG_LINUX
|
|
|
719b13 |
+ if (params->has_zero_copy_send) {
|
|
|
719b13 |
+ dest->zero_copy_send = params->zero_copy_send;
|
|
|
719b13 |
+ }
|
|
|
719b13 |
+#endif
|
|
|
719b13 |
if (params->has_xbzrle_cache_size) {
|
|
|
719b13 |
dest->xbzrle_cache_size = params->xbzrle_cache_size;
|
|
|
719b13 |
}
|
|
|
719b13 |
@@ -1653,6 +1662,11 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
|
|
|
719b13 |
if (params->has_multifd_compression) {
|
|
|
719b13 |
s->parameters.multifd_compression = params->multifd_compression;
|
|
|
719b13 |
}
|
|
|
719b13 |
+#ifdef CONFIG_LINUX
|
|
|
719b13 |
+ if (params->has_zero_copy_send) {
|
|
|
719b13 |
+ s->parameters.zero_copy_send = params->zero_copy_send;
|
|
|
719b13 |
+ }
|
|
|
719b13 |
+#endif
|
|
|
719b13 |
if (params->has_xbzrle_cache_size) {
|
|
|
719b13 |
s->parameters.xbzrle_cache_size = params->xbzrle_cache_size;
|
|
|
719b13 |
xbzrle_cache_resize(params->xbzrle_cache_size, errp);
|
|
|
719b13 |
@@ -2543,6 +2557,17 @@ int migrate_multifd_zstd_level(void)
|
|
|
719b13 |
return s->parameters.multifd_zstd_level;
|
|
|
719b13 |
}
|
|
|
719b13 |
|
|
|
719b13 |
+#ifdef CONFIG_LINUX
|
|
|
719b13 |
+bool migrate_use_zero_copy_send(void)
|
|
|
719b13 |
+{
|
|
|
719b13 |
+ MigrationState *s;
|
|
|
719b13 |
+
|
|
|
719b13 |
+ s = migrate_get_current();
|
|
|
719b13 |
+
|
|
|
719b13 |
+ return s->parameters.zero_copy_send;
|
|
|
719b13 |
+}
|
|
|
719b13 |
+#endif
|
|
|
719b13 |
+
|
|
|
719b13 |
int migrate_use_xbzrle(void)
|
|
|
719b13 |
{
|
|
|
719b13 |
MigrationState *s;
|
|
|
719b13 |
@@ -4193,6 +4218,10 @@ static Property migration_properties[] = {
|
|
|
719b13 |
DEFINE_PROP_UINT8("multifd-zstd-level", MigrationState,
|
|
|
719b13 |
parameters.multifd_zstd_level,
|
|
|
719b13 |
DEFAULT_MIGRATE_MULTIFD_ZSTD_LEVEL),
|
|
|
719b13 |
+#ifdef CONFIG_LINUX
|
|
|
719b13 |
+ DEFINE_PROP_BOOL("zero_copy_send", MigrationState,
|
|
|
719b13 |
+ parameters.zero_copy_send, false),
|
|
|
719b13 |
+#endif
|
|
|
719b13 |
DEFINE_PROP_SIZE("xbzrle-cache-size", MigrationState,
|
|
|
719b13 |
parameters.xbzrle_cache_size,
|
|
|
719b13 |
DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE),
|
|
|
719b13 |
@@ -4290,6 +4319,9 @@ static void migration_instance_init(Object *obj)
|
|
|
719b13 |
params->has_multifd_compression = true;
|
|
|
719b13 |
params->has_multifd_zlib_level = true;
|
|
|
719b13 |
params->has_multifd_zstd_level = true;
|
|
|
719b13 |
+#ifdef CONFIG_LINUX
|
|
|
719b13 |
+ params->has_zero_copy_send = true;
|
|
|
719b13 |
+#endif
|
|
|
719b13 |
params->has_xbzrle_cache_size = true;
|
|
|
719b13 |
params->has_max_postcopy_bandwidth = true;
|
|
|
719b13 |
params->has_max_cpu_throttle = true;
|
|
|
719b13 |
diff --git a/migration/migration.h b/migration/migration.h
|
|
|
719b13 |
index d016cedd9d..908098939f 100644
|
|
|
719b13 |
--- a/migration/migration.h
|
|
|
719b13 |
+++ b/migration/migration.h
|
|
|
719b13 |
@@ -339,6 +339,11 @@ MultiFDCompression migrate_multifd_compression(void);
|
|
|
719b13 |
int migrate_multifd_zlib_level(void);
|
|
|
719b13 |
int migrate_multifd_zstd_level(void);
|
|
|
719b13 |
|
|
|
719b13 |
+#ifdef CONFIG_LINUX
|
|
|
719b13 |
+bool migrate_use_zero_copy_send(void);
|
|
|
719b13 |
+#else
|
|
|
719b13 |
+#define migrate_use_zero_copy_send() (false)
|
|
|
719b13 |
+#endif
|
|
|
719b13 |
int migrate_use_xbzrle(void);
|
|
|
719b13 |
uint64_t migrate_xbzrle_cache_size(void);
|
|
|
719b13 |
bool migrate_colo_enabled(void);
|
|
|
719b13 |
diff --git a/migration/socket.c b/migration/socket.c
|
|
|
719b13 |
index 05705a32d8..3754d8f72c 100644
|
|
|
719b13 |
--- a/migration/socket.c
|
|
|
719b13 |
+++ b/migration/socket.c
|
|
|
719b13 |
@@ -74,9 +74,16 @@ static void socket_outgoing_migration(QIOTask *task,
|
|
|
719b13 |
|
|
|
719b13 |
if (qio_task_propagate_error(task, &err)) {
|
|
|
719b13 |
trace_migration_socket_outgoing_error(error_get_pretty(err));
|
|
|
719b13 |
- } else {
|
|
|
719b13 |
- trace_migration_socket_outgoing_connected(data->hostname);
|
|
|
719b13 |
+ goto out;
|
|
|
719b13 |
}
|
|
|
719b13 |
+
|
|
|
719b13 |
+ trace_migration_socket_outgoing_connected(data->hostname);
|
|
|
719b13 |
+
|
|
|
719b13 |
+ if (migrate_use_zero_copy_send()) {
|
|
|
719b13 |
+ error_setg(&err, "Zero copy send not available in migration");
|
|
|
719b13 |
+ }
|
|
|
719b13 |
+
|
|
|
719b13 |
+out:
|
|
|
719b13 |
migration_channel_connect(data->s, sioc, data->hostname, err);
|
|
|
719b13 |
object_unref(OBJECT(sioc));
|
|
|
719b13 |
}
|
|
|
719b13 |
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
|
|
|
719b13 |
index 2669156b28..e02da5008b 100644
|
|
|
719b13 |
--- a/monitor/hmp-cmds.c
|
|
|
719b13 |
+++ b/monitor/hmp-cmds.c
|
|
|
719b13 |
@@ -1297,6 +1297,12 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
|
|
|
719b13 |
p->has_multifd_zstd_level = true;
|
|
|
719b13 |
visit_type_uint8(v, param, &p->multifd_zstd_level, &err;;
|
|
|
719b13 |
break;
|
|
|
719b13 |
+#ifdef CONFIG_LINUX
|
|
|
719b13 |
+ case MIGRATION_PARAMETER_ZERO_COPY_SEND:
|
|
|
719b13 |
+ p->has_zero_copy_send = true;
|
|
|
719b13 |
+ visit_type_bool(v, param, &p->zero_copy_send, &err;;
|
|
|
719b13 |
+ break;
|
|
|
719b13 |
+#endif
|
|
|
719b13 |
case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE:
|
|
|
719b13 |
p->has_xbzrle_cache_size = true;
|
|
|
719b13 |
if (!visit_type_size(v, param, &cache_size, &err)) {
|
|
|
719b13 |
diff --git a/qapi/migration.json b/qapi/migration.json
|
|
|
719b13 |
index bbfd48cf0b..59b5c5780b 100644
|
|
|
719b13 |
--- a/qapi/migration.json
|
|
|
719b13 |
+++ b/qapi/migration.json
|
|
|
719b13 |
@@ -730,6 +730,13 @@
|
|
|
719b13 |
# will consume more CPU.
|
|
|
719b13 |
# Defaults to 1. (Since 5.0)
|
|
|
719b13 |
#
|
|
|
719b13 |
+# @zero-copy-send: Controls behavior on sending memory pages on migration.
|
|
|
719b13 |
+# When true, enables a zero-copy mechanism for sending
|
|
|
719b13 |
+# memory pages, if host supports it.
|
|
|
719b13 |
+# Requires that QEMU be permitted to use locked memory
|
|
|
719b13 |
+# for guest RAM pages.
|
|
|
719b13 |
+# Defaults to false. (Since 7.1)
|
|
|
719b13 |
+#
|
|
|
719b13 |
# @block-bitmap-mapping: Maps block nodes and bitmaps on them to
|
|
|
719b13 |
# aliases for the purpose of dirty bitmap migration. Such
|
|
|
719b13 |
# aliases may for example be the corresponding names on the
|
|
|
719b13 |
@@ -769,6 +776,7 @@
|
|
|
719b13 |
'xbzrle-cache-size', 'max-postcopy-bandwidth',
|
|
|
719b13 |
'max-cpu-throttle', 'multifd-compression',
|
|
|
719b13 |
'multifd-zlib-level' ,'multifd-zstd-level',
|
|
|
719b13 |
+ { 'name': 'zero-copy-send', 'if' : 'CONFIG_LINUX'},
|
|
|
719b13 |
'block-bitmap-mapping' ] }
|
|
|
719b13 |
|
|
|
719b13 |
##
|
|
|
719b13 |
@@ -895,6 +903,13 @@
|
|
|
719b13 |
# will consume more CPU.
|
|
|
719b13 |
# Defaults to 1. (Since 5.0)
|
|
|
719b13 |
#
|
|
|
719b13 |
+# @zero-copy-send: Controls behavior on sending memory pages on migration.
|
|
|
719b13 |
+# When true, enables a zero-copy mechanism for sending
|
|
|
719b13 |
+# memory pages, if host supports it.
|
|
|
719b13 |
+# Requires that QEMU be permitted to use locked memory
|
|
|
719b13 |
+# for guest RAM pages.
|
|
|
719b13 |
+# Defaults to false. (Since 7.1)
|
|
|
719b13 |
+#
|
|
|
719b13 |
# @block-bitmap-mapping: Maps block nodes and bitmaps on them to
|
|
|
719b13 |
# aliases for the purpose of dirty bitmap migration. Such
|
|
|
719b13 |
# aliases may for example be the corresponding names on the
|
|
|
719b13 |
@@ -949,6 +964,7 @@
|
|
|
719b13 |
'*multifd-compression': 'MultiFDCompression',
|
|
|
719b13 |
'*multifd-zlib-level': 'uint8',
|
|
|
719b13 |
'*multifd-zstd-level': 'uint8',
|
|
|
719b13 |
+ '*zero-copy-send': { 'type': 'bool', 'if': 'CONFIG_LINUX' },
|
|
|
719b13 |
'*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ] } }
|
|
|
719b13 |
|
|
|
719b13 |
##
|
|
|
719b13 |
@@ -1095,6 +1111,13 @@
|
|
|
719b13 |
# will consume more CPU.
|
|
|
719b13 |
# Defaults to 1. (Since 5.0)
|
|
|
719b13 |
#
|
|
|
719b13 |
+# @zero-copy-send: Controls behavior on sending memory pages on migration.
|
|
|
719b13 |
+# When true, enables a zero-copy mechanism for sending
|
|
|
719b13 |
+# memory pages, if host supports it.
|
|
|
719b13 |
+# Requires that QEMU be permitted to use locked memory
|
|
|
719b13 |
+# for guest RAM pages.
|
|
|
719b13 |
+# Defaults to false. (Since 7.1)
|
|
|
719b13 |
+#
|
|
|
719b13 |
# @block-bitmap-mapping: Maps block nodes and bitmaps on them to
|
|
|
719b13 |
# aliases for the purpose of dirty bitmap migration. Such
|
|
|
719b13 |
# aliases may for example be the corresponding names on the
|
|
|
719b13 |
@@ -1147,6 +1170,7 @@
|
|
|
719b13 |
'*multifd-compression': 'MultiFDCompression',
|
|
|
719b13 |
'*multifd-zlib-level': 'uint8',
|
|
|
719b13 |
'*multifd-zstd-level': 'uint8',
|
|
|
719b13 |
+ '*zero-copy-send': { 'type': 'bool', 'if': 'CONFIG_LINUX' },
|
|
|
719b13 |
'*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ] } }
|
|
|
719b13 |
|
|
|
719b13 |
##
|
|
|
719b13 |
--
|
|
|
719b13 |
2.35.3
|
|
|
719b13 |
|