Blame SOURCES/kvm-migration-Change-zero_copy_send-from-migration-param.patch

29b115
From 7e2a037f3f349c21201152cecce32d8c8ff0bea0 Mon Sep 17 00:00:00 2001
29b115
From: Leonardo Bras <leobras@redhat.com>
29b115
Date: Mon, 20 Jun 2022 02:39:45 -0300
29b115
Subject: [PATCH 17/18] migration: Change zero_copy_send from migration
29b115
 parameter to migration capability
29b115
MIME-Version: 1.0
29b115
Content-Type: text/plain; charset=UTF-8
29b115
Content-Transfer-Encoding: 8bit
29b115
29b115
RH-Author: Leonardo BrĂ¡s <leobras@redhat.com>
29b115
RH-MergeRequest: 95: MSG_ZEROCOPY + Multifd
29b115
RH-Commit: [11/11] e4a955607947896a49398ac8400241a0adac51a1 (LeoBras/centos-qemu-kvm)
29b115
RH-Bugzilla: 1968509
29b115
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
29b115
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
29b115
RH-Acked-by: Peter Xu <peterx@redhat.com>
29b115
29b115
When originally implemented, zero_copy_send was designed as a Migration
29b115
paramenter.
29b115
29b115
But taking into account how is that supposed to work, and how
29b115
the difference between a capability and a parameter, it only makes sense
29b115
that zero-copy-send would work better as a capability.
29b115
29b115
Taking into account how recently the change got merged, it was decided
29b115
that it's still time to make it right, and convert zero_copy_send into
29b115
a Migration capability.
29b115
29b115
Signed-off-by: Leonardo Bras <leobras@redhat.com>
29b115
Reviewed-by: Juan Quintela <quintela@redhat.com>
29b115
Acked-by: Markus Armbruster <armbru@redhat.com>
29b115
Acked-by: Peter Xu <peterx@redhat.com>
29b115
Signed-off-by: Juan Quintela <quintela@redhat.com>
29b115
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
29b115
  dgilbert: always define the capability, even on non-Linux but error if
29b115
set; avoids build problems with the capability
29b115
(cherry picked from commit 1abaec9a1b2c23f7aa94709a422128d9e42c3e0b)
29b115
Signed-off-by: Leonardo Bras <leobras@redhat.com>
29b115
---
29b115
 migration/migration.c | 58 +++++++++++++++++++------------------------
29b115
 monitor/hmp-cmds.c    |  6 -----
29b115
 qapi/migration.json   | 33 +++++++-----------------
29b115
 3 files changed, 34 insertions(+), 63 deletions(-)
29b115
29b115
diff --git a/migration/migration.c b/migration/migration.c
29b115
index 102236fba0..2a141bfaf3 100644
29b115
--- a/migration/migration.c
29b115
+++ b/migration/migration.c
29b115
@@ -163,7 +163,8 @@ INITIALIZE_MIGRATE_CAPS_SET(check_caps_background_snapshot,
29b115
     MIGRATION_CAPABILITY_COMPRESS,
29b115
     MIGRATION_CAPABILITY_XBZRLE,
29b115
     MIGRATION_CAPABILITY_X_COLO,
29b115
-    MIGRATION_CAPABILITY_VALIDATE_UUID);
29b115
+    MIGRATION_CAPABILITY_VALIDATE_UUID,
29b115
+    MIGRATION_CAPABILITY_ZERO_COPY_SEND);
29b115
 
