Skip to content

Commit

Permalink
migration: Move yank outside qemu_start_incoming_migration()
Browse files Browse the repository at this point in the history
Starting from commit b5eea99, qmp_migrate_recover() calls unregister
before calling qemu_start_incoming_migration(). I believe it wanted to mitigate
the next call to yank_register_instance(), but I think that's wrong.

Firstly, if during recover, we should keep the yank instance there, not
"quickly removing and adding it back".

Meanwhile, calling qmp_migrate_recover() twice with b5eea99 will directly
crash the dest qemu (right now it can't; but it'll start to work right after
the next patch) because the 1st call of qmp_migrate_recover() will unregister
permanently when the channel failed to establish, then the 2nd call of
qmp_migrate_recover() crashes at yank_unregister_instance().

This patch fixes it by moving yank ops out of qemu_start_incoming_migration()
into qmp_migrate_incoming.  For qmp_migrate_recover(), drop the unregister of
yank instance too since we keep it there during the recovery phase.

Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20210629181356.217312-2-peterx@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
  • Loading branch information
xzpeter authored and dagrh committed Jul 5, 2021
1 parent c00d434 commit cc48c58
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions migration/migration.c
Expand Up @@ -456,10 +456,6 @@ static void qemu_start_incoming_migration(const char *uri, Error **errp)
{
const char *p = NULL;

if (!yank_register_instance(MIGRATION_YANK_INSTANCE, errp)) {
return;
}

qapi_event_send_migration(MIGRATION_STATUS_SETUP);
if (strstart(uri, "tcp:", &p) ||
strstart(uri, "unix:", NULL) ||
Expand All @@ -474,7 +470,6 @@ static void qemu_start_incoming_migration(const char *uri, Error **errp)
} else if (strstart(uri, "fd:", &p)) {
fd_start_incoming_migration(p, errp);
} else {
yank_unregister_instance(MIGRATION_YANK_INSTANCE);
error_setg(errp, "unknown migration protocol: %s", uri);
}
}
Expand Down Expand Up @@ -2083,9 +2078,14 @@ void qmp_migrate_incoming(const char *uri, Error **errp)
return;
}

if (!yank_register_instance(MIGRATION_YANK_INSTANCE, errp)) {
return;
}

qemu_start_incoming_migration(uri, &local_err);

if (local_err) {
yank_unregister_instance(MIGRATION_YANK_INSTANCE);
error_propagate(errp, local_err);
return;
}
Expand Down Expand Up @@ -2114,7 +2114,6 @@ void qmp_migrate_recover(const char *uri, Error **errp)
* only re-setup the migration stream and poke existing migration
* to continue using that newly established channel.
*/
yank_unregister_instance(MIGRATION_YANK_INSTANCE);
qemu_start_incoming_migration(uri, errp);
}

Expand Down

0 comments on commit cc48c58

Please sign in to comment.