Skip to content

migrations: Fix potential rare race of migration-test after yank

Peter Xu qemu-devel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest5 patches 4 repliesIn review
  2. v25 patches 8 repliesSuperseded
  3. v15 patches 11 repliesSuperseded

Changes in v3 from the cover letter

- Use WITH_QEMU_LOCK_GUARD() for patch 2 [Eric]
(potentially I can also replace other existing uses of qemu_file_lock into
WITH_QEMU_LOCK_GUARD, but I decided to took Dave's r-b first and leave that for later)
- Added r-bs for Dave on patch 2/4
- Add a comment in patch 5 to explain why it's safe to unregister yank without qemu_file_lock, in postcopy_pause() [Dave]

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5migration: Fix missing join() of rp_threadmigration/migration.c migration/migration.h+10 -10 replies
2/5migration: Make from_dst_file accesses thread-safemigration/migration.c migration/migration.h migration/ram.c+35 -131 reply
3/5migration: Introduce migration_ioc_[un]register_yank()migration/channel.c migration/multifd.c migration/qemu-file-channel.c +2 more+36 -250 replies
4/5migration: Teach QEMUFile to be QIOChannel-awaremigration/qemu-file-channel.c migration/qemu-file.c migration/qemu-file.h +2 more+24 -70 replies
5/5migration: Move the yank unregister of channel_close outmigration/migration.c migration/qemu-file-channel.c migration/savevm.c +2 more+35 -41 reply

Reviews trailers per patch

All 5 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchDr. David Alan GilbertLukas Straub
SeriesR-b
1/5R-b
2/5R-b
3/5R-b
4/5R-b
5/5R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/5] migrations: Fix potential rare race of migration-test after yank

v3:
- Use WITH_QEMU_LOCK_GUARD() for patch 2 [Eric]
(potentially I can also replace other existing uses of qemu_file_lock into
WITH_QEMU_LOCK_GUARD, but I decided to took Dave's r-b first and leave that for later)
- Added r-bs for Dave on patch 2/4
- Add a comment in patch 5 to explain why it's safe to unregister yank without qemu_file_lock, in postcopy_pause() [Dave]

v2:
- Pick r-b for Dave on patch 1/3
- Move migration_file_get_ioc() from patch 5 to patch 4, meanwhile rename it to qemu_file_get_ioc(). [Dave]
- Patch 2 "migration: Shutdown src in await_return_path_close_on_source()" is replaced by patch "migration: Make from_dst_file accesses thread-safe" [Dave]

Patch 1 fixes a possible race that migration thread can accidentally skip join() of rp_thread even if the return thread is enabled. Patch 1 is suspected to also be the root cause of the recent hard-to-reproduce migration-test failure here reported by PMM:

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

I didn't reproduce it myself; but after co-debugged with Dave it's suspected that the race of rp_thread could be the cause. It's not exposed before because yank is soo strict on releasing instances, while we're not that strict before, and didn't join() on rp_thread wasn't so dangerous after all when migration succeeded before.

Patch 2 fixes another theoretical race on accessing from_dst_file spotted by Dave. I don't think there's known issues with it, but may still worth fixing.

Patch 3 should be a cleanup on yank that I think would be nice to have.

Patch 4-5 are further cleanups to remove the ref==1 check in channel_close(), finally, as I always thought that's a bit hackish. So I used explicit unregister of the yank function at necessary places to replace that ref==1 one.

I still think having patch 3-5 altogether would be great, however I think patch 1 should still be the most important to be reviewed. Also it would be great to know whether patch 1 could fix the known yank crash.

Please review, thanks.

Peter Xu (5):
migration: Fix missing join() of rp_thread
migration: Make from_dst_file accesses thread-safe
migration: Introduce migration_ioc_[un]register_yank()
migration: Teach QEMUFile to be QIOChannel-aware
migration: Move the yank unregister of channel_close out

 migration/channel.c           | 15 ++-------
 migration/migration.c         | 57 +++++++++++++++++++++++++++--------
 migration/migration.h         | 15 +++++++--
 migration/multifd.c           |  8 ++---
 migration/qemu-file-channel.c | 11 ++-----
 migration/qemu-file.c         | 17 ++++++++++-
 migration/qemu-file.h         |  4 ++-
 migration/ram.c               |  3 +-
 migration/savevm.c            | 11 +++++--
 migration/yank_functions.c    | 42 ++++++++++++++++++++++++++
 migration/yank_functions.h    |  3 ++
 11 files changed, 138 insertions(+), 48 deletions(-)
Signature · 1 line
2.31.1