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-exec.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'migration-exec.c') diff --git a/migration-exec.c b/migration-exec.c index a2b5f8d729..8c3f72050a 100644 --- a/migration-exec.c +++ b/migration-exec.c @@ -43,33 +43,16 @@ static int file_write(MigrationState *s, const void * buf, size_t size) return write(s->fd, buf, size); } -static int exec_close(MigrationState *s) -{ - int ret = 0; - DPRINTF("exec_close\n"); - ret = qemu_fclose(s->opaque); - s->opaque = NULL; - s->fd = -1; - return ret; -} - void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp) { - QEMUFile *f; - f = qemu_popen_cmd(command, "w"); - if (f == NULL) { + s->migration_file = qemu_popen_cmd(command, "w"); + if (s->migration_file == NULL) { error_setg_errno(errp, errno, "failed to popen the migration target"); return; } - s->opaque = f; - s->fd = qemu_get_fd(f); - assert(s->fd != -1); - - s->close = exec_close; s->get_error = file_errno; s->write = file_write; - migrate_fd_connect(s); } -- cgit v1.2.1