thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
1be5c7
From a7c6bc008fe006f005d5c15d3f883572ad5defc5 Mon Sep 17 00:00:00 2001
1be5c7
From: Leonardo Bras <leobras@redhat.com>
1be5c7
Date: Wed, 18 May 2022 02:52:25 -0300
1be5c7
Subject: [PATCH 20/37] migration: Add migrate_use_tls() helper
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: 191: MSG_ZEROCOPY + Multifd @ rhel8.7
1be5c7
RH-Commit: [20/26] 02afc2e60f1abbf6db45d83e54a18b66dad52426
1be5c7
RH-Bugzilla: 2072049
1be5c7
RH-Acked-by: Peter Xu <peterx@redhat.com>
1be5c7
RH-Acked-by: Daniel P. Berrangé <berrange@redhat.com>
1be5c7
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
1be5c7
1be5c7
A lot of places check parameters.tls_creds in order to evaluate if TLS is
1be5c7
in use, and sometimes call migrate_get_current() just for that test.
1be5c7
1be5c7
Add new helper function migrate_use_tls() in order to simplify testing
1be5c7
for TLS usage.
1be5c7
1be5c7
Signed-off-by: Leonardo Bras <leobras@redhat.com>
1be5c7
Reviewed-by: Juan Quintela <quintela@redhat.com>
1be5c7
Reviewed-by: Peter Xu <peterx@redhat.com>
1be5c7
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
1be5c7
Message-Id: <20220513062836.965425-6-leobras@redhat.com>
1be5c7
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
1be5c7
(cherry picked from commit d2fafb6a6814a8998607d0baf691265032996a0f)
1be5c7
Signed-off-by: Leonardo Bras <leobras@redhat.com>
1be5c7
---
1be5c7
 migration/channel.c   | 3 +--
1be5c7
 migration/migration.c | 9 +++++++++
1be5c7
 migration/migration.h | 1 +
1be5c7
 migration/multifd.c   | 5 +----
1be5c7
 4 files changed, 12 insertions(+), 6 deletions(-)
1be5c7
1be5c7
diff --git a/migration/channel.c b/migration/channel.c
1be5c7
index c4fc000a1a..086b5c0d8b 100644
1be5c7
--- a/migration/channel.c
1be5c7
+++ b/migration/channel.c
1be5c7
@@ -38,8 +38,7 @@ void migration_channel_process_incoming(QIOChannel *ioc)
1be5c7
     trace_migration_set_incoming_channel(
1be5c7
         ioc, object_get_typename(OBJECT(ioc)));
1be5c7
 
1be5c7
-    if (s->parameters.tls_creds &&
1be5c7
-        *s->parameters.tls_creds &&
1be5c7
+    if (migrate_use_tls() &&
1be5c7
         !object_dynamic_cast(OBJECT(ioc),
1be5c7
                              TYPE_QIO_CHANNEL_TLS)) {
1be5c7
         migration_tls_channel_process_incoming(s, ioc, &local_err);
1be5c7
diff --git a/migration/migration.c b/migration/migration.c
1be5c7
index b0fc3f68bd..8e28f2ee41 100644
1be5c7
--- a/migration/migration.c
1be5c7
+++ b/migration/migration.c
1be5c7
@@ -2568,6 +2568,15 @@ bool migrate_use_zero_copy_send(void)
1be5c7
 }
1be5c7
 #endif
1be5c7
 
1be5c7
+int migrate_use_tls(void)
1be5c7
+{
1be5c7
+    MigrationState *s;
1be5c7
+
1be5c7
+    s = migrate_get_current();
1be5c7
+
1be5c7
+    return s->parameters.tls_creds && *s->parameters.tls_creds;
1be5c7
+}
1be5c7
+
1be5c7
 int migrate_use_xbzrle(void)
1be5c7
 {
1be5c7
     MigrationState *s;
1be5c7
diff --git a/migration/migration.h b/migration/migration.h
1be5c7
index 908098939f..9396b7e90a 100644
1be5c7
--- a/migration/migration.h
1be5c7
+++ b/migration/migration.h
1be5c7
@@ -344,6 +344,7 @@ bool migrate_use_zero_copy_send(void);
1be5c7
 #else
1be5c7
 #define migrate_use_zero_copy_send() (false)
1be5c7
 #endif
1be5c7
+int migrate_use_tls(void);
1be5c7
 int migrate_use_xbzrle(void);
1be5c7
 uint64_t migrate_xbzrle_cache_size(void);
1be5c7
 bool migrate_colo_enabled(void);
1be5c7
diff --git a/migration/multifd.c b/migration/multifd.c
1be5c7
index 3725226400..e53811f04a 100644
1be5c7
--- a/migration/multifd.c
1be5c7
+++ b/migration/multifd.c
1be5c7
@@ -789,14 +789,11 @@ static bool multifd_channel_connect(MultiFDSendParams *p,
1be5c7
                                     QIOChannel *ioc,
1be5c7
                                     Error *error)
1be5c7
 {
1be5c7
-    MigrationState *s = migrate_get_current();
1be5c7
-
1be5c7
     trace_multifd_set_outgoing_channel(
1be5c7
         ioc, object_get_typename(OBJECT(ioc)), p->tls_hostname, error);
1be5c7
 
1be5c7
     if (!error) {
1be5c7
-        if (s->parameters.tls_creds &&
1be5c7
-            *s->parameters.tls_creds &&
1be5c7
+        if (migrate_use_tls() &&
1be5c7
             !object_dynamic_cast(OBJECT(ioc),
1be5c7
                                  TYPE_QIO_CHANNEL_TLS)) {
1be5c7
             multifd_tls_channel_connect(p, ioc, &error);
1be5c7
-- 
1be5c7
2.35.3
1be5c7