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

4841a6
From 70108ff9ffe77062116e47670c0e0c2396529f88 Mon Sep 17 00:00:00 2001
719b13
From: Leonardo Bras <leobras@redhat.com>
719b13
Date: Mon, 20 Jun 2022 02:39:45 -0300
4841a6
Subject: [PATCH 26/37] migration: Change zero_copy_send from migration
719b13
 parameter to migration capability
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: [26/26] ea61e6cbdbe47611bd22d18988e1c4c4e8357cc3
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
When originally implemented, zero_copy_send was designed as a Migration
719b13
paramenter.
719b13
719b13
But taking into account how is that supposed to work, and how
719b13
the difference between a capability and a parameter, it only makes sense
719b13
that zero-copy-send would work better as a capability.
719b13
719b13
Taking into account how recently the change got merged, it was decided
719b13
that it's still time to make it right, and convert zero_copy_send into
719b13
a Migration capability.
719b13
719b13
Signed-off-by: Leonardo Bras <leobras@redhat.com>
719b13
Reviewed-by: Juan Quintela <quintela@redhat.com>
719b13
Acked-by: Markus Armbruster <armbru@redhat.com>
719b13
Acked-by: Peter Xu <peterx@redhat.com>
719b13
Signed-off-by: Juan Quintela <quintela@redhat.com>
719b13
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
719b13
  dgilbert: always define the capability, even on non-Linux but error if
719b13
set; avoids build problems with the capability
719b13
(cherry picked from commit 1abaec9a1b2c23f7aa94709a422128d9e42c3e0b)
719b13
Signed-off-by: Leonardo Bras <leobras@redhat.com>
719b13
---
719b13
 migration/migration.c | 58 +++++++++++++++++++------------------------
719b13
 monitor/hmp-cmds.c    |  6 -----
719b13
 qapi/migration.json   | 33 +++++++-----------------
719b13
 3 files changed, 34 insertions(+), 63 deletions(-)
719b13
719b13
diff --git a/migration/migration.c b/migration/migration.c
719b13
index 5357efd348..c8aa55d2fe 100644
719b13
--- a/migration/migration.c
719b13
+++ b/migration/migration.c
719b13
@@ -162,7 +162,8 @@ INITIALIZE_MIGRATE_CAPS_SET(check_caps_background_snapshot,
719b13
     MIGRATION_CAPABILITY_COMPRESS,
719b13
     MIGRATION_CAPABILITY_XBZRLE,
719b13
     MIGRATION_CAPABILITY_X_COLO,
719b13
-    MIGRATION_CAPABILITY_VALIDATE_UUID);
719b13
+    MIGRATION_CAPABILITY_VALIDATE_UUID,
719b13
+    MIGRATION_CAPABILITY_ZERO_COPY_SEND);
719b13
 
719b13
 bool migrate_pre_2_2;
719b13
 
719b13
@@ -888,10 +889,6 @@ 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
@@ -1249,6 +1246,24 @@ static bool migrate_caps_check(bool *cap_list,
719b13
         }
719b13
     }
719b13
 
719b13
+#ifdef CONFIG_LINUX
719b13
+    if (cap_list[MIGRATION_CAPABILITY_ZERO_COPY_SEND] &&
719b13
+        (!cap_list[MIGRATION_CAPABILITY_MULTIFD] ||
719b13
+         migrate_use_compression() ||
719b13
+         migrate_use_tls())) {
719b13
+        error_setg(errp,
719b13
+                   "Zero copy only available for non-compressed non-TLS multifd migration");
719b13
+        return false;
719b13
+    }
719b13
+#else
719b13
+    if (cap_list[MIGRATION_CAPABILITY_ZERO_COPY_SEND]) {
719b13
+        error_setg(errp,
719b13
+                   "Zero copy currently only available on Linux");
719b13
+        return false;
719b13
+    }
719b13
+#endif
719b13
+
719b13
+
719b13
     /* incoming side only */