29b115
 /* When we add fault tolerance, we could have several
29b115
    migrations at once.  For now we don't need to add
29b115
@@ -899,10 +900,6 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp)
29b115
     params->multifd_zlib_level = s->parameters.multifd_zlib_level;
29b115
     params->has_multifd_zstd_level = true;
29b115
     params->multifd_zstd_level = s->parameters.multifd_zstd_level;
29b115
-#ifdef CONFIG_LINUX
29b115
-    params->has_zero_copy_send = true;
29b115
-    params->zero_copy_send = s->parameters.zero_copy_send;
29b115
-#endif
29b115
     params->has_xbzrle_cache_size = true;
29b115
     params->xbzrle_cache_size = s->parameters.xbzrle_cache_size;
29b115
     params->has_max_postcopy_bandwidth = true;
29b115
@@ -1263,6 +1260,24 @@ static bool migrate_caps_check(bool *cap_list,
29b115
         }
29b115
     }
29b115
 
29b115
+#ifdef CONFIG_LINUX
29b115
+    if (cap_list[MIGRATION_CAPABILITY_ZERO_COPY_SEND] &&
29b115
+        (!cap_list[MIGRATION_CAPABILITY_MULTIFD] ||
29b115
+         migrate_use_compression() ||
29b115
+         migrate_use_tls())) {
29b115
+        error_setg(errp,
29b115
+                   "Zero copy only available for non-compressed non-TLS multifd migration");
29b115
+        return false;
29b115
+    }
29b115
+#else
29b115
+    if (cap_list[MIGRATION_CAPABILITY_ZERO_COPY_SEND]) {
29b115
+        error_setg(errp,
29b115
+                   "Zero copy currently only available on Linux");
29b115
+        return false;
29b115
+    }
29b115
+#endif
29b115
+
29b115
+
29b115
     /* incoming side only */
29b115
     if (runstate_check(RUN_STATE_INMIGRATE) &&
29b115
         !migrate_multifd_is_allowed() &&
29b115
@@ -1485,16 +1500,6 @@ static bool migrate_params_check(MigrationParameters *params, Error **errp)
29b115
         error_prepend(errp, "Invalid mapping given for block-bitmap-mapping: ");
29b115
         return false;
29b115
     }
29b115
-#ifdef CONFIG_LINUX
29b115
-    if (params->zero_copy_send &&
29b115
-        (!migrate_use_multifd() ||
29b115
-         params->multifd_compression != MULTIFD_COMPRESSION_NONE ||
29b115
-         (params->tls_creds && *params->tls_creds))) {
29b115
-        error_setg(errp,
29b115
-                   "Zero copy only available for non-compressed non-TLS multifd migration");
29b115
-        return false;
29b115
-    }
29b115
-#endif
29b115
     return true;
29b115
 }
29b115
 
