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

586cba
From 0753565af588dfa78b3529e359b1590e15fcbdb3 Mon Sep 17 00:00:00 2001
586cba
From: Leonardo Bras <leobras@redhat.com>
586cba
Date: Tue, 19 Jul 2022 09:23:45 -0300
586cba
Subject: [PATCH 04/11] migration: Avoid false-positive on non-supported
586cba
 scenarios for zero-copy-send
586cba
MIME-Version: 1.0
586cba
Content-Type: text/plain; charset=UTF-8
586cba
Content-Transfer-Encoding: 8bit
586cba
586cba
RH-Author: Leonardo BrĂ¡s <leobras@redhat.com>
586cba
RH-MergeRequest: 111: zero-copy-send fixes & improvements
586cba
RH-Commit: [4/6] f5c7ed6710d92668acb81d0118a71fab0b4e3d43 (LeoBras/centos-qemu-kvm)
586cba
RH-Bugzilla: 2107466
586cba
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
586cba
RH-Acked-by: Thomas Huth <thuth@redhat.com>
586cba
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
586cba
586cba
Migration with zero-copy-send currently has it's limitations, as it can't
586cba
be used with TLS nor any kind of compression. In such scenarios, it should
586cba
output errors during parameter / capability setting.
586cba
586cba
But currently there are some ways of setting this not-supported scenarios
586cba
without printing the error message:
586cba
586cba
!) For 'compression' capability, it works by enabling it together with
586cba
zero-copy-send. This happens because the validity test for zero-copy uses
586cba
the helper unction migrate_use_compression(), which check for compression
586cba
presence in s->enabled_capabilities[MIGRATION_CAPABILITY_COMPRESS].
586cba
586cba
The point here is: the validity test happens before the capability gets
586cba
enabled. If all of them get enabled together, this test will not return
586cba
error.
586cba
586cba
In order to fix that, replace migrate_use_compression() by directly testing
586cba
the cap_list parameter migrate_caps_check().
586cba
586cba
2) For features enabled by parameters such as TLS & 'multifd_compression',
586cba
there was also a possibility of setting non-supported scenarios: setting
586cba
zero-copy-send first, then setting the unsupported parameter.
586cba
586cba
In order to fix that, also add a check for parameters conflicting with
586cba
zero-copy-send on migrate_params_check().
586cba
586cba
3) XBZRLE is also a compression capability, so it makes sense to also add
586cba
it to the list of capabilities which are not supported with zero-copy-send.
586cba
586cba
Fixes: 1abaec9a1b2c ("migration: Change zero_copy_send from migration parameter to migration capability")
586cba
Signed-off-by: Leonardo Bras <leobras@redhat.com>
586cba
Message-Id: <20220719122345.253713-1-leobras@redhat.com>
586cba
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
586cba
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
586cba
(cherry picked from commit 90eb69e4f1a16b388d0483543bf6bfc69a9966e4)
586cba
Signed-off-by: Leonardo Bras <leobras@redhat.com>
586cba
---
586cba
 migration/migration.c | 15 ++++++++++++++-
586cba
 1 file changed, 14 insertions(+), 1 deletion(-)
586cba
586cba
diff --git a/migration/migration.c b/migration/migration.c
586cba
index 3a3a7a4a50..343629d59c 100644
586cba
--- a/migration/migration.c
586cba
+++ b/migration/migration.c
586cba
@@ -1265,7 +1265,9 @@ static bool migrate_caps_check(bool *cap_list,
586cba
 #ifdef CONFIG_LINUX
586cba
     if (cap_list[MIGRATION_CAPABILITY_ZERO_COPY_SEND] &&
586cba
         (!cap_list[MIGRATION_CAPABILITY_MULTIFD] ||
586cba
-         migrate_use_compression() ||
586cba
+         cap_list[MIGRATION_CAPABILITY_COMPRESS] ||
586cba
+         cap_list[MIGRATION_CAPABILITY_XBZRLE] ||
586cba
+         migrate_multifd_compression() ||
586cba
          migrate_use_tls())) {
586cba
         error_setg(errp,
586cba
                    "Zero copy only available for non-compressed non-TLS multifd migration");
586cba
@@ -1502,6 +1504,17 @@ static bool migrate_params_check(MigrationParameters *params, Error **errp)
586cba
         error_prepend(errp, "Invalid mapping given for block-bitmap-mapping: ");
586cba
         return false;
586cba
     }
586cba
+
586cba
+#ifdef CONFIG_LINUX
586cba
+    if (migrate_use_zero_copy_send() &&
586cba
+        ((params->has_multifd_compression && params->multifd_compression) ||
586cba
+         (params->has_tls_creds && params->tls_creds && *params->tls_creds))) {
586cba
+        error_setg(errp,
586cba
+                   "Zero copy only available for non-compressed non-TLS multifd migration");
586cba
+        return false;
586cba
+    }
586cba
+#endif
586cba
+
586cba
     return true;
586cba
 }
586cba
 
586cba
-- 
586cba
2.31.1
586cba