Skip to content

migration/postcopy: report destination states only after the run state change

Denis V. Lunev qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest5 patches 4 repliesIn review
  2. v14 patches 4 repliesSuperseded

Changes in v2 from the cover letter

- the run BH sets main_thread_load_event instead of a second event (Peter)
- the destination's switch to postcopy-active keeps the explicit POSTCOPY_DEVICE check (Peter)
- new iotest case for a bitmap postcopy with a return path
- the commit message of the late pong is updated; the code is unchanged, so I kept the tags
- rebased

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5migration/postcopy: report COMPLETED only after the run BH has runmigration/migration.h migration/savevm.c+6 -21 reply
2/5migration/postcopy: set destination postcopy-active in the run BHmigration/savevm.c+6 -51 reply
3/5tests/qtest/migration: check the destination run state in postcopy teststests/qtest/migration/framework.c tests/qtest/migration/migration-qmp.c tests/qtest/migration/migration-qmp.h +2 more+24 -51 reply
4/5migration/postcopy: answer the package-loaded ping from the run BHmigration/migration.c migration/migration.h migration/savevm.c+11 -00 replies
5/5iotests/migrate-bitmaps-postcopy-test: cover postcopy with a return pathtests/qemu-iotests/tests/migrate-bitmaps-postcopy-test tests/qemu-iotests/tests/migrate-bitmaps-postcopy-test.out+41 -21 reply

Reviews trailers per patch

3 of 5 patches have a Reviewed-by or Acked-by.

PatchPeter XuJuraj MarcinEric Blake
1/5R-b
2/5
3/5T-b R-b
4/5R-b R-b T-b
5/5

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 0/5] migration/postcopy: report destination states only after the run state change

On the postcopy destination, the postcopy-active and completed states can be reported while the VM is still in RUN_STATE_INMIGRATE. The run state only changes in loadvm_postcopy_handle_run_bh(), but loadvm_postcopy_handle_run() switches to postcopy-active before it schedules the BH, and the listen thread can report completed before the BH has run. Precopy does not have this problem: the run state changes before completed is reported.

We hit this in production. A VM with a persistent dirty bitmap migrates its bitmaps in postcopy, so libvirt runs the Finish phase as soon as the source enters postcopy-active. Our libvirt reattaches disks on the destination in Finish, and the blockdev-add calls land while the destination is still in RUN_STATE_INMIGRATE. The new nodes are created inactive, the device cannot be attached to them ("Block node is read-only"), and the guest is lost on both hosts. A bitmap-only postcopy makes the window wide, because the listen thread has almost nothing to load.

The series orders both destination states after the run state change and adds a qtest check that fails on master; fast snapshot load (postcopy-ram with mapped-ram) is not covered. The series also gives the source's postcopy-active the same meaning. It takes Peter's idea from the review of Juraj's RFC [1]: record the package-loaded ping and send the pong later [2]. Here the pong is sent from the run BH, after the run state change, rather than from loadvm_postcopy_handle_run(). Juraj confirmed that this fixes the unrecoverable source he reported [3]. The late pong keeps the source in postcopy-device longer, so it can be dropped without affecting the rest.

The late pong has two more consequences. A bitmap-only postcopy with a return path deadlocks unless dirty_bitmap_load() stops holding its lock while it reads the stream. That fix was sent separately [4] and this series is based on it. The new iotest case covers that configuration; feel free to drop it. And an autostarting destination that dies between vm_start() and the pong lets the source resume after the guest has briefly run there. This cannot happen with -S, which libvirt uses.

[1] https://lore.kernel.org/qemu-devel/[email protected]/
[2] https://lore.kernel.org/qemu-devel/[email protected]/
[3] https://lore.kernel.org/qemu-devel/[email protected]/
[4] https://lore.kernel.org/qemu-devel/[email protected]/

Many thanks to Juraj for the postcopy-device state in 7b842fe354c. It is what gives the source a point to wait at, and this series only moves that point to where the destination has really left RUN_STATE_INMIGRATE.

v2:
- the run BH sets main_thread_load_event instead of a second event (Peter)
- the destination's switch to postcopy-active keeps the explicit POSTCOPY_DEVICE check (Peter)
- new iotest case for a bitmap postcopy with a return path
- the commit message of the late pong is updated; the code is unchanged, so I kept the tags
- rebased

v1: https://lore.kernel.org/qemu-devel/[email protected]/

Based-on: <[email protected]>

Cc Peter Xu <[email protected]>
Cc Fabiano Rosas <[email protected]>
Cc Juraj Marcin <[email protected]>
Cc Vladimir Sementsov-Ogievskiy <[email protected]>
Cc Eric Blake <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Hanna Reitz <[email protected]>

Denis V. Lunev (5):
migration/postcopy: report COMPLETED only after the run BH has run migration/postcopy: set destination postcopy-active in the run BH tests/qtest/migration: check the destination run state in postcopy
tests
migration/postcopy: answer the package-loaded ping from the run BH iotests/migrate-bitmaps-postcopy-test: cover postcopy with a return
path

 migration/migration.c                         |  1 +
 migration/migration.h                         |  4 +-
 migration/savevm.c                            | 25 +++++++++---
 .../tests/migrate-bitmaps-postcopy-test       | 39 +++++++++++++++++++
 .../tests/migrate-bitmaps-postcopy-test.out   |  4 +-
 tests/qtest/migration/framework.c             |  6 ++-
 tests/qtest/migration/migration-qmp.c         | 10 ++++-
 tests/qtest/migration/migration-qmp.h         |  3 +-
 tests/qtest/migration/migration-util.c        |  8 ++++
 tests/qtest/migration/migration-util.h        |  2 +
 10 files changed, 88 insertions(+), 14 deletions(-)

base-commit: 723622bedb0b423de7d1c61ebbe6e7a71934949c
prerequisite-patch-id: 67b7337e86202ef7509fc53ff8915a814a477e3b

Signature · 1 line
2.53.0