Blame SOURCES/kvm-migration-Avoid-false-positive-on-non-supported-scen.patch

719b13
From cfcde3507dd742c0e17cdfe3ac3bf076cc131a84 Mon Sep 17 00:00:00 2001
719b13
From: Leonardo Bras <leobras@redhat.com>
719b13
Date: Tue, 19 Jul 2022 09:23:45 -0300
719b13
Subject: [PATCH 32/34] migration: Avoid false-positive on non-supported
719b13
 scenarios for zero-copy-send
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>
719b13
RH-MergeRequest: 185: MSG_ZEROCOPY + Multifd @ rhel8.6
719b13
RH-Commit: [32/34] 409d9f974c5d69cdb4df8ef44f45c6cb25638144
719b13
RH-Bugzilla: 2117252
719b13
RH-Acked-by: quintela1 <quintela@redhat.com>
719b13
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
719b13
RH-Acked-by: Peter Xu <peterx@redhat.com>
719b13
719b13
Migration with zero-copy-send currently has it's limitations, as it can't
719b13
be used with TLS nor any kind of compression. In such scenarios, it should
719b13
output errors during parameter / capability setting.
719b13
719b13
But currently there are some ways of setting this not-supported scenarios
719b13
without printing the error message:
719b13
719b13
!) For 'compression' capability, it works by enabling it together with
719b13
zero-copy-send. This happens because the validity test for zero-copy uses
719b13
the helper unction migrate_use_compression(), which check for compression
719b13
presence in s->enabled_capabilities[MIGRATION_CAPABILITY_COMPRESS].
719b13
719b13
The point here is: the validity test happens before the capability gets
719b13
enabled. If all of them get enabled together, this test will not return
719b13
error.
719b13
719b13
In order to fix that, replace migrate_use_compression() by directly testing
719b13
the cap_list parameter migrate_caps_check().
719b13
719b13
2) For features enabled by parameters such as TLS & 'multifd_compression',
719b13
there was also a possibility of setting non-supported scenarios: setting
719b13
zero-copy-send first, then setting the unsupported parameter.
719b13
719b13
In order to fix that, also add a check for parameters conflicting with
719b13
zero-copy-send on migrate_params_check().
719b13
719b13
3) XBZRLE is also a compression capability, so it makes sense to also add
719b13
it to the list of capabilities which are not supported with zero-copy-send.
719b13
719b13
Fixes: 1abaec9a1b2c ("migration: Change zero_copy_send from migration parameter to migration capability")
719b13
Signed-off-by: Leonardo Bras <leobras@redhat.com>
719b13
Message-Id: <20220719122345.253713-1-leobras@redhat.com>
719b13
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
719b13
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
719b13
(cherry picked from commit 90eb69e4f1a16b388d0483543bf6bfc69a9966e4)
719b13
Signed-off-by: Leonardo Bras <leobras@redhat.com>
719b13
---
719b13
 migration/migration.c | 15 ++++++++++++++-
719b13
 1 file changed, 14 insertions(+), 1 deletion(-)
719b13
719b13
diff --git a/migration/migration.c b/migration/migration.c
719b13
index a3e0ac954c..b1fe50a749 100644
719b13
--- a/migration/migration.c
719b13
+++ b/migration/migration.c
719b13
@@ -1254,7 +1254,9 @@ static bool migrate_caps_check(bool *cap_list,
719b13
 #ifdef CONFIG_LINUX
719b13
     if (cap_list[MIGRATION_CAPABILITY_ZERO_COPY_SEND] &&
719b13
         (!cap_list[MIGRATION_CAPABILITY_MULTIFD] ||
719b13
-         migrate_use_compression() ||
719b13
+         cap_list[MIGRATION_CAPABILITY_COMPRESS] ||
719b13
+         cap_list[MIGRATION_CAPABILITY_XBZRLE] ||
719b13
+         migrate_multifd_compression() ||
719b13
          migrate_use_tls())) {
719b13
         error_setg(errp,
719b13
                    "Zero copy only available for non-compressed non-TLS multifd migration");
719b13
@@ -1491,6 +1493,17 @@ 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
+
719b13
+#ifdef CONFIG_LINUX
719b13
+    if (migrate_use_zero_copy_send() &&
719b13
+        ((params->has_multifd_compression && params->multifd_compression) ||
719b13
+         (params->has_tls_creds && 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
+
719b13
     return true;
719b13
 }
719b13
 
719b13
-- 
719b13
2.35.3
719b13