From nobody Wed Oct 29 05:57:25 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513358342941532.9977929755289; Fri, 15 Dec 2017 09:19:02 -0800 (PST) Received: from localhost ([::1]:47836 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePtd0-0001M3-SS for importer@patchew.org; Fri, 15 Dec 2017 12:18:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePtbd-0000bi-JD for qemu-devel@nongnu.org; Fri, 15 Dec 2017 12:17:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePtbb-0001oM-RF for qemu-devel@nongnu.org; Fri, 15 Dec 2017 12:17:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41674) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePtbb-0001lR-Ko for qemu-devel@nongnu.org; Fri, 15 Dec 2017 12:17:03 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E04202CE95C for ; Fri, 15 Dec 2017 17:17:02 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-102.ams2.redhat.com [10.36.117.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 786757F5C1; Fri, 15 Dec 2017 17:17:01 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, berrange@redhat.com Date: Fri, 15 Dec 2017 17:16:54 +0000 Message-Id: <20171215171655.7818-2-dgilbert@redhat.com> In-Reply-To: <20171215171655.7818-1-dgilbert@redhat.com> References: <20171215171655.7818-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 15 Dec 2017 17:17:02 +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] [PATCH 1/2] migration: Allow migrate_fd_connect to take an Error * 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: peterx@redhat.com, quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Allow whatever is performing the connection to pass migrate_fd_connect an error to indicate there was a problem during connection, an allow us to clean up. The caller must free the error. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela --- migration/channel.c | 2 +- migration/migration.c | 7 ++++++- migration/migration.h | 2 +- migration/rdma.c | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/migration/channel.c b/migration/channel.c index 70ec7ea3b7..fdb7ddbd17 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -78,6 +78,6 @@ void migration_channel_connect(MigrationState *s, =20 s->to_dst_file =3D f; =20 - migrate_fd_connect(s); + migrate_fd_connect(s, NULL); } } diff --git a/migration/migration.c b/migration/migration.c index 4de3b551fe..10a4260f27 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2333,10 +2333,15 @@ static void *migration_thread(void *opaque) return NULL; } =20 -void migrate_fd_connect(MigrationState *s) +void migrate_fd_connect(MigrationState *s, Error *error_in) { s->expected_downtime =3D s->parameters.downtime_limit; s->cleanup_bh =3D qemu_bh_new(migrate_fd_cleanup, s); + if (error_in) { + migrate_fd_error(s, error_in); + migrate_fd_cleanup(s); + return; + } =20 qemu_file_set_blocking(s->to_dst_file, true); qemu_file_set_rate_limit(s->to_dst_file, diff --git a/migration/migration.h b/migration/migration.h index 663415fe48..e67e5e87c2 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -168,7 +168,7 @@ uint64_t migrate_max_downtime(void); void migrate_set_error(MigrationState *s, const Error *error); void migrate_fd_error(MigrationState *s, const Error *error); =20 -void migrate_fd_connect(MigrationState *s); +void migrate_fd_connect(MigrationState *s, Error *error_in); =20 MigrationState *migrate_init(void); bool migration_is_blocked(Error **errp); diff --git a/migration/rdma.c b/migration/rdma.c index ca56594328..cc7049c594 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3758,7 +3758,7 @@ void rdma_start_outgoing_migration(void *opaque, trace_rdma_start_outgoing_migration_after_rdma_connect(); =20 s->to_dst_file =3D qemu_fopen_rdma(rdma, "wb"); - migrate_fd_connect(s); + migrate_fd_connect(s, NULL); return; err: g_free(rdma); --=20 2.14.3 From nobody Wed Oct 29 05:57:25 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513358417177799.3379881160147; Fri, 15 Dec 2017 09:20:17 -0800 (PST) Received: from localhost ([::1]:47842 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePteQ-0002Gn-HD for importer@patchew.org; Fri, 15 Dec 2017 12:19:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35862) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePtbe-0000cH-J4 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 12:17:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePtbd-0001uv-D8 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 12:17:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32826) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePtbd-0001rP-3j for qemu-devel@nongnu.org; Fri, 15 Dec 2017 12:17:05 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3DECE83F3D for ; Fri, 15 Dec 2017 17:17:04 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-102.ams2.redhat.com [10.36.117.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 354D6619DC; Fri, 15 Dec 2017 17:17:03 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, berrange@redhat.com Date: Fri, 15 Dec 2017 17:16:55 +0000 Message-Id: <20171215171655.7818-3-dgilbert@redhat.com> In-Reply-To: <20171215171655.7818-1-dgilbert@redhat.com> References: <20171215171655.7818-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 15 Dec 2017 17:17:04 +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] [PATCH 2/2] 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: peterx@redhat.com, quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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); =20 - if (s->parameters.tls_creds && - *s->parameters.tls_creds && - !object_dynamic_cast(OBJECT(ioc), - TYPE_QIO_CHANNEL_TLS)) { - Error *local_err =3D 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 =3D 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 =3D qemu_fopen_channel_output(ioc); =20 - s->to_dst_file =3D f; + s->to_dst_file =3D f; =20 - 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); =20 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, con= st char *command, Error } =20 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)); } =20 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 ** } =20 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)); } =20 diff --git a/migration/socket.c b/migration/socket.c index dee869044a..eff685f7b2 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -79,12 +79,10 @@ static void socket_outgoing_migration(QIOTask *task, =20 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)); } =20 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, =20 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)); } =20 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=3D%d postcopy-stat= e=3D%d" process_incoming_migration_co_postcopy_end_main(void) "" migration_set_incoming_channel(void *ioc, const char *ioctype) "ioc=3D%p i= octype=3D%s" -migration_set_outgoing_channel(void *ioc, const char *ioctype, const char = *hostname) "ioc=3D%p ioctype=3D%s hostname=3D%s" +migration_set_outgoing_channel(void *ioc, const char *ioctype, const char = *hostname, void *err) "ioc=3D%p ioctype=3D%s hostname=3D%s err=3D%p" =20 # migration/rdma.c qemu_rdma_accept_incoming_migration(void) "" --=20 2.14.3