29b115
@@ -1568,11 +1573,6 @@ static void migrate_params_test_apply(MigrateSetParameters *params,
29b115
     if (params->has_multifd_compression) {
29b115
         dest->multifd_compression = params->multifd_compression;
29b115
     }
29b115
-#ifdef CONFIG_LINUX
29b115
-    if (params->has_zero_copy_send) {
29b115
-        dest->zero_copy_send = params->zero_copy_send;
29b115
-    }
29b115
-#endif
29b115
     if (params->has_xbzrle_cache_size) {
29b115
         dest->xbzrle_cache_size = params->xbzrle_cache_size;
29b115
     }
29b115
@@ -1685,11 +1685,6 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
29b115
     if (params->has_multifd_compression) {
29b115
         s->parameters.multifd_compression = params->multifd_compression;
29b115
     }
29b115
-#ifdef CONFIG_LINUX
29b115
-    if (params->has_zero_copy_send) {
29b115
-        s->parameters.zero_copy_send = params->zero_copy_send;
29b115
-    }
29b115
-#endif
29b115
     if (params->has_xbzrle_cache_size) {
29b115
         s->parameters.xbzrle_cache_size = params->xbzrle_cache_size;
29b115
         xbzrle_cache_resize(params->xbzrle_cache_size, errp);
29b115
@@ -2587,7 +2582,7 @@ bool migrate_use_zero_copy_send(void)
29b115
 
29b115
     s = migrate_get_current();
29b115
 
29b115
-    return s->parameters.zero_copy_send;
29b115
+    return s->enabled_capabilities[MIGRATION_CAPABILITY_ZERO_COPY_SEND];
29b115
 }
29b115
 #endif
29b115
 
29b115
@@ -4243,10 +4238,6 @@ static Property migration_properties[] = {
29b115
     DEFINE_PROP_UINT8("multifd-zstd-level", MigrationState,
29b115
                       parameters.multifd_zstd_level,
29b115
                       DEFAULT_MIGRATE_MULTIFD_ZSTD_LEVEL),
29b115
-#ifdef CONFIG_LINUX
29b115
-    DEFINE_PROP_BOOL("zero_copy_send", MigrationState,
29b115
-                      parameters.zero_copy_send, false),
29b115
-#endif
29b115
     DEFINE_PROP_SIZE("xbzrle-cache-size", MigrationState,
29b115
                       parameters.xbzrle_cache_size,
29b115
                       DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE),
29b115
@@ -4284,6 +4275,10 @@ static Property migration_properties[] = {
29b115
     DEFINE_PROP_MIG_CAP("x-multifd", MIGRATION_CAPABILITY_MULTIFD),
29b115
     DEFINE_PROP_MIG_CAP("x-background-snapshot",
29b115
             MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT),
29b115
+#ifdef CONFIG_LINUX
29b115
+    DEFINE_PROP_MIG_CAP("x-zero-copy-send",
29b115
+            MIGRATION_CAPABILITY_ZERO_COPY_SEND),
29b115
+#endif
29b115
 
29b115
     DEFINE_PROP_END_OF_LIST(),
29b115
 };
29b115
@@ -4344,9 +4339,6 @@ static void migration_instance_init(Object *obj)
29b115
     params->has_multifd_compression = true;
29b115
     params->has_multifd_zlib_level = true;
29b115
     params->has_multifd_zstd_level = true;
29b115
-#ifdef CONFIG_LINUX
29b115
-    params->has_zero_copy_send = true;
29b115
-#endif
29b115
     params->has_xbzrle_cache_size = true;
29b115
     params->has_max_postcopy_bandwidth = true;
29b115
     params->has_max_cpu_throttle = true;
29b115
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
29b115
index 55b48d3733..634968498b 100644
29b115
--- a/monitor/hmp-cmds.c
29b115
+++ b/monitor/hmp-cmds.c
29b115
@@ -1309,12 +1309,6 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
29b115
         p->has_multifd_zstd_level = true;
29b115
         visit_type_uint8(v, param, &p->multifd_zstd_level, &err;;
29b115
         break;
29b115
-#ifdef CONFIG_LINUX
29b115
-    case MIGRATION_PARAMETER_ZERO_COPY_SEND:
29b115
-        p->has_zero_copy_send = true;
29b115
-        visit_type_bool(v, param, &p->zero_copy_send, &err;;
29b115
-        break;
29b115
-#endif
29b115
     case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE:
29b115
         p->has_xbzrle_cache_size = true;
29b115
         if (!visit_type_size(v, param, &cache_size, &err)) {
29b115
diff --git a/qapi/migration.json b/qapi/migration.json
29b115
index 4d833ecdd6..5105790cd0 100644
29b115
--- a/qapi/migration.json
29b115
+++ b/qapi/migration.json
29b115
@@ -463,6 +463,13 @@
29b115
 #                       procedure starts. The VM RAM is saved with running VM.
29b115
 #                       (since 6.0)
29b115
 #
29b115
+# @zero-copy-send: Controls behavior on sending memory pages on migration.
29b115
+#                  When true, enables a zero-copy mechanism for sending
29b115
+#                  memory pages, if host supports it.
29b115
+#                  Requires that QEMU be permitted to use locked memory
29b115
+#                  for guest RAM pages.
29b115
+#                  (since 7.1)
29b115
+#
29b115
 # Features:
29b115
 # @unstable: Members @x-colo and @x-ignore-shared are experimental.
29b115
 #
29b115
@@ -476,7 +483,8 @@
29b115
            'block', 'return-path', 'pause-before-switchover', 'multifd',
29b115
            'dirty-bitmaps', 'postcopy-blocktime', 'late-block-activate',
29b115
            { 'name': 'x-ignore-shared', 'features': [ 'unstable' ] },
29b115
-           'validate-uuid', 'background-snapshot'] }
29b115
+           'validate-uuid', 'background-snapshot',
29b115
+           'zero-copy-send'] }
29b115
 
29b115
 ##
29b115
 # @MigrationCapabilityStatus:
29b115
@@ -741,12 +749,6 @@
29b115
 #                      will consume more CPU.
29b115
 #                      Defaults to 1. (Since 5.0)
29b115
 #
29b115
-# @zero-copy-send: Controls behavior on sending memory pages on migration.
29b115
-#                  When true, enables a zero-copy mechanism for sending
29b115
-#                  memory pages, if host supports it.
29b115
-#                  Requires that QEMU be permitted to use locked memory
29b115
-#                  for guest RAM pages.
29b115
-#                  Defaults to false. (Since 7.1)
29b115
 #
29b115
 # @block-bitmap-mapping: Maps block nodes and bitmaps on them to
29b115
 #                        aliases for the purpose of dirty bitmap migration.  Such
29b115
@@ -787,7 +789,6 @@
29b115
            'xbzrle-cache-size', 'max-postcopy-bandwidth',
29b115
            'max-cpu-throttle', 'multifd-compression',
29b115
            'multifd-zlib-level' ,'multifd-zstd-level',
29b115
-           { 'name': 'zero-copy-send', 'if' : 'CONFIG_LINUX'},
29b115
            'block-bitmap-mapping' ] }
