From f8bbc1286337a8506162b5785babe6f2a7de2476 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 22 Feb 2013 17:36:41 +0100 Subject: migration: use QEMUFile for migration channel lifetime As a start, use QEMUFile to store the destination and close it. qemu_get_fd gets a file descriptor that will be used by the write callbacks. Reviewed-by: Orit Wasserman Reviewed-by: Juan Quintela Signed-off-by: Paolo Bonzini Signed-off-by: Juan Quintela --- migration.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'migration.c') diff --git a/migration.c b/migration.c index f35728da8d..52126d86cc 100644 --- a/migration.c +++ b/migration.c @@ -274,7 +274,7 @@ static void migrate_fd_cleanup(void *opaque) s->file = NULL; } - assert(s->fd == -1); + assert(s->migration_file == NULL); assert(s->state != MIG_STATE_ACTIVE); if (s->state != MIG_STATE_COMPLETED) { @@ -330,8 +330,9 @@ static void migrate_fd_cancel(MigrationState *s) int migrate_fd_close(MigrationState *s) { int rc = 0; - if (s->fd != -1) { - rc = s->close(s); + if (s->migration_file != NULL) { + rc = qemu_fclose(s->migration_file); + s->migration_file = NULL; s->fd = -1; } return rc; @@ -720,6 +721,7 @@ void migrate_fd_connect(MigrationState *s) s->xfer_limit = s->bandwidth_limit / XFER_LIMIT_RATIO; s->cleanup_bh = qemu_bh_new(migrate_fd_cleanup, s); + s->fd = qemu_get_fd(s->migration_file); s->file = qemu_fopen_ops(s, &migration_file_ops); qemu_thread_create(&s->thread, migration_thread, s, -- cgit v1.2.3