From: Avihai Horon <avihaih@nvidia.com>
To: <qemu-devel@nongnu.org>
Cc: Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>,
"Avihai Horon" <avihaih@nvidia.com>
Subject: [PATCH 08/17] migration: Use the new TLS upgrade API for main channel
Date: Thu, 25 Jan 2024 18:25:19 +0200 [thread overview]
Message-ID: <20240125162528.7552-9-avihaih@nvidia.com> (raw)
In-Reply-To: <20240125162528.7552-1-avihaih@nvidia.com>
Use the new TLS upgrade API for main migration channel and remove the
old TLS code.
Signed-off-by: Avihai Horon <avihaih@nvidia.com>
---
migration/tls.h | 3 ---
migration/channel.c | 24 +++++++++++++++++-------
migration/tls.c | 36 ------------------------------------
migration/trace-events | 3 ---
4 files changed, 17 insertions(+), 49 deletions(-)
diff --git a/migration/tls.h b/migration/tls.h
index 514529ff38..a6babbfa14 100644
--- a/migration/tls.h
+++ b/migration/tls.h
@@ -32,9 +32,6 @@ QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc,
const char *hostname,
Error **errp);
-void migration_tls_channel_connect_main(MigrationState *s, QIOChannel *ioc,
- const char *hostname, Error **errp);
-
typedef void (*MigTLSConCallback)(QIOChannel *ioc, void *opaque, Error *err);
/**
diff --git a/migration/channel.c b/migration/channel.c
index 041a63eb21..4022b2c9b8 100644
--- a/migration/channel.c
+++ b/migration/channel.c
@@ -50,6 +50,14 @@ void migration_channel_process_incoming(QIOChannel *ioc)
}
}
+static void migration_channel_tls_handshake_main(QIOChannel *ioc, void *opaque,
+ Error *err)
+{
+ MigrationState *s = opaque;
+
+ migration_channel_connect(s, ioc, NULL, err);
+ object_unref(OBJECT(ioc));
+}
/**
* @migration_channel_connect - Create new outgoing migration channel
@@ -69,14 +77,16 @@ void migration_channel_connect(MigrationState *s,
if (!error) {
if (migrate_channel_requires_tls_upgrade(ioc)) {
- migration_tls_channel_connect_main(s, ioc, hostname, &error);
-
- if (!error) {
- /* tls_channel_connect will call back to this
- * function after the TLS handshake,
- * so we mustn't call migrate_fd_connect until then
+ /* Save hostname into MigrationState for handshake */
+ s->hostname = g_strdup(hostname);
+ if (migration_tls_channel_connect(
+ ioc, "main", hostname, migration_channel_tls_handshake_main,
+ s, false, &error)) {
+ /*
+ * migration_channel_tls_handshake_main will call back to this
+ * function after the TLS handshake, so we mustn't call
+ * migrate_fd_connect until then.
*/
-
return;
}
} else {
diff --git a/migration/tls.c b/migration/tls.c
index e6a0349bd1..99c71e4fb6 100644
--- a/migration/tls.c
+++ b/migration/tls.c
@@ -97,24 +97,6 @@ void migration_tls_channel_process_incoming(MigrationState *s,
NULL);
}
-
-static void migration_tls_outgoing_handshake_main(QIOTask *task,
- gpointer opaque)
-{
- MigrationState *s = opaque;
- QIOChannel *ioc = QIO_CHANNEL(qio_task_get_source(task));
- Error *err = NULL;
-
- if (qio_task_propagate_error(task, &err)) {
- trace_migration_tls_outgoing_handshake_main_error(
- error_get_pretty(err));
- } else {
- trace_migration_tls_outgoing_handshake_main_complete();
- }
- migration_channel_connect(s, ioc, NULL, err);
- object_unref(OBJECT(ioc));
-}
-
QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc,
const char *hostname,
Error **errp)
@@ -134,24 +116,6 @@ QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc,
return qio_channel_tls_new_client(ioc, creds, hostname, errp);
}
-void migration_tls_channel_connect_main(MigrationState *s, QIOChannel *ioc,
- const char *hostname, Error **errp)
-{
- QIOChannelTLS *tioc;
-
- tioc = migration_tls_client_create(ioc, hostname, errp);
- if (!tioc) {
- return;
- }
-
- /* Save hostname into MigrationState for handshake */
- s->hostname = g_strdup(hostname);
- trace_migration_tls_outgoing_handshake_main_start(hostname);
- qio_channel_set_name(QIO_CHANNEL(tioc), "migration-tls-outgoing");
- qio_channel_tls_handshake(tioc, migration_tls_outgoing_handshake_main, s,
- NULL, NULL);
-}
-
typedef struct {
QIOChannelTLS *tioc;
MigTLSConCallback callback;
diff --git a/migration/trace-events b/migration/trace-events
index 09dd342d37..80c3c20faa 100644
--- a/migration/trace-events
+++ b/migration/trace-events
@@ -325,9 +325,6 @@ migration_socket_outgoing_connected(const char *hostname) "hostname=%s"
migration_socket_outgoing_error(const char *err) "error=%s"
# tls.c
-migration_tls_outgoing_handshake_main_start(const char *hostname) "hostname=%s"
-migration_tls_outgoing_handshake_main_error(const char *err) "err=%s"
-migration_tls_outgoing_handshake_main_complete(void) ""
migration_tls_outgoing_handshake_start(const char *hostname, const char *name) "hostname=%s, name=%s"
migration_tls_outgoing_handshake_error(const char *name, const char *err) "name=%s, err=%s"
migration_tls_outgoing_handshake_complete(const char *name) "name=%s"
--
2.26.3
next prev parent reply other threads:[~2024-01-25 16:26 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-25 16:25 [PATCH 00/17] migration: Add new migration channel connect and TLS upgrade APIs Avihai Horon
2024-01-25 16:25 ` [PATCH 01/17] migration: Fix logic of channels and transport compatibility check Avihai Horon
2024-01-26 3:09 ` Peter Xu
2024-01-25 16:25 ` [PATCH 02/17] migration: Move local_err check in migration_ioc_process_incoming() Avihai Horon
2024-01-26 3:10 ` Peter Xu
2024-01-25 16:25 ` [PATCH 03/17] migration: Rename default_channel to main_channel Avihai Horon
2024-01-26 3:11 ` Peter Xu
2024-01-25 16:25 ` [PATCH 04/17] migration/multifd: Set p->running = true in the right place Avihai Horon
2024-01-25 20:57 ` Fabiano Rosas
2024-01-28 15:43 ` Avihai Horon
2024-01-29 4:17 ` Peter Xu
2024-01-29 12:20 ` Avihai Horon
2024-01-30 5:57 ` Peter Xu
2024-01-30 18:44 ` Avihai Horon
2024-02-06 10:25 ` Peter Xu
2024-02-08 15:31 ` Avihai Horon
2024-01-29 12:23 ` Fabiano Rosas
2024-01-25 16:25 ` [PATCH 05/17] migration/multifd: Wait for multifd channels creation before proceeding Avihai Horon
2024-01-29 14:34 ` Fabiano Rosas
2024-01-30 18:32 ` Avihai Horon
2024-01-30 21:32 ` Fabiano Rosas
2024-01-31 4:49 ` Peter Xu
2024-01-31 10:39 ` Avihai Horon
2024-01-25 16:25 ` [PATCH 06/17] migration/tls: Rename main migration channel TLS functions Avihai Horon
2024-01-25 16:25 ` [PATCH 07/17] migration/tls: Add new migration channel TLS upgrade API Avihai Horon
2024-01-25 16:25 ` Avihai Horon [this message]
2024-01-25 16:25 ` [PATCH 09/17] migration/multifd: Use the new TLS upgrade API for multifd channels Avihai Horon
2024-01-25 16:25 ` [PATCH 10/17] migration/postcopy: Use the new TLS upgrade API for preempt channel Avihai Horon
2024-01-25 16:25 ` [PATCH 11/17] migration/tls: Make migration_tls_client_create() static Avihai Horon
2024-01-25 16:25 ` [PATCH 12/17] migration/multifd: Consolidate TLS/non-TLS multifd channel error flow Avihai Horon
2024-01-25 16:25 ` [PATCH 13/17] migration: Store MigrationAddress in MigrationState Avihai Horon
2024-01-25 16:25 ` [PATCH 14/17] migration: Rename migration_channel_connect() Avihai Horon
2024-01-25 16:25 ` [PATCH 15/17] migration: Add new migration channel connect API Avihai Horon
2024-01-25 16:25 ` [PATCH 16/17] migration/multifd: Use the new migration channel connect API for multifd Avihai Horon
2024-01-25 16:25 ` [PATCH 17/17] migration/postcopy: Use the new migration channel connect API for postcopy preempt Avihai Horon
2024-02-06 10:04 ` [PATCH 00/17] migration: Add new migration channel connect and TLS upgrade APIs Peter Xu
2024-02-06 13:10 ` Avihai Horon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240125162528.7552-9-avihaih@nvidia.com \
--to=avihaih@nvidia.com \
--cc=farosas@suse.de \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).