diff mbox series

[v1,6/7] migration/tls: add support for multifd tls-handshake

Message ID 1599663177-53993-7-git-send-email-zhengchuan@huawei.com
State New
Headers show
Series *** Add Multifd support for TLS migration *** | expand

Commit Message

Zheng Chuan Sept. 9, 2020, 2:52 p.m. UTC
add support for multifd tls-handshake

Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>
Signed-off-by: Yan Jin <jinyan12@huawei.com>
---
 migration/multifd.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/migration/multifd.c b/migration/multifd.c
index b2076d7..2509187 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -719,11 +719,41 @@  out:
     return NULL;
 }
 
+static bool multifd_channel_connect(MultiFDSendParams *p,
+                                    QIOChannel *ioc,
+                                    Error *error);
+
+static void multifd_tls_outgoing_handshake(QIOTask *task,
+                                           gpointer opaque)
+{
+    MultiFDSendParams *p = opaque;
+    QIOChannel *ioc = QIO_CHANNEL(qio_task_get_source(task));
+    Error *err = NULL;
+
+    qio_task_propagate_error(task, &err);
+    multifd_channel_connect(p, ioc, err);
+}
+
 static void multifd_tls_channel_connect(MultiFDSendParams *p,
                                     QIOChannel *ioc,
                                     Error **errp)
 {
-    /* TODO */
+    MigrationState *s = p->s;
+    const char *hostname = s->hostname;
+    QIOChannelTLS *tioc;
+
+    tioc = migration_tls_client_create(s, ioc, hostname, errp);
+    if (!tioc) {
+        return;
+    }
+
+    qio_channel_set_name(QIO_CHANNEL(tioc), "multifd-tls-outgoing");
+    qio_channel_tls_handshake(tioc,
+                              multifd_tls_outgoing_handshake,
+                              p,
+                              NULL,
+                              NULL);
+
 }
 
 static bool multifd_channel_connect(MultiFDSendParams *p,