Anthony Liguori <anth...@codemonkey.ws> wrote: > On 03/09/2010 05:10 PM, Juan Quintela wrote: >> This was the only incoming migration without autostart check >> >> Signed-off-by: Juan Quintela<quint...@redhat.com> >> --- >> migration-unix.c | 2 ++ >> 1 files changed, 2 insertions(+), 0 deletions(-) >> >> diff --git a/migration-unix.c b/migration-unix.c >> index ce59a2a..49de1b9 100644 >> --- a/migration-unix.c >> +++ b/migration-unix.c >> @@ -176,6 +176,8 @@ static void unix_accept_incoming_migration(void *opaque) >> qemu_announce_self(); >> DPRINTF("successfully loaded vm state\n"); >> >> + if (autostart) >> + vm_start(); >> > > Maybe a better thing to do is make accept_incoming_migration return an > error code and do the vm_start in common code.
It is uglier than that (got the ones from migration-fd but idea is the same, removed uinteresting bits) static void fd_accept_incoming_migration(void *opaque) { ret = qemu_loadvm_state(f); .... if (autostart) vm_start(); .... } int fd_start_incoming_migration(const char *infd) { .... qemu_set_fd_handler2(fd, NULL, fd_accept_incoming_migration, NULL, (void *)(unsigned long)f); return 0; } function call chain is: main() -> qemu_start_incoming_migration() -> fd_start_migration() -> here they got an fd, and call fd_accept_incoming_migration asyncronously on that fd. We can't call vm_start() until migration finish. And we have gone async a long time ago. As a related note, you can see that exec_accept_incoming_migration() is identical to fd_start_incoming_migration(). I was going to share the code for all migrations until I found that unix & tcp migration do the accept also asynchronously, breaking the common function. My plan was to make the accept in {unix,tcp}_start_incoming_migration() and then have a shared qemu_accept_incoming_migration() for all four kinds of migration. Notice that it don't make sense to make the accept async, because qemu is not going to do _anything_ until incoming migration is finished, anyways. Just didn't want to merge the bugfix with the other change. Later, Juan. > Regards, > > Anthony Liguori > >> out_fopen: >> qemu_fclose(f); >>