[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 13/16] migration: Add migrate_use_tls() helper
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PULL 13/16] migration: Add migrate_use_tls() helper |
Date: |
Mon, 9 May 2022 16:02:50 +0100 |
From: Leonardo Bras <leobras@redhat.com>
A lot of places check parameters.tls_creds in order to evaluate if TLS is
in use, and sometimes call migrate_get_current() just for that test.
Add new helper function migrate_use_tls() in order to simplify testing
for TLS usage.
Signed-off-by: Leonardo Bras <leobras@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20220507015759.840466-5-leobras@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
migration/channel.c | 3 +--
migration/migration.c | 9 +++++++++
migration/migration.h | 1 +
migration/multifd.c | 5 +----
4 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/migration/channel.c b/migration/channel.c
index c6a8dcf1d7..a162d00fea 100644
--- a/migration/channel.c
+++ b/migration/channel.c
@@ -38,8 +38,7 @@ void migration_channel_process_incoming(QIOChannel *ioc)
trace_migration_set_incoming_channel(
ioc, object_get_typename(OBJECT(ioc)));
- if (s->parameters.tls_creds &&
- *s->parameters.tls_creds &&
+ if (migrate_use_tls() &&
!object_dynamic_cast(OBJECT(ioc),
TYPE_QIO_CHANNEL_TLS)) {
migration_tls_channel_process_incoming(s, ioc, &local_err);
diff --git a/migration/migration.c b/migration/migration.c
index 3e91f4b5e2..4b6df2eb5e 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2588,6 +2588,15 @@ bool migrate_use_zero_copy_send(void)
}
#endif
+int migrate_use_tls(void)
+{
+ MigrationState *s;
+
+ s = migrate_get_current();
+
+ return s->parameters.tls_creds && *s->parameters.tls_creds;
+}
+
int migrate_use_xbzrle(void)
{
MigrationState *s;
diff --git a/migration/migration.h b/migration/migration.h
index e8f2941a55..485d58b95f 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -380,6 +380,7 @@ bool migrate_use_zero_copy_send(void);
#else
#define migrate_use_zero_copy_send() (false)
#endif
+int migrate_use_tls(void);
int migrate_use_xbzrle(void);
uint64_t migrate_xbzrle_cache_size(void);
bool migrate_colo_enabled(void);
diff --git a/migration/multifd.c b/migration/multifd.c
index 9ea4f581e2..2a8c8570c3 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -782,15 +782,12 @@ static bool multifd_channel_connect(MultiFDSendParams *p,
QIOChannel *ioc,
Error *error)
{
- MigrationState *s = migrate_get_current();
-
trace_multifd_set_outgoing_channel(
ioc, object_get_typename(OBJECT(ioc)),
migrate_get_current()->hostname, error);
if (!error) {
- if (s->parameters.tls_creds &&
- *s->parameters.tls_creds &&
+ if (migrate_use_tls() &&
!object_dynamic_cast(OBJECT(ioc),
TYPE_QIO_CHANNEL_TLS)) {
multifd_tls_channel_connect(p, ioc, &error);
--
2.36.0
- [PULL 00/16] migration queue, Dr. David Alan Gilbert (git), 2022/05/09
- [PULL 02/16] tests: add more helper macros for creating TLS x509 certs, Dr. David Alan Gilbert (git), 2022/05/09
- [PULL 06/16] tests: convert multifd migration tests to use common helper, Dr. David Alan Gilbert (git), 2022/05/09
- [PULL 04/16] tests: add migration tests of TLS with x509 credentials, Dr. David Alan Gilbert (git), 2022/05/09
- [PULL 01/16] tests: fix encoding of IP addresses in x509 certs, Dr. David Alan Gilbert (git), 2022/05/09
- [PULL 07/16] tests: add multifd migration tests of TLS with PSK credentials, Dr. David Alan Gilbert (git), 2022/05/09
- [PULL 05/16] tests: convert XBZRLE migration test to use common helper, Dr. David Alan Gilbert (git), 2022/05/09
- [PULL 13/16] migration: Add migrate_use_tls() helper,
Dr. David Alan Gilbert (git) <=
- [PULL 03/16] tests: add migration tests of TLS with PSK credentials, Dr. David Alan Gilbert (git), 2022/05/09
- [PULL 14/16] multifd: multifd_send_sync_main now returns negative on error, Dr. David Alan Gilbert (git), 2022/05/09
- [PULL 09/16] tests: ensure migration status isn't reported as failed, Dr. David Alan Gilbert (git), 2022/05/09
- [PULL 12/16] migration: Add zero-copy-send parameter for QMP/HMP for Linux, Dr. David Alan Gilbert (git), 2022/05/09
- [PULL 08/16] tests: add multifd migration tests of TLS with x509 credentials, Dr. David Alan Gilbert (git), 2022/05/09
- [PULL 10/16] QIOChannel: Add flags on io_writev and introduce io_flush callback, Dr. David Alan Gilbert (git), 2022/05/09
- [PULL 15/16] multifd: Send header packet without flags if zero-copy-send is enabled, Dr. David Alan Gilbert (git), 2022/05/09