Move all the writes to the migration_thread, and make writings blocking. Notice that are still using the iothread for everything that we do.
Signed-off-by: Juan Quintela <quint...@redhat.com> --- migration-exec.c | 2 -- migration-fd.c | 6 ------ migration-tcp.c | 2 +- migration-unix.c | 2 -- migration.c | 18 ------------------ qemu-file.h | 5 ----- savevm.c | 5 ----- 7 files changed, 1 insertion(+), 39 deletions(-) diff --git a/migration-exec.c b/migration-exec.c index 6c97db9..908f22e 100644 --- a/migration-exec.c +++ b/migration-exec.c @@ -76,8 +76,6 @@ int exec_start_outgoing_migration(MigrationState *s, const char *command) goto err_after_open; } - socket_set_nonblock(s->fd); - s->opaque = qemu_popen(f, "w"); s->close = exec_close; diff --git a/migration-fd.c b/migration-fd.c index 50138ed..e5be972 100644 --- a/migration-fd.c +++ b/migration-fd.c @@ -81,11 +81,6 @@ int fd_start_outgoing_migration(MigrationState *s, const char *fdname) goto err_after_get_fd; } - if (fcntl(s->fd, F_SETFL, O_NONBLOCK) == -1) { - DPRINTF("Unable to set nonblocking mode on file descriptor\n"); - goto err_after_open; - } - s->get_error = fd_errno; s->write = fd_write; s->close = fd_close; @@ -93,7 +88,6 @@ int fd_start_outgoing_migration(MigrationState *s, const char *fdname) migrate_fd_connect(s); return 0; -err_after_open: close(s->fd); err_after_get_fd: return -1; diff --git a/migration-tcp.c b/migration-tcp.c index 440804d..d2bfb03 100644 --- a/migration-tcp.c +++ b/migration-tcp.c @@ -86,7 +86,7 @@ int tcp_start_outgoing_migration(MigrationState *s, const char *host_port, s->write = socket_write; s->close = tcp_close; - s->fd = inet_connect(host_port, false, errp); + s->fd = inet_connect(host_port, true, errp); if (!error_is_set(errp)) { migrate_fd_connect(s); diff --git a/migration-unix.c b/migration-unix.c index 169de88..bb41bac 100644 --- a/migration-unix.c +++ b/migration-unix.c @@ -96,8 +96,6 @@ int unix_start_outgoing_migration(MigrationState *s, const char *path) return -errno; } - socket_set_nonblock(s->fd); - do { ret = connect(s->fd, (struct sockaddr *)&addr, sizeof(addr)); if (ret == -1) { diff --git a/migration.c b/migration.c index e3eec97..fe2afd0 100644 --- a/migration.c +++ b/migration.c @@ -257,8 +257,6 @@ static int migrate_fd_cleanup(MigrationState *s) { int ret = 0; - qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); - if (s->file) { DPRINTF("closing file\n"); ret = qemu_fclose(s->file); @@ -293,17 +291,6 @@ static void migrate_fd_completed(MigrationState *s) notifier_list_notify(&migration_state_notifiers, s); } -static void migrate_fd_put_notify(void *opaque) -{ - MigrationState *s = opaque; - - qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); - qemu_file_put_notify(s->file); - if (s->file && qemu_file_get_error(s->file)) { - migrate_fd_error(s); - } -} - ssize_t migrate_fd_put_buffer(MigrationState *s, const void *data, size_t size) { @@ -320,10 +307,6 @@ ssize_t migrate_fd_put_buffer(MigrationState *s, const void *data, if (ret == -1) ret = -(s->get_error(s)); - if (ret == -EAGAIN) { - qemu_set_fd_handler2(s->fd, NULL, NULL, migrate_fd_put_notify, s); - } - return ret; } @@ -431,7 +414,6 @@ void migrate_fd_wait_for_unfreeze(MigrationState *s) int migrate_fd_close(MigrationState *s) { - qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); return s->close(s); } diff --git a/qemu-file.h b/qemu-file.h index 31b83f6..af7c36f 100644 --- a/qemu-file.h +++ b/qemu-file.h @@ -106,11 +106,6 @@ int64_t qemu_file_get_rate_limit(QEMUFile *f); int qemu_file_get_error(QEMUFile *f); void qemu_file_set_error(QEMUFile *f, int error); -/* Try to send any outstanding data. This function is useful when output is - * halted due to rate limiting or EAGAIN errors occur as it can be used to - * resume output. */ -void qemu_file_put_notify(QEMUFile *f); - static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv) { qemu_put_be64(f, *pv); diff --git a/savevm.c b/savevm.c index c5fd13f..2c34faa 100644 --- a/savevm.c +++ b/savevm.c @@ -546,11 +546,6 @@ int qemu_fclose(QEMUFile *f) return ret; } -void qemu_file_put_notify(QEMUFile *f) -{ - f->put_buffer(f->opaque, NULL, 0, 0); -} - void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size) { int l; -- 1.7.10.4