@@ -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);
/**
@@ -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 {
@@ -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;
@@ -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"
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(-)