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