Skip to content

Commit

Permalink
migration: Don't do migrate cleanup if during postcopy resume
Browse files Browse the repository at this point in the history
Below process could crash qemu with postcopy recovery:

  1. (hmp) migrate -d ..
  2. (hmp) migrate_start_postcopy
  3. [network down, postcopy paused]
  4. (hmp) migrate -r $WRONG_PORT
     when try the recover on an invalid $WRONG_PORT, cleanup_bh will be cleared
  5. (hmp) migrate -r $RIGHT_PORT
     [qemu crash on assert(cleanup_bh)]

The thing is we shouldn't cleanup if it's postcopy resume; the error is set
mostly because the channel is wrong, so we return directly waiting for the user
to retry.

migrate_fd_cleanup() should only be called when migration is cancelled or
completed.

Signed-off-by: Peter Xu <[email protected]>
Message-Id: <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Signed-off-by: Dr. David Alan Gilbert <[email protected]>
  • Loading branch information
xzpeter authored and dagrh committed Jul 13, 2021
1 parent 2e3e3da commit ca30f24
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion migration/migration.c
Original file line number Diff line number Diff line change
Expand Up @@ -3979,7 +3979,18 @@ void migrate_fd_connect(MigrationState *s, Error *error_in)
}
if (error_in) {
migrate_fd_error(s, error_in);
migrate_fd_cleanup(s);
if (resume) {
/*
* Don't do cleanup for resume if channel is invalid, but only dump
* the error. We wait for another channel connect from the user.
* The error_report still gives HMP user a hint on what failed.
* It's normally done in migrate_fd_cleanup(), but call it here
* explicitly.
*/
error_report_err(error_copy(s->error));
} else {
migrate_fd_cleanup(s);
}
return;
}

Expand Down

0 comments on commit ca30f24

Please sign in to comment.