[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 15/16] migration/postcopy: Release fd before going into 'postcopy-
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PULL 15/16] migration/postcopy: Release fd before going into 'postcopy-pause' |
Date: |
Mon, 26 Oct 2020 16:19:51 +0000 |
From: Peter Xu <peterx@redhat.com>
Logically below race could trigger with the old code:
test program migration thread
------------ ----------------
wait_until('postcopy-pause')
postcopy_pause()
set_state('postcopy-pause')
do_postcopy_recover()
arm s->to_dst_file with new fd
release s->to_dst_file [1]
Here [1] could have released the just-installed recoverying channel. Then the
migration could hang without really resuming.
Instead, it should be very safe to release the fd before setting the state into
'postcopy-pause', because there's no reason for any other thread to touch it
during 'postcopy-active'.
Dave reported a very rare postcopy recovery hang that the migration-test
program waited for the migration to complete in migrate_postcopy_complete().
We do suspect it's the same thing that we're gonna fix here. Hard to tell.
However since we've noticed this, fix this irrelevant of the hang report.
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <20201021212721.440373-6-peterx@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
migration/migration.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index 5421042d4a..627f194b8b 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -3178,9 +3178,6 @@ static MigThrError postcopy_pause(MigrationState *s)
while (true) {
QEMUFile *file;
- migrate_set_state(&s->state, s->state,
- MIGRATION_STATUS_POSTCOPY_PAUSED);
-
/* Current channel is possibly broken. Release it. */
assert(s->to_dst_file);
qemu_mutex_lock(&s->qemu_file_lock);
@@ -3191,6 +3188,9 @@ static MigThrError postcopy_pause(MigrationState *s)
qemu_file_shutdown(file);
qemu_fclose(file);
+ migrate_set_state(&s->state, s->state,
+ MIGRATION_STATUS_POSTCOPY_PAUSED);
+
error_report("Detected IO failure for postcopy. "
"Migration paused.");
--
2.28.0
- [PULL 04/16] migration: Add spaces around operator, (continued)
- [PULL 04/16] migration: Add spaces around operator, Dr. David Alan Gilbert (git), 2020/10/26
- [PULL 05/16] migration: Open brace '{' following struct go on the same line, Dr. David Alan Gilbert (git), 2020/10/26
- [PULL 06/16] migration: Add braces {} for if statement, Dr. David Alan Gilbert (git), 2020/10/26
- [PULL 07/16] migration: Do not initialise statics and globals to 0 or NULL, Dr. David Alan Gilbert (git), 2020/10/26
- [PULL 08/16] migration: Open brace '{' following function declarations go on the next line, Dr. David Alan Gilbert (git), 2020/10/26
- [PULL 09/16] migration: Delete redundant spaces, Dr. David Alan Gilbert (git), 2020/10/26
- [PULL 11/16] migration: Pass incoming state into qemu_ufd_copy_ioctl(), Dr. David Alan Gilbert (git), 2020/10/26
- [PULL 10/16] migration: using trace_ to replace DPRINTF, Dr. David Alan Gilbert (git), 2020/10/26
- [PULL 12/16] migration: Introduce migrate_send_rp_message_req_pages(), Dr. David Alan Gilbert (git), 2020/10/26
- [PULL 13/16] migration: Maintain postcopy faulted addresses, Dr. David Alan Gilbert (git), 2020/10/26
- [PULL 15/16] migration/postcopy: Release fd before going into 'postcopy-pause',
Dr. David Alan Gilbert (git) <=
- [PULL 14/16] migration: Sync requested pages after postcopy recovery, Dr. David Alan Gilbert (git), 2020/10/26
- [PULL 16/16] migration-test: Only hide error if !QTEST_LOG, Dr. David Alan Gilbert (git), 2020/10/26
- Re: [PULL 00/16] migration queue, no-reply, 2020/10/26
- Re: [PULL 00/16] migration queue, Peter Maydell, 2020/10/27
- Re: [PULL 00/16] migration queue, Christian Schoenebeck, 2020/10/31