29b115
From 828f6c106eedcb7a48e551ffda15af56ff92a899 Mon Sep 17 00:00:00 2001
29b115
From: Leonardo Bras <leobras@redhat.com>
29b115
Date: Fri, 13 May 2022 03:28:34 -0300
29b115
Subject: [PATCH 11/18] migration: Add migrate_use_tls() helper
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: [5/11] 06e945297c3b9c0ce5864885aafcdba1e5746bc2 (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
A lot of places check parameters.tls_creds in order to evaluate if TLS is
29b115
in use, and sometimes call migrate_get_current() just for that test.
29b115
29b115
Add new helper function migrate_use_tls() in order to simplify testing
29b115
for TLS usage.
29b115
29b115
Signed-off-by: Leonardo Bras <leobras@redhat.com>
29b115
Reviewed-by: Juan Quintela <quintela@redhat.com>
29b115
Reviewed-by: Peter Xu <peterx@redhat.com>
29b115
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
29b115
Message-Id: <20220513062836.965425-6-leobras@redhat.com>
29b115
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
29b115
(cherry picked from commit d2fafb6a6814a8998607d0baf691265032996a0f)
29b115
Signed-off-by: Leonardo Bras <leobras@redhat.com>
29b115
---
29b115
 migration/channel.c   | 3 +--
29b115
 migration/migration.c | 9 +++++++++
29b115
 migration/migration.h | 1 +
29b115
 migration/multifd.c   | 5 +----
29b115
 4 files changed, 12 insertions(+), 6 deletions(-)
29b115
29b115
diff --git a/migration/channel.c b/migration/channel.c
29b115
index c4fc000a1a..086b5c0d8b 100644
29b115
--- a/migration/channel.c
29b115
+++ b/migration/channel.c
29b115
@@ -38,8 +38,7 @@ void migration_channel_process_incoming(QIOChannel *ioc)
29b115
     trace_migration_set_incoming_channel(
29b115
         ioc, object_get_typename(OBJECT(ioc)));
29b115
 
29b115
-    if (s->parameters.tls_creds &&
29b115
-        *s->parameters.tls_creds &&
29b115
+    if (migrate_use_tls() &&
29b115
         !object_dynamic_cast(OBJECT(ioc),
29b115
                              TYPE_QIO_CHANNEL_TLS)) {
29b115
         migration_tls_channel_process_incoming(s, ioc, &local_err);
29b115
diff --git a/migration/migration.c b/migration/migration.c
29b115
index 0a6b3b9f4d..d91efb66fe 100644
29b115
--- a/migration/migration.c
29b115
+++ b/migration/migration.c
29b115
@@ -2582,6 +2582,15 @@ bool migrate_use_zero_copy_send(void)
29b115
 }
29b115
 #endif
29b115
 
29b115
+int migrate_use_tls(void)
29b115
+{
29b115
+    MigrationState *s;
29b115
+
29b115
+    s = migrate_get_current();
29b115
+
29b115
+    return s->parameters.tls_creds && *s->parameters.tls_creds;
29b115
+}
29b115
+
29b115
 int migrate_use_xbzrle(void)
29b115
 {
29b115
     MigrationState *s;
29b115
diff --git a/migration/migration.h b/migration/migration.h
29b115
index 5bcb7628ef..c2cabb8a14 100644
29b115
--- a/migration/migration.h
29b115
+++ b/migration/migration.h
29b115
@@ -381,6 +381,7 @@ bool migrate_use_zero_copy_send(void);
29b115
 #else
29b115
 #define migrate_use_zero_copy_send() (false)
29b115
 #endif
29b115
+int migrate_use_tls(void);
29b115
 int migrate_use_xbzrle(void);
29b115
 uint64_t migrate_xbzrle_cache_size(void);
29b115
 bool migrate_colo_enabled(void);
29b115
diff --git a/migration/multifd.c b/migration/multifd.c
29b115
index 76b57a7177..43998ad117 100644
29b115
--- a/migration/multifd.c
29b115
+++ b/migration/multifd.c
29b115
@@ -784,14 +784,11 @@ static bool multifd_channel_connect(MultiFDSendParams *p,
29b115
                                     QIOChannel *ioc,
29b115
                                     Error *error)
29b115
 {
29b115
-    MigrationState *s = migrate_get_current();
29b115
-
29b115
     trace_multifd_set_outgoing_channel(
29b115
         ioc, object_get_typename(OBJECT(ioc)), p->tls_hostname, error);
29b115
 
29b115
     if (!error) {
29b115
-        if (s->parameters.tls_creds &&
29b115
-            *s->parameters.tls_creds &&
29b115
+        if (migrate_use_tls() &&
29b115
             !object_dynamic_cast(OBJECT(ioc),
29b115
                                  TYPE_QIO_CHANNEL_TLS)) {
29b115
             multifd_tls_channel_connect(p, ioc, &error);
29b115
-- 
29b115
2.35.3
29b115