X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=migration-fd.c;h=3d4613cbaf5b2e2bfafd2b42dce303db4981bf33;hb=5e916c287e023c57f05689f908cc4579a6b53245;hp=73a1dfcc937a092041d3c6b0a93b633d7f68dd9a;hpb=83c9089e73b81c69dc1ecdf859fa84d2c500fb5f;p=qemu.git diff --git a/migration-fd.c b/migration-fd.c index 73a1dfcc9..3d4613cba 100644 --- a/migration-fd.c +++ b/migration-fd.c @@ -14,12 +14,11 @@ */ #include "qemu-common.h" -#include "qemu_socket.h" -#include "migration.h" +#include "qemu/sockets.h" +#include "migration/migration.h" #include "monitor/monitor.h" -#include "buffered_file.h" +#include "migration/qemu-file.h" #include "block/block.h" -#include "qemu_socket.h" //#define DEBUG_MIGRATION_FD @@ -31,55 +30,13 @@ do { } while (0) #endif -static int fd_errno(MigrationState *s) -{ - return errno; -} - -static int fd_write(MigrationState *s, const void * buf, size_t size) -{ - return write(s->fd, buf, size); -} - -static int fd_close(MigrationState *s) -{ - struct stat st; - int ret; - - DPRINTF("fd_close\n"); - ret = fstat(s->fd, &st); - if (ret == 0 && S_ISREG(st.st_mode)) { - /* - * If the file handle is a regular file make sure the - * data is flushed to disk before signaling success. - */ - ret = fsync(s->fd); - if (ret != 0) { - ret = -errno; - perror("migration-fd: fsync"); - return ret; - } - } - ret = close(s->fd); - s->fd = -1; - if (ret != 0) { - ret = -errno; - perror("migration-fd: close"); - } - return ret; -} - void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp) { - s->fd = monitor_get_fd(cur_mon, fdname, errp); - if (s->fd == -1) { + int fd = monitor_get_fd(cur_mon, fdname, errp); + if (fd == -1) { return; } - - fcntl(s->fd, F_SETFL, O_NONBLOCK); - s->get_error = fd_errno; - s->write = fd_write; - s->close = fd_close; + s->file = qemu_fdopen(fd, "wb"); migrate_fd_connect(s); }