[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 04/17] migration/multifd: Set p->running = true in the right plac
From: |
Avihai Horon |
Subject: |
[PATCH 04/17] migration/multifd: Set p->running = true in the right place |
Date: |
Thu, 25 Jan 2024 18:25:15 +0200 |
The commit in the fixes line moved multifd thread creation to a
different location, but forgot to move the p->running = true assignment
as well. Thus, p->running is set to true before multifd thread is
actually created.
p->running is used in multifd_save_cleanup() to decide whether to join
the multifd thread or not.
With TLS, an error in multifd_tls_channel_connect() can lead to a
segmentation fault because p->running is true but p->thread is never
initialized, so multifd_save_cleanup() tries to join an uninitialized
thread.
Fix it by moving p->running = true assignment right after multifd thread
creation. Also move qio_channel_set_delay() to there, as this is where
it used to be originally.
Fixes: 29647140157a ("migration/tls: add support for multifd tls-handshake")
Signed-off-by: Avihai Horon <avihaih@nvidia.com>
---
migration/multifd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/migration/multifd.c b/migration/multifd.c
index 25cbc6dc6b..564e911b6c 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -850,11 +850,13 @@ static bool multifd_channel_connect(MultiFDSendParams *p,
return multifd_tls_channel_connect(p, ioc, errp);
}
+ qio_channel_set_delay(ioc, false);
migration_ioc_register_yank(ioc);
p->registered_yank = true;
p->c = ioc;
qemu_thread_create(&p->thread, p->name, multifd_send_thread, p,
QEMU_THREAD_JOINABLE);
+ p->running = true;
return true;
}
@@ -883,8 +885,6 @@ static void multifd_new_send_channel_async(QIOTask *task,
gpointer opaque)
trace_multifd_new_send_channel_async(p->id);
if (!qio_task_propagate_error(task, &local_err)) {
- qio_channel_set_delay(ioc, false);
- p->running = true;
if (multifd_channel_connect(p, ioc, &local_err)) {
return;
}
--
2.26.3
- [PATCH 00/17] migration: Add new migration channel connect and TLS upgrade APIs, Avihai Horon, 2024/01/25
- [PATCH 01/17] migration: Fix logic of channels and transport compatibility check, Avihai Horon, 2024/01/25
- [PATCH 02/17] migration: Move local_err check in migration_ioc_process_incoming(), Avihai Horon, 2024/01/25
- [PATCH 03/17] migration: Rename default_channel to main_channel, Avihai Horon, 2024/01/25
- [PATCH 10/17] migration/postcopy: Use the new TLS upgrade API for preempt channel, Avihai Horon, 2024/01/25
- [PATCH 11/17] migration/tls: Make migration_tls_client_create() static, Avihai Horon, 2024/01/25
- [PATCH 12/17] migration/multifd: Consolidate TLS/non-TLS multifd channel error flow, Avihai Horon, 2024/01/25
- [PATCH 04/17] migration/multifd: Set p->running = true in the right place,
Avihai Horon <=
- Re: [PATCH 04/17] migration/multifd: Set p->running = true in the right place, Fabiano Rosas, 2024/01/25
- Re: [PATCH 04/17] migration/multifd: Set p->running = true in the right place, Avihai Horon, 2024/01/28
- Re: [PATCH 04/17] migration/multifd: Set p->running = true in the right place, Peter Xu, 2024/01/28
- Re: [PATCH 04/17] migration/multifd: Set p->running = true in the right place, Avihai Horon, 2024/01/29
- Re: [PATCH 04/17] migration/multifd: Set p->running = true in the right place, Peter Xu, 2024/01/30
- Re: [PATCH 04/17] migration/multifd: Set p->running = true in the right place, Avihai Horon, 2024/01/30
- Re: [PATCH 04/17] migration/multifd: Set p->running = true in the right place, Fabiano Rosas, 2024/01/29
[PATCH 05/17] migration/multifd: Wait for multifd channels creation before proceeding, Avihai Horon, 2024/01/25