Skip to content

Commit

Permalink
migration/multifd: Join the TLS thread
Browse files Browse the repository at this point in the history
We're currently leaking the resources of the TLS thread by not joining
it and also overwriting the p->thread pointer altogether.

Fixes: a1af605 ("migration/multifd: fix hangup with TLS-Multifd due to blocking handshake")
Cc: qemu-stable <qemu-stable@nongnu.org>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20240206215118.6171-2-farosas@suse.de
Signed-off-by: Peter Xu <peterx@redhat.com>
  • Loading branch information
Fabiano Rosas authored and xzpeter committed Feb 7, 2024
1 parent 3205beb commit e1921f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion migration/multifd.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,10 @@ static void multifd_send_terminate_threads(void)
for (i = 0; i < migrate_multifd_channels(); i++) {
MultiFDSendParams *p = &multifd_send_state->params[i];

if (p->tls_thread_created) {
qemu_thread_join(&p->tls_thread);
}

if (p->running) {
qemu_thread_join(&p->thread);
}
Expand Down Expand Up @@ -921,7 +925,9 @@ static bool multifd_tls_channel_connect(MultiFDSendParams *p,
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",

p->tls_thread_created = true;
qemu_thread_create(&p->tls_thread, "multifd-tls-handshake-worker",
multifd_tls_handshake_thread, p,
QEMU_THREAD_JOINABLE);
return true;
Expand Down
2 changes: 2 additions & 0 deletions migration/multifd.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ typedef struct {
char *name;
/* channel thread id */
QemuThread thread;
QemuThread tls_thread;
bool tls_thread_created;
/* communication channel */
QIOChannel *c;
/* is the yank function registered */
Expand Down

0 comments on commit e1921f1

Please sign in to comment.