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-unix.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'migration-unix.c') diff --git a/migration-unix.c b/migration-unix.c index 4693b43d90..11917f4f2a 100644 --- a/migration-unix.c +++ b/migration-unix.c @@ -39,28 +39,17 @@ static int unix_write(MigrationState *s, const void * buf, size_t size) return write(s->fd, buf, size); } -static int unix_close(MigrationState *s) -{ - int r = 0; - DPRINTF("unix_close\n"); - if (close(s->fd) < 0) { - r = -errno; - } - return r; -} - static void unix_wait_for_connect(int fd, void *opaque) { MigrationState *s = opaque; if (fd < 0) { DPRINTF("migrate connect error\n"); - s->fd = -1; + s->migration_file = NULL; migrate_fd_error(s); } else { DPRINTF("migrate connect success\n"); - s->fd = fd; - socket_set_block(s->fd); + s->migration_file = qemu_fopen_socket(fd, "wb"); migrate_fd_connect(s); } } @@ -69,9 +58,7 @@ void unix_start_outgoing_migration(MigrationState *s, const char *path, Error ** { s->get_error = unix_errno; s->write = unix_write; - s->close = unix_close; - - s->fd = unix_nonblocking_connect(path, unix_wait_for_connect, s, errp); + unix_nonblocking_connect(path, unix_wait_for_connect, s, errp); } static void unix_accept_incoming_migration(void *opaque) -- cgit v1.2.1