From patchwork Tue Feb 6 15:49:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dr. David Alan Gilbert" X-Patchwork-Id: 10203217 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C19F760327 for ; Tue, 6 Feb 2018 15:54:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0F2C28C16 for ; Tue, 6 Feb 2018 15:54:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2D8328C6E; Tue, 6 Feb 2018 15:54:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_HK_NAME_DR autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0ED1028C16 for ; Tue, 6 Feb 2018 15:54:20 +0000 (UTC) Received: from localhost ([::1]:59614 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ej5Zb-0005zt-6U for patchwork-qemu-devel@patchwork.kernel.org; Tue, 06 Feb 2018 10:54:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ej5Vs-0002UR-A1 for qemu-devel@nongnu.org; Tue, 06 Feb 2018 10:50:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ej5Vq-0003uF-4k for qemu-devel@nongnu.org; Tue, 06 Feb 2018 10:50:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34406) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ej5Vp-0003tI-Qh for qemu-devel@nongnu.org; Tue, 06 Feb 2018 10:50:25 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F15686A7C2; Tue, 6 Feb 2018 15:50:24 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-30.ams2.redhat.com [10.36.117.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08B375D6A8; Tue, 6 Feb 2018 15:50:14 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com Date: Tue, 6 Feb 2018 15:49:24 +0000 Message-Id: <20180206154936.13565-3-dgilbert@redhat.com> In-Reply-To: <20180206154936.13565-1-dgilbert@redhat.com> References: <20180206154936.13565-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 06 Feb 2018 15:50:25 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 02/14] migration: Route errors down through migration_channel_connect X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, groug@kaod.org, peterx@redhat.com, ross.lagerwall@citrix.com, wei.w.wang@intel.com, danielhb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "Dr. David Alan Gilbert" Route async errors (especially from sockets) down through migration_channel_connect and on to migrate_fd_connect where they can be cleaned up. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Signed-off-by: Dr. David Alan Gilbert --- migration/channel.c | 32 ++++++++++++++++---------------- migration/channel.h | 3 ++- migration/exec.c | 2 +- migration/fd.c | 2 +- migration/socket.c | 4 +--- migration/tls.c | 3 +-- migration/trace-events | 2 +- 7 files changed, 23 insertions(+), 25 deletions(-) diff --git a/migration/channel.c b/migration/channel.c index fdb7ddbd17..c5eaf0fa0e 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -55,29 +55,29 @@ void migration_channel_process_incoming(QIOChannel *ioc) * @s: Current migration state * @ioc: Channel to which we are connecting * @hostname: Where we want to connect + * @error: Error indicating failure to connect, free'd here */ void migration_channel_connect(MigrationState *s, QIOChannel *ioc, - const char *hostname) + const char *hostname, + Error *error) { trace_migration_set_outgoing_channel( - ioc, object_get_typename(OBJECT(ioc)), hostname); + ioc, object_get_typename(OBJECT(ioc)), hostname, error); - if (s->parameters.tls_creds && - *s->parameters.tls_creds && - !object_dynamic_cast(OBJECT(ioc), - TYPE_QIO_CHANNEL_TLS)) { - Error *local_err = NULL; - migration_tls_channel_connect(s, ioc, hostname, &local_err); - if (local_err) { - migrate_fd_error(s, local_err); - error_free(local_err); - } - } else { - QEMUFile *f = qemu_fopen_channel_output(ioc); + if (!error) { + if (s->parameters.tls_creds && + *s->parameters.tls_creds && + !object_dynamic_cast(OBJECT(ioc), + TYPE_QIO_CHANNEL_TLS)) { + migration_tls_channel_connect(s, ioc, hostname, &error); + } else { + QEMUFile *f = qemu_fopen_channel_output(ioc); - s->to_dst_file = f; + s->to_dst_file = f; - migrate_fd_connect(s, NULL); + } } + migrate_fd_connect(s, error); + error_free(error); } diff --git a/migration/channel.h b/migration/channel.h index e4b40579a1..67a461c28a 100644 --- a/migration/channel.h +++ b/migration/channel.h @@ -22,5 +22,6 @@ void migration_channel_process_incoming(QIOChannel *ioc); void migration_channel_connect(MigrationState *s, QIOChannel *ioc, - const char *hostname); + const char *hostname, + Error *error_in); #endif diff --git a/migration/exec.c b/migration/exec.c index f3be1baf2e..c9537974ad 100644 --- a/migration/exec.c +++ b/migration/exec.c @@ -39,7 +39,7 @@ void exec_start_outgoing_migration(MigrationState *s, const char *command, Error } qio_channel_set_name(ioc, "migration-exec-outgoing"); - migration_channel_connect(s, ioc, NULL); + migration_channel_connect(s, ioc, NULL, NULL); object_unref(OBJECT(ioc)); } diff --git a/migration/fd.c b/migration/fd.c index 30de4b9847..6284a97cba 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -39,7 +39,7 @@ void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error ** } qio_channel_set_name(QIO_CHANNEL(ioc), "migration-fd-outgoing"); - migration_channel_connect(s, ioc, NULL); + migration_channel_connect(s, ioc, NULL, NULL); object_unref(OBJECT(ioc)); } diff --git a/migration/socket.c b/migration/socket.c index 3a8232dd2d..e090097077 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -79,12 +79,10 @@ static void socket_outgoing_migration(QIOTask *task, if (qio_task_propagate_error(task, &err)) { trace_migration_socket_outgoing_error(error_get_pretty(err)); - migrate_fd_error(data->s, err); - error_free(err); } else { trace_migration_socket_outgoing_connected(data->hostname); - migration_channel_connect(data->s, sioc, data->hostname); } + migration_channel_connect(data->s, sioc, data->hostname, err); object_unref(OBJECT(sioc)); } diff --git a/migration/tls.c b/migration/tls.c index 026a008667..a29b35b33c 100644 --- a/migration/tls.c +++ b/migration/tls.c @@ -118,11 +118,10 @@ static void migration_tls_outgoing_handshake(QIOTask *task, if (qio_task_propagate_error(task, &err)) { trace_migration_tls_outgoing_handshake_error(error_get_pretty(err)); - migrate_fd_error(s, err); } else { trace_migration_tls_outgoing_handshake_complete(); - migration_channel_connect(s, ioc, NULL); } + migration_channel_connect(s, ioc, NULL, err); object_unref(OBJECT(ioc)); } diff --git a/migration/trace-events b/migration/trace-events index 6f29fcc686..93961dea16 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -114,7 +114,7 @@ migrate_transferred(uint64_t tranferred, uint64_t time_spent, double bandwidth, process_incoming_migration_co_end(int ret, int ps) "ret=%d postcopy-state=%d" process_incoming_migration_co_postcopy_end_main(void) "" migration_set_incoming_channel(void *ioc, const char *ioctype) "ioc=%p ioctype=%s" -migration_set_outgoing_channel(void *ioc, const char *ioctype, const char *hostname) "ioc=%p ioctype=%s hostname=%s" +migration_set_outgoing_channel(void *ioc, const char *ioctype, const char *hostname, void *err) "ioc=%p ioctype=%s hostname=%s err=%p" # migration/rdma.c qemu_rdma_accept_incoming_migration(void) ""