[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 37/38] migration/multifd: Unify multifd_send_thread error paths
From: |
Juan Quintela |
Subject: |
[PULL 37/38] migration/multifd: Unify multifd_send_thread error paths |
Date: |
Mon, 16 Oct 2023 12:07:05 +0200 |
From: Fabiano Rosas <farosas@suse.de>
The preferred usage of the Error type is to always set both the return
code and the error when a failure happens. As all code called from the
send thread follows this pattern, we'll always have the return code
and the error set at the same time.
Aside from the convention, in this piece of code this must be the
case, otherwise the if (ret != 0) would be exiting the thread without
calling multifd_send_terminate_threads() which is incorrect.
Unify both paths to make it clear that both are taken when there's an
error.
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20231012134343.23757-3-farosas@suse.de>
---
migration/multifd.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/migration/multifd.c b/migration/multifd.c
index 8e9a5ee394..c92955de41 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -753,19 +753,13 @@ static void *multifd_send_thread(void *opaque)
}
out:
- if (local_err) {
+ if (ret) {
+ assert(local_err);
trace_multifd_send_error(p->id);
multifd_send_terminate_threads(local_err);
- error_free(local_err);
- }
-
- /*
- * Error happen, I will exit, but I can't just leave, tell
- * who pay attention to me.
- */
- if (ret != 0) {
qemu_sem_post(&p->sem_sync);
qemu_sem_post(&multifd_send_state->channels_ready);
+ error_free(local_err);
}
qemu_mutex_lock(&p->mutex);
--
2.41.0
- [PULL 27/38] migration: Improve json and formatting, (continued)
- [PULL 27/38] migration: Improve json and formatting, Juan Quintela, 2023/10/16
- [PULL 28/38] migration: check for rate_limit_max for RATE_LIMIT_DISABLED, Juan Quintela, 2023/10/16
- [PULL 31/38] migration/ram: Refactor precopy ram loading code, Juan Quintela, 2023/10/16
- [PULL 32/38] migration/ram: Remove RAMState from xbzrle_cache_zero_page, Juan Quintela, 2023/10/16
- [PULL 29/38] multifd: fix counters in multifd_send_thread, Juan Quintela, 2023/10/16
- [PULL 34/38] migration/ram: Move xbzrle zero page handling into save_zero_page, Juan Quintela, 2023/10/16
- [PULL 30/38] multifd: reset next_packet_len after sending pages, Juan Quintela, 2023/10/16
- [PULL 33/38] migration/ram: Stop passing QEMUFile around in save_zero_page, Juan Quintela, 2023/10/16
- [PULL 36/38] migration/multifd: Remove direct "socket" references, Juan Quintela, 2023/10/16
- [PULL 35/38] migration/ram: Merge save_zero_page functions, Juan Quintela, 2023/10/16
- [PULL 37/38] migration/multifd: Unify multifd_send_thread error paths,
Juan Quintela <=
- [PULL 38/38] migration/multifd: Clarify Error usage in multifd_channel_connect, Juan Quintela, 2023/10/16
- Re: [PULL 00/38] Migration 20231016 patches, Stefan Hajnoczi, 2023/10/16
- Re: [PULL 00/38] Migration 20231016 patches, Juan Quintela, 2023/10/17