migration: move process_incoming_migration to a coroutine
The final part of incoming migration, which now consists of process_incoming_migration for all protocols, is thus made non-blocking. Reviewed-by: Orit Wasserman <owasserm@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
595ab64169
commit
82a4da79fd
21
migration.c
21
migration.c
@ -83,11 +83,13 @@ void qemu_start_incoming_migration(const char *uri, Error **errp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_incoming_migration(QEMUFile *f)
|
static void process_incoming_migration_co(void *opaque)
|
||||||
{
|
{
|
||||||
|
QEMUFile *f = opaque;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = qemu_loadvm_state(f);
|
ret = qemu_loadvm_state(f);
|
||||||
|
qemu_set_fd_handler(qemu_get_fd(f), NULL, NULL, NULL);
|
||||||
qemu_fclose(f);
|
qemu_fclose(f);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "load of migration failed\n");
|
fprintf(stderr, "load of migration failed\n");
|
||||||
@ -107,6 +109,23 @@ void process_incoming_migration(QEMUFile *f)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void enter_migration_coroutine(void *opaque)
|
||||||
|
{
|
||||||
|
Coroutine *co = opaque;
|
||||||
|
qemu_coroutine_enter(co, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void process_incoming_migration(QEMUFile *f)
|
||||||
|
{
|
||||||
|
Coroutine *co = qemu_coroutine_create(process_incoming_migration_co);
|
||||||
|
int fd = qemu_get_fd(f);
|
||||||
|
|
||||||
|
assert(fd != -1);
|
||||||
|
socket_set_nonblock(fd);
|
||||||
|
qemu_set_fd_handler(fd, enter_migration_coroutine, NULL, co);
|
||||||
|
qemu_coroutine_enter(co, f);
|
||||||
|
}
|
||||||
|
|
||||||
/* amount of nanoseconds we are willing to wait for migration to be down.
|
/* amount of nanoseconds we are willing to wait for migration to be down.
|
||||||
* the choice of nanoseconds is because it is the maximum resolution that
|
* the choice of nanoseconds is because it is the maximum resolution that
|
||||||
* get_clock() can achieve. It is an internal measure. All user-visible
|
* get_clock() can achieve. It is an internal measure. All user-visible
|
||||||
|
Loading…
x
Reference in New Issue
Block a user