From patchwork Thu Oct 18 07:30:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 192218 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4C0112C00A3 for ; Thu, 18 Oct 2012 18:55:11 +1100 (EST) Received: from localhost ([::1]:41304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOkZy-0006DQ-5t for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2012 03:31:42 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOkZE-00054R-8a for qemu-devel@nongnu.org; Thu, 18 Oct 2012 03:31:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOkZ8-0000Su-Ig for qemu-devel@nongnu.org; Thu, 18 Oct 2012 03:30:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28905) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOkZ7-0000Pu-MJ for qemu-devel@nongnu.org; Thu, 18 Oct 2012 03:30:49 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9I7UlhB029158 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 18 Oct 2012 03:30:49 -0400 Received: from trasno.mitica (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q9I7URnQ020816; Thu, 18 Oct 2012 03:30:47 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2012 09:30:03 +0200 Message-Id: <1350545426-23172-8-git-send-email-quintela@redhat.com> In-Reply-To: <1350545426-23172-1-git-send-email-quintela@redhat.com> References: <1350545426-23172-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 07/30] migration: make writes blocking X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- migration-exec.c | 2 -- migration-fd.c | 6 ------ migration-tcp.c | 19 ++----------------- migration-unix.c | 2 -- migration.c | 21 --------------------- qemu-file.h | 5 ----- savevm.c | 5 ----- 7 files changed, 2 insertions(+), 58 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 7335167..aba1be7 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 a15c2b8..812ae22 100644 --- a/migration-tcp.c +++ b/migration-tcp.c @@ -53,21 +53,6 @@ static int tcp_close(MigrationState *s) return r; } -static void tcp_wait_for_connect(int fd, void *opaque) -{ - MigrationState *s = opaque; - - if (fd < 0) { - DPRINTF("migrate connect error\n"); - s->fd = -1; - migrate_fd_error(s); - } else { - DPRINTF("migrate connect success\n"); - s->fd = fd; - migrate_fd_connect(s); - } -} - int tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp) { @@ -75,12 +60,12 @@ int tcp_start_outgoing_migration(MigrationState *s, const char *host_port, s->write = socket_write; s->close = tcp_close; - s->fd = inet_nonblocking_connect(host_port, tcp_wait_for_connect, s, - errp); + s->fd = inet_connect(host_port, errp); if (error_is_set(errp)) { migrate_fd_error(s); return -1; } + migrate_fd_connect(s); return 0; } 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 05ef1a3..a8b2f4a 100644 --- a/migration.c +++ b/migration.c @@ -247,10 +247,6 @@ static int migrate_fd_cleanup(MigrationState *s) { int ret = 0; - if (s->fd != -1) { - qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); - } - if (s->file) { DPRINTF("closing file\n"); ret = qemu_fclose(s->file); @@ -285,18 +281,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; - int ret; - - qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); - ret = qemu_file_put_notify(s->file); - if (ret) { - migrate_fd_error(s); - } -} - ssize_t migrate_fd_put_buffer(MigrationState *s, const void *data, size_t size) { @@ -313,10 +297,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; } @@ -412,7 +392,6 @@ int 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 9c8985b..e88892c 100644 --- a/qemu-file.h +++ b/qemu-file.h @@ -104,11 +104,6 @@ int64_t qemu_file_set_rate_limit(QEMUFile *f, int64_t new_rate); int64_t qemu_file_get_rate_limit(QEMUFile *f); int qemu_file_get_error(QEMUFile *f); -/* 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. */ -int 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 b080d37..69f1768 100644 --- a/savevm.c +++ b/savevm.c @@ -523,11 +523,6 @@ int qemu_fclose(QEMUFile *f) return ret; } -int qemu_file_put_notify(QEMUFile *f) -{ - return f->put_buffer(f->opaque, NULL, 0, 0); -} - void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size) { int l;