summary refs log tree commit diff stats
path: root/hw/i2c/omap_i2c.c
diff options
context:
space:
mode:
authorPeter Xu <peterx@redhat.com>2021-07-22 13:58:37 -0400
committerDr. David Alan Gilbert <dgilbert@redhat.com>2021-07-26 12:44:26 +0100
commit53021ea1659b8a9074c6f5eb6c65a4e5dddddaec (patch)
tree51dbcc6e1005135dc8b6a69c7c4c5aa9dfd80e7a /hw/i2c/omap_i2c.c
parent5e32ffd346429b2e92545c425de96d92e88a7498 (diff)
downloadfocaccia-qemu-53021ea1659b8a9074c6f5eb6c65a4e5dddddaec.tar.gz
focaccia-qemu-53021ea1659b8a9074c6f5eb6c65a4e5dddddaec.zip
migration: Fix missing join() of rp_thread
It's possible that the migration thread skip the join() of the rp_thread in
below race and crash on src right at finishing migration:

       migration_thread                     rp_thread
       ----------------                     ---------
    migration_completion()
                                        (before rp_thread quits)
                                        from_dst_file=NULL
                                        [thread got scheduled out]
      s->rp_state.from_dst_file==NULL
        (skip join() of rp_thread)
    migrate_fd_cleanup()
      qemu_fclose(s->to_dst_file)
      yank_unregister_instance()
        assert(yank_find_entry())  <------- crash

It could mostly happen with postcopy, but that shouldn't be required, e.g., I
think it could also trigger with MIGRATION_CAPABILITY_RETURN_PATH set.

It's suspected that above race could be the root cause of a recent (but rare)
migration-test break reported by either Dave or PMM:

https://lore.kernel.org/qemu-devel/YPamXAHwan%2FPPXLf@work-vm/

The issue is: from_dst_file is reset in the rp_thread, so if the thread reset
it to NULL fast enough then the migration thread will assume there's no
rp_thread at all.

This could potentially cause more severe issue (e.g. crash) after the yank code.

Fix it by using a boolean to keep "whether we've created rp_thread".

Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <20210722175841.938739-2-peterx@redhat.com>
Reviewed-by: Lukas Straub <lukasstraub2@web.de>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Diffstat (limited to 'hw/i2c/omap_i2c.c')
0 files changed, 0 insertions, 0 deletions