29b115
 
29b115
 ##
29b115
@@ -914,13 +915,6 @@
29b115
 #                      will consume more CPU.
29b115
 #                      Defaults to 1. (Since 5.0)
29b115
 #
29b115
-# @zero-copy-send: Controls behavior on sending memory pages on migration.
29b115
-#                  When true, enables a zero-copy mechanism for sending
29b115
-#                  memory pages, if host supports it.
29b115
-#                  Requires that QEMU be permitted to use locked memory
29b115
-#                  for guest RAM pages.
29b115
-#                  Defaults to false. (Since 7.1)
29b115
-#
29b115
 # @block-bitmap-mapping: Maps block nodes and bitmaps on them to
29b115
 #                        aliases for the purpose of dirty bitmap migration.  Such
29b115
 #                        aliases may for example be the corresponding names on the
29b115
@@ -975,7 +969,6 @@
29b115
             '*multifd-compression': 'MultiFDCompression',
29b115
             '*multifd-zlib-level': 'uint8',
29b115
             '*multifd-zstd-level': 'uint8',
29b115
-            '*zero-copy-send': { 'type': 'bool', 'if': 'CONFIG_LINUX' },
29b115
             '*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ] } }
29b115
 
29b115
 ##
29b115
@@ -1122,13 +1115,6 @@
29b115
 #                      will consume more CPU.
29b115
 #                      Defaults to 1. (Since 5.0)
29b115
 #
29b115
-# @zero-copy-send: Controls behavior on sending memory pages on migration.
29b115
-#                  When true, enables a zero-copy mechanism for sending
29b115
-#                  memory pages, if host supports it.
29b115
-#                  Requires that QEMU be permitted to use locked memory
29b115
-#                  for guest RAM pages.
29b115
-#                  Defaults to false. (Since 7.1)
29b115
-#
29b115
 # @block-bitmap-mapping: Maps block nodes and bitmaps on them to
29b115
 #                        aliases for the purpose of dirty bitmap migration.  Such
29b115
 #                        aliases may for example be the corresponding names on the
29b115
@@ -1181,7 +1167,6 @@
29b115
             '*multifd-compression': 'MultiFDCompression',
29b115
             '*multifd-zlib-level': 'uint8',
29b115
             '*multifd-zstd-level': 'uint8',
29b115
-            '*zero-copy-send': { 'type': 'bool', 'if': 'CONFIG_LINUX' },
29b115
             '*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ] } }
29b115
 
29b115
 ##
29b115
-- 
29b115
2.35.3
29b115