Migration: fix missing iothread locking
PATCH 1/2 migration: block-dirty-bitmap: add missing qemu_mutex_lock_iothread
In reply to Emanuele Giuseppe Espositoinit_dirty_bitmap_migration assumes the iothread lock (BQL) to be held, but instead it isn't.
Instead of adding the lock to qemu_savevm_state_setup(), follow the same pattern as the other ->save_setup callbacks and lock+unlock inside dirty_bitmap_save_setup().
--- migration/block-dirty-bitmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
migration/block-dirty-bitmap.c +4 -1
@@ -1215,7 +1215,10 @@ static int dirty_bitmap_save_setup(QEMUFile *f, void *opaque) {DBMSaveState *s = &((DBMState *)opaque)->save;SaveBitmapState *dbms =NULL ; + +qemu_mutex_lock_iothread ();if (init_dirty_bitmap_migration (s) <0 ) { +qemu_mutex_unlock_iothread ();return -1 ; }
@@ -1223,7 +1226,7 @@ static int dirty_bitmap_save_setup(QEMUFile *f, void *opaque)send_bitmap_start (f, s, dbms); }qemu_put_bitmap_flags (f,DIRTY_BITMAP_MIG_FLAG_EOS ); - +qemu_mutex_unlock_iothread ();return 0 ; }
Signature · 1 line
2.27.0
cover Migration: fix missing iothread locking
Some functions (in this case qemu_savevm_state_complete_postcopy() and init_dirty_bitmap_migration()) assume and document that qemu_mutex_lock_iothread() is hold.
This seems to have been forgotten in some places, and this series aims to fix that.
Patch 1 was part of my RFC block layer series "block layer: split block APIs in graph and I/O" but I decided to do a separate series for these two bugs, as they are independent from the API split.
Emanuele Giuseppe Esposito (2):
migration: block-dirty-bitmap: add missing qemu_mutex_lock_iothread
migration: add missing qemu_mutex_lock_iothread in
migration_completion
migration/block-dirty-bitmap.c | 5 ++++- migration/migration.c | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-)
Signature · 1 line
2.27.0
PATCH 2/2 migration: add missing qemu_mutex_lock_iothread in migration_completion
qemu_savevm_state_complete_postcopy assumes the iothread lock (BQL) to be held, but instead it isn't.
--- migration/migration.c | 3 +++ 1 file changed, 3 insertions(+)
migration/migration.c +3 -0
@@ -3182,7 +3182,10 @@ static void migration_completion(MigrationState *s) }else if (s->state ==MIGRATION_STATUS_POSTCOPY_ACTIVE ) {trace_migration_completion_postcopy_end (); +qemu_mutex_lock_iothread ();qemu_savevm_state_complete_postcopy (s->to_dst_file); +qemu_mutex_unlock_iothread (); +trace_migration_completion_postcopy_end_after_complete (); }else if (s->state ==MIGRATION_STATUS_CANCELLING ) { goto fail;
Signature · 1 line
2.27.0
Re: [PATCH v1 2/2] migration: add missing qemu_mutex_lock_iothread in migration_completion
Quoted 4 lines · * Emanuele Giuseppe Esposito ([email protected]) wrote:
qemu_savevm_state_complete_postcopyassumes the iothread lock (BQL) to be held, but instead it isn't.Signed-off-by Emanuele Giuseppe Esposito <[email protected]>
Interesting, I think you're right - and I think it's been missing it from the start.
Quoted 22 lines
--- migration/migration.c | 3 +++ 1 file changed, 3 insertions(+)migration/migration.c +3
-0@@ -3182,7 +3182,10 @@ static void migration_completion(MigrationState *s) }else if (s->state ==MIGRATION_STATUS_POSTCOPY_ACTIVE ) {trace_migration_completion_postcopy_end (); +qemu_mutex_lock_iothread ();qemu_savevm_state_complete_postcopy (s->to_dst_file); +qemu_mutex_unlock_iothread (); +trace_migration_completion_postcopy_end_after_complete (); }else if (s->state ==MIGRATION_STATUS_CANCELLING ) { goto fail;Signature · 1 line
2.27.0
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [PATCH v1 1/2] migration: block-dirty-bitmap: add missing qemu_mutex_lock_iothread
In reply to Emanuele Giuseppe EspositoQuoted 9 lines · Emanuele Giuseppe Esposito
init_dirty_bitmap_migrationassumes the iothread lock (BQL) to be held, but instead it isn't.Instead of adding the lock to
qemu_savevm_state_setup(), follow the same pattern as the other ->save_setup callbacks and lock+unlock insidedirty_bitmap_save_setup().Signed-off-by Emanuele Giuseppe Esposito <[email protected]>Reviewed-by Stefan Hajnoczi <[email protected]>
queued.
Re: [PATCH v1 1/2] migration: block-dirty-bitmap: add missing qemu_mutex_lock_iothread
Quoted 4 lines · Juan Quintela
Quoted 3 lines · Emanuele Giuseppe Esposito
init_dirty_bitmap_migrationassumes the iothread lock (BQL) to be held, but instead it isn't.
Quoted 8 lines
Quoted 6 lines
Instead of adding the lock to
qemu_savevm_state_setup(), follow the same pattern as the other ->save_setup callbacks and lock+unlock insidedirty_bitmap_save_setup().Signed-off-by Emanuele Giuseppe Esposito <[email protected]>Reviewed-by Stefan Hajnoczi <[email protected]>Reviewed-by Juan Quintela <[email protected]>
And I realized that this patch is already on the tree, just not through the migration tree.
Ignore the noise.
Later, Juan.