@@ -794,22 +794,17 @@ static bool multifd_channel_connect(MultiFDSendParams *p,
QIOChannel *ioc,
Error **errp);
-static void multifd_tls_outgoing_handshake(QIOTask *task,
- gpointer opaque)
+static void multifd_tls_outgoing_handshake(QIOChannel *ioc, gpointer opaque,
+ Error *err)
{
MultiFDSendParams *p = opaque;
- QIOChannel *ioc = QIO_CHANNEL(qio_task_get_source(task));
- Error *err = NULL;
- if (!qio_task_propagate_error(task, &err)) {
- trace_multifd_tls_outgoing_handshake_complete(ioc);
+ if (!err) {
if (multifd_channel_connect(p, ioc, &err)) {
return;
}
}
- trace_multifd_tls_outgoing_handshake_error(ioc, error_get_pretty(err));
-
migrate_set_error(migrate_get_current(), err);
/*
* Error happen, mark multifd_send_thread status as 'quit' although it
@@ -820,59 +815,30 @@ static void multifd_tls_outgoing_handshake(QIOTask *task,
qemu_sem_post(&p->sem_sync);
qemu_sem_post(&p->create_sem);
error_free(err);
-}
-
-static void *multifd_tls_handshake_thread(void *opaque)
-{
- MultiFDSendParams *p = opaque;
- QIOChannelTLS *tioc = QIO_CHANNEL_TLS(p->c);
-
- qio_channel_tls_handshake(tioc,
- multifd_tls_outgoing_handshake,
- p,
- NULL,
- NULL);
- return NULL;
-}
-
-static bool multifd_tls_channel_connect(MultiFDSendParams *p,
- QIOChannel *ioc,
- Error **errp)
-{
- MigrationState *s = migrate_get_current();
- const char *hostname = s->hostname;
- QIOChannelTLS *tioc;
-
- tioc = migration_tls_client_create(ioc, hostname, errp);
- if (!tioc) {
- return false;
- }
-
object_unref(OBJECT(ioc));
- trace_multifd_tls_outgoing_handshake_start(ioc, tioc, hostname);
- qio_channel_set_name(QIO_CHANNEL(tioc), "multifd-tls-outgoing");
- p->c = QIO_CHANNEL(tioc);
- qemu_thread_create(&p->thread, "multifd-tls-handshake-worker",
- multifd_tls_handshake_thread, p,
- QEMU_THREAD_JOINABLE);
- return true;
}
static bool multifd_channel_connect(MultiFDSendParams *p,
QIOChannel *ioc,
Error **errp)
{
- trace_multifd_set_outgoing_channel(
- ioc, object_get_typename(OBJECT(ioc)),
- migrate_get_current()->hostname);
+ MigrationState *s = migrate_get_current();
+
+ trace_multifd_set_outgoing_channel(ioc, object_get_typename(OBJECT(ioc)),
+ s->hostname);
if (migrate_channel_requires_tls_upgrade(ioc)) {
/*
- * tls_channel_connect will call back to this
- * function after the TLS handshake,
- * so we mustn't call multifd_send_thread until then
+ * multifd_tls_outgoing_handshake will call back to this function after
+ * the TLS handshake, so we mustn't call multifd_send_thread until then.
*/
- return multifd_tls_channel_connect(p, ioc, errp);
+ if (migration_tls_channel_connect(ioc, p->name, s->hostname,
+ multifd_tls_outgoing_handshake, p,
+ true, errp)) {
+ object_unref(OBJECT(ioc));
+ return true;
+ }
+ return false;
}
qio_channel_set_delay(ioc, false);
@@ -144,9 +144,6 @@ multifd_send_sync_main_wait(uint8_t id) "channel %u"
multifd_send_terminate_threads(bool error) "error %d"
multifd_send_thread_end(uint8_t id, uint64_t packets, uint64_t normal_pages) "channel %u packets %" PRIu64 " normal pages %" PRIu64
multifd_send_thread_start(uint8_t id) "%u"
-multifd_tls_outgoing_handshake_start(void *ioc, void *tioc, const char *hostname) "ioc=%p tioc=%p hostname=%s"
-multifd_tls_outgoing_handshake_error(void *ioc, const char *err) "ioc=%p err=%s"
-multifd_tls_outgoing_handshake_complete(void *ioc) "ioc=%p"
multifd_set_outgoing_channel(void *ioc, const char *ioctype, const char *hostname) "ioc=%p ioctype=%s hostname=%s"
# migration.c
Use the new TLS upgrade API for multifd channels and remove the old TLS code. Note that p->c is now set only after a successful TLS connection, so need to call object_unref() on QIOChannelTLS in case of error in multifd_tls_outgoing_handshake() (previously it was done in multifd_save_cleanup()). Signed-off-by: Avihai Horon <avihaih@nvidia.com> --- migration/multifd.c | 66 ++++++++++-------------------------------- migration/trace-events | 3 -- 2 files changed, 16 insertions(+), 53 deletions(-)