diff options
| author | Anthony Liguori <aliguori@us.ibm.com> | 2012-11-02 13:06:28 -0500 |
|---|---|---|
| committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-11-02 13:06:28 -0500 |
| commit | 2a0dfd004d9fae4adf2ccfcb2e3b1a76906b48a0 (patch) | |
| tree | 98dbd8f0ee86efb371da9fa605d87f96b51d55e5 /migration-fd.c | |
| parent | 1ef2a82e8f60779bebdae59f7dad8205cc93db30 (diff) | |
| parent | 82a4da79fd6c108400637143f8439c2364bdb21e (diff) | |
| download | focaccia-qemu-2a0dfd004d9fae4adf2ccfcb2e3b1a76906b48a0.tar.gz focaccia-qemu-2a0dfd004d9fae4adf2ccfcb2e3b1a76906b48a0.zip | |
Merge remote-tracking branch 'bonzini/migr-coroutine' into staging
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> * bonzini/migr-coroutine: migration: move process_incoming_migration to a coroutine migration: handle EAGAIN while reading QEMUFile migration: move qemu_fclose to process_incoming_migration migration: close socket QEMUFile from socket_close migration: xxx_close will only be called once migration: use closesocket, not close migration: use migrate_fd_close in migrate_fd_cleanup migration: clean up server sockets and handlers before invoking process_incoming_migration migration: replace qemu_stdio_fd with qemu_get_fd migration: add qemu_get_fd migration: consolidate QEMUFile methods in a single QEMUFileOps struct migration: unify stdio-based QEMUFile operations
Diffstat (limited to 'migration-fd.c')
| -rw-r--r-- | migration-fd.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/migration-fd.c b/migration-fd.c index ce6932d7c3..5fe28e09fd 100644 --- a/migration-fd.c +++ b/migration-fd.c @@ -48,29 +48,26 @@ static int fd_close(MigrationState *s) int ret; DPRINTF("fd_close\n"); - if (s->fd != -1) { - 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; + 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: close"); + perror("migration-fd: fsync"); return ret; } } - return 0; + 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) @@ -92,9 +89,8 @@ static void fd_accept_incoming_migration(void *opaque) { QEMUFile *f = opaque; + qemu_set_fd_handler2(qemu_get_fd(f), NULL, NULL, NULL, NULL); process_incoming_migration(f); - qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL); - qemu_fclose(f); } void fd_start_incoming_migration(const char *infd, Error **errp) |