Skip to content

Commit

Permalink
migration: Recover behavior of preempt channel creation for pre-7.2
Browse files Browse the repository at this point in the history
In 8.0 devel window we reworked preempt channel creation, so that there'll
be no race condition when the migration channel and preempt channel got
established in the wrong order in commit 5655aab.

However no one noticed that the change will also be not compatible with
older qemus, majorly 7.1/7.2 versions where preempt mode started to be
supported.

Leverage the same pre-7.2 flag introduced in the previous patch to recover
the behavior hopefully before 8.0 releases, so we don't break migration
when we migrate from 8.0 to older qemu binaries.

Fixes: 5655aab ("migration: Postpone postcopy preempt channel to be after main")
Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: Juan Quintela <[email protected]>
Signed-off-by: Juan Quintela <[email protected]>
  • Loading branch information
xzpeter authored and Juan Quintela committed Apr 12, 2023
1 parent 6621883 commit 06064a6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
9 changes: 9 additions & 0 deletions migration/migration.c
Original file line number Diff line number Diff line change
Expand Up @@ -4388,6 +4388,15 @@ void migrate_fd_connect(MigrationState *s, Error *error_in)
}
}

/*
* This needs to be done before resuming a postcopy. Note: for newer
* QEMUs we will delay the channel creation until postcopy_start(), to
* avoid disorder of channel creations.
*/
if (migrate_postcopy_preempt() && s->preempt_pre_7_2) {
postcopy_preempt_setup(s);
}

if (resume) {
/* Wakeup the main migration thread to do the recovery */
migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_PAUSED,
Expand Down
7 changes: 7 additions & 0 deletions migration/migration.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,19 @@ struct MigrationState {
* - postcopy preempt src QEMU instance will generate an EOS message at
* the end of migration to shut the preempt channel on dest side.
*
* - postcopy preempt channel will be created at the setup phase on src
QEMU.
*
* When clear:
*
* - postcopy preempt src QEMU instance will _not_ generate an EOS
* message at the end of migration, the dest qemu will shutdown the
* channel itself.
*
* - postcopy preempt channel will be created at the switching phase
* from precopy -> postcopy (to avoid race condtion of misordered
* creation of channels).
*
* NOTE: See message-id <ZBoShWArKDPpX/D7@work-vm> on qemu-devel
* mailing list for more information on the possible race. Everyone
* should probably just keep this value untouched after set by the
Expand Down
10 changes: 8 additions & 2 deletions migration/postcopy-ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -1630,8 +1630,14 @@ int postcopy_preempt_establish_channel(MigrationState *s)
return 0;
}

/* Kick off async task to establish preempt channel */
postcopy_preempt_setup(s);
/*
* Kick off async task to establish preempt channel. Only do so with
* 8.0+ machines, because 7.1/7.2 require the channel to be created in
* setup phase of migration (even if racy in an unreliable network).
*/
if (!s->preempt_pre_7_2) {
postcopy_preempt_setup(s);
}

/*
* We need the postcopy preempt channel to be established before
Expand Down

0 comments on commit 06064a6

Please sign in to comment.