719b13
     if (runstate_check(RUN_STATE_INMIGRATE) &&
719b13
         !migrate_multifd_is_allowed() &&
719b13
@@ -1471,16 +1486,6 @@ static bool migrate_params_check(MigrationParameters *params, Error **errp)
719b13
         error_prepend(errp, "Invalid mapping given for block-bitmap-mapping: ");
719b13
         return false;
719b13
     }
719b13
-#ifdef CONFIG_LINUX
719b13
-    if (params->zero_copy_send &&
719b13
-        (!migrate_use_multifd() ||
719b13
-         params->multifd_compression != MULTIFD_COMPRESSION_NONE ||
719b13
-         (params->tls_creds && *params->tls_creds))) {
719b13
-        error_setg(errp,
719b13
-                   "Zero copy only available for non-compressed non-TLS multifd migration");
719b13
-        return false;
719b13
-    }
719b13
-#endif
719b13
     return true;
719b13
 }
719b13
 
719b13
@@ -1554,11 +1559,6 @@ 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
@@ -1671,11 +1671,6 @@ 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
@@ -2573,7 +2568,7 @@ bool migrate_use_zero_copy_send(void)
719b13
 
719b13
     s = migrate_get_current();
719b13
 
719b13
-    return s->parameters.zero_copy_send;
719b13
+    return s->enabled_capabilities[MIGRATION_CAPABILITY_ZERO_COPY_SEND];
719b13
 }
719b13
 #endif
719b13
 
719b13
@@ -4236,10 +4231,6 @@ 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
@@ -4277,6 +4268,10 @@ static Property migration_properties[] = {
719b13
     DEFINE_PROP_MIG_CAP("x-multifd", MIGRATION_CAPABILITY_MULTIFD),
719b13
     DEFINE_PROP_MIG_CAP("x-background-snapshot",
719b13
             MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT),
719b13
+#ifdef CONFIG_LINUX
719b13
+    DEFINE_PROP_MIG_CAP("x-zero-copy-send",
719b13
+            MIGRATION_CAPABILITY_ZERO_COPY_SEND),
719b13
+#endif
719b13
 
719b13
     DEFINE_PROP_END_OF_LIST(),
719b13
 };
719b13
@@ -4337,9 +4332,6 @@ 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/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
719b13
index e02da5008b..2669156b28 100644
719b13
--- a/monitor/hmp-cmds.c
719b13
+++ b/monitor/hmp-cmds.c
719b13
@@ -1297,12 +1297,6 @@ 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 59b5c5780b..fe70a0c4b2 100644
719b13
--- a/qapi/migration.json
719b13
+++ b/qapi/migration.json
719b13
@@ -452,6 +452,13 @@
719b13
 #                       procedure starts. The VM RAM is saved with running VM.
719b13
 #                       (since 6.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
+#                  (since 7.1)
719b13
+#
719b13
 # Features:
719b13
 # @unstable: Members @x-colo and @x-ignore-shared are experimental.
719b13
 #
719b13
@@ -465,7 +472,8 @@
719b13
            'block', 'return-path', 'pause-before-switchover', 'multifd',
719b13
            'dirty-bitmaps', 'postcopy-blocktime', 'late-block-activate',
719b13
            { 'name': 'x-ignore-shared', 'features': [ 'unstable' ] },
719b13
-           'validate-uuid', 'background-snapshot'] }
719b13
+           'validate-uuid', 'background-snapshot',
719b13
+           'zero-copy-send'] }
719b13
 
719b13
 ##
719b13
 # @MigrationCapabilityStatus:
719b13
@@ -730,12 +738,6 @@
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
@@ -776,7 +778,6 @@
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
@@ -903,13 +904,6 @@
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
@@ -964,7 +958,6 @@
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
@@ -1111,13 +1104,6 @@
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
@@ -1170,7 +1156,6 @@
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