From nobody Sun Jan 25 11:58:45 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1769198271; cv=none; d=zohomail.com; s=zohoarc; b=W2mbCp5GvrJmRj0ODZSBjCLqn6kvPEz1ZGGN4mHuMw53HbJI9nPKk9ixYusk3whbKRwXcvQqO+S8KFOXvxz1jhJSS4ceIDrx0/pyu3IfxdnvcqsVroPr/oB25fr5ILFHH+IXgt0fpv1c4Y1IOjC7BJX3v98XfDIjzcWXdZq1JAw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769198271; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/YWHCUSygdNx4mlYt6JKjPtldreXCVz9pqJ1aGkeTRo=; b=X/KIwe4smvCworQDcIkiNVAG+6Tsg12YusMsoy2M17iUmi2f4wgcWv8asB+G88GOQk/VRig69IQ2UG7HQqSMc9q8d+BfXUfbsYqbPdX3DCZ5AjSwMP9dLnQs6QMDRVKDIcEYH6JPgiwYK43B2kS8FHzLLE8dIDdfHjC9Oukl9gA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1769198271985384.4362381667952; Fri, 23 Jan 2026 11:57:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vjNFT-0004ue-Gr; Fri, 23 Jan 2026 14:55:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vjNFR-0004jl-Ns for qemu-devel@nongnu.org; Fri, 23 Jan 2026 14:55:13 -0500 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vjNFP-0003nP-2j for qemu-devel@nongnu.org; Fri, 23 Jan 2026 14:55:13 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id AD4A15BCCC; Fri, 23 Jan 2026 19:54:37 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 5A6201395E; Fri, 23 Jan 2026 19:54:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id YBL6BvzRc2lFZQAAD6G6ig (envelope-from ); Fri, 23 Jan 2026 19:54:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1769198077; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/YWHCUSygdNx4mlYt6JKjPtldreXCVz9pqJ1aGkeTRo=; b=W6ZdejUvkjTiPVIfULumR5hH3W2LYzGtN1NePzJo19LowUfwoUVC0BxwaWJlAF44FIdiJQ tmwHCqCJ6Qp+wbL6N8L+/I33mc4vbtktJOMBaD6yKfhw8D0rOdHDOojK90N4Y7NSM9S9Ba 7ZevDJm9k/Wk/NjGdYWWKsKHNZZKJdA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1769198077; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/YWHCUSygdNx4mlYt6JKjPtldreXCVz9pqJ1aGkeTRo=; b=3MxbmZgtZAn17vWOiO8WCnTPFBY0lfg/WkeMkAEDk7I+ING0iXHYw9N5+5X3zMsqvd4kev FzY/xw34Jyyu1DBQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=W6ZdejUv; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=3MxbmZgt DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1769198077; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/YWHCUSygdNx4mlYt6JKjPtldreXCVz9pqJ1aGkeTRo=; b=W6ZdejUvkjTiPVIfULumR5hH3W2LYzGtN1NePzJo19LowUfwoUVC0BxwaWJlAF44FIdiJQ tmwHCqCJ6Qp+wbL6N8L+/I33mc4vbtktJOMBaD6yKfhw8D0rOdHDOojK90N4Y7NSM9S9Ba 7ZevDJm9k/Wk/NjGdYWWKsKHNZZKJdA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1769198077; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/YWHCUSygdNx4mlYt6JKjPtldreXCVz9pqJ1aGkeTRo=; b=3MxbmZgtZAn17vWOiO8WCnTPFBY0lfg/WkeMkAEDk7I+ING0iXHYw9N5+5X3zMsqvd4kev FzY/xw34Jyyu1DBQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Prasad Pandit Subject: [PULL 23/36] migration: Handle error in the early async paths Date: Fri, 23 Jan 2026 16:53:38 -0300 Message-ID: <20260123195352.12850-24-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260123195352.12850-1-farosas@suse.de> References: <20260123195352.12850-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_COUNT_TWO(0.00)[2]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Score: -3.01 X-Rspamd-Queue-Id: AD4A15BCCC X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1769198273984154100 Content-Type: text/plain; charset="utf-8" Simplify migration_channel_connect() and migration_connect() to not take an error as input. Move the error handling into the paths that generate the error. To achieve this, call migration_connect_error_propagate() from socket.c and tls.c, which are the async paths. For the sync paths, the handling is done as normal by returning all the way to qmp_migrate_finish(), except that now the sync paths don't pass the error forward into migration_connect() anymore. Reviewed-by: Peter Xu Reviewed-by: Prasad Pandit Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-13-farosas@sus= e.de Signed-off-by: Fabiano Rosas --- migration/channel.c | 49 ++++++++++++++++++++---------------------- migration/channel.h | 4 +--- migration/exec.c | 2 +- migration/fd.c | 2 +- migration/file.c | 2 +- migration/migration.c | 11 ++-------- migration/migration.h | 3 ++- migration/rdma.c | 2 +- migration/socket.c | 17 ++++++++------- migration/tls.c | 14 ++++++------ migration/tls.h | 3 +-- migration/trace-events | 2 +- 12 files changed, 50 insertions(+), 61 deletions(-) diff --git a/migration/channel.c b/migration/channel.c index ba14f66d85..26cb7bf059 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -60,38 +60,35 @@ void migration_channel_process_incoming(QIOChannel *ioc) * * @s: Current migration state * @ioc: Channel to which we are connecting - * @error: Error indicating failure to connect, free'd here */ -void migration_channel_connect(MigrationState *s, - QIOChannel *ioc, - Error *error) +void migration_channel_connect(MigrationState *s, QIOChannel *ioc) { - trace_migration_set_outgoing_channel( - ioc, object_get_typename(OBJECT(ioc)), error); + trace_migration_set_outgoing_channel(ioc, object_get_typename(OBJECT(i= oc))); =20 - if (!error) { - if (migrate_channel_requires_tls_upgrade(ioc)) { - migration_tls_channel_connect(s, ioc, &error); + if (migrate_channel_requires_tls_upgrade(ioc)) { + Error *local_err =3D NULL; =20 - if (!error) { - /* tls_channel_connect will call back to this - * function after the TLS handshake, - * so we mustn't call migration_connect until then - */ - - return; - } - } else { - QEMUFile *f =3D qemu_file_new_output(ioc); - - migration_ioc_register_yank(ioc); - - qemu_mutex_lock(&s->qemu_file_lock); - s->to_dst_file =3D f; - qemu_mutex_unlock(&s->qemu_file_lock); + migration_tls_channel_connect(s, ioc, &local_err); + if (local_err) { + migration_connect_error_propagate(s, local_err); } + + /* + * async: the above will call back to this function after + * the TLS handshake is successfully completed. + */ + return; } - migration_connect(s, error); + + QEMUFile *f =3D qemu_file_new_output(ioc); + + migration_ioc_register_yank(ioc); + + qemu_mutex_lock(&s->qemu_file_lock); + s->to_dst_file =3D f; + qemu_mutex_unlock(&s->qemu_file_lock); + + migration_connect(s); } =20 =20 diff --git a/migration/channel.h b/migration/channel.h index 2215091323..ccfeaaef18 100644 --- a/migration/channel.h +++ b/migration/channel.h @@ -20,9 +20,7 @@ =20 void migration_channel_process_incoming(QIOChannel *ioc); =20 -void migration_channel_connect(MigrationState *s, - QIOChannel *ioc, - Error *error_in); +void migration_channel_connect(MigrationState *s, QIOChannel *ioc); =20 int migration_channel_read_peek(QIOChannel *ioc, const char *buf, diff --git a/migration/exec.c b/migration/exec.c index 78fe0fff13..d83a07435a 100644 --- a/migration/exec.c +++ b/migration/exec.c @@ -55,7 +55,7 @@ void exec_start_outgoing_migration(MigrationState *s, str= List *command, } =20 qio_channel_set_name(ioc, "migration-exec-outgoing"); - migration_channel_connect(s, ioc, NULL); + migration_channel_connect(s, ioc); object_unref(OBJECT(ioc)); } =20 diff --git a/migration/fd.c b/migration/fd.c index b92bc4c4eb..f5cf58e6ee 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -72,7 +72,7 @@ void fd_start_outgoing_migration(MigrationState *s, const= char *fdname, Error ** } =20 qio_channel_set_name(ioc, "migration-fd-outgoing"); - migration_channel_connect(s, ioc, NULL); + migration_channel_connect(s, ioc); object_unref(OBJECT(ioc)); } =20 diff --git a/migration/file.c b/migration/file.c index c490f2b219..7bb9c1c79f 100644 --- a/migration/file.c +++ b/migration/file.c @@ -122,7 +122,7 @@ void file_start_outgoing_migration(MigrationState *s, return; } qio_channel_set_name(ioc, "migration-file-outgoing"); - migration_channel_connect(s, ioc, NULL); + migration_channel_connect(s, ioc); } =20 static gboolean file_accept_incoming_migration(QIOChannel *ioc, diff --git a/migration/migration.c b/migration/migration.c index a78c2f4840..82e431b637 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1569,7 +1569,7 @@ static void migrate_error_free(MigrationState *s) s->error =3D NULL; } =20 -static void migration_connect_error_propagate(MigrationState *s, Error *er= ror) +void migration_connect_error_propagate(MigrationState *s, Error *error) { MigrationStatus current =3D s->state; MigrationStatus next =3D MIGRATION_STATUS_NONE; @@ -4020,7 +4020,7 @@ fail_setup: return NULL; } =20 -void migration_connect(MigrationState *s, Error *error_in) +void migration_connect(MigrationState *s) { Error *local_err =3D NULL; uint64_t rate_limit; @@ -4028,13 +4028,6 @@ void migration_connect(MigrationState *s, Error *err= or_in) int ret; =20 s->expected_downtime =3D migrate_downtime_limit(); - if (error_in) { - migration_connect_error_propagate(s, error_in); - if (s->error) { - error_report_err(error_copy(s->error)); - } - return; - } =20 if (resume) { /* This is a resumed migration */ diff --git a/migration/migration.h b/migration/migration.h index 8b55d4741a..d134881eaf 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -533,10 +533,11 @@ void migration_incoming_process(void); =20 bool migration_has_all_channels(void); =20 +void migration_connect_error_propagate(MigrationState *s, Error *error); void migrate_error_propagate(MigrationState *s, Error *error); bool migrate_has_error(MigrationState *s); =20 -void migration_connect(MigrationState *s, Error *error_in); +void migration_connect(MigrationState *s); =20 int migration_call_notifiers(MigrationEventType type, Error **errp); =20 diff --git a/migration/rdma.c b/migration/rdma.c index cced173379..c41c3e24b9 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3996,7 +3996,7 @@ void rdma_start_outgoing_migration(void *opaque, =20 s->to_dst_file =3D rdma_new_output(rdma); s->rdma_migration =3D true; - migration_connect(s, NULL); + migration_connect(s); return; return_path_err: qemu_rdma_cleanup(rdma); diff --git a/migration/socket.c b/migration/socket.c index 426f363b99..676fe26712 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -59,24 +59,25 @@ static void socket_outgoing_migration(QIOTask *task, gpointer opaque) { struct SocketConnectData *data =3D opaque; - QIOChannel *sioc =3D QIO_CHANNEL(qio_task_get_source(task)); + g_autoptr(QIOChannel) sioc =3D QIO_CHANNEL(qio_task_get_source(task)); Error *err =3D NULL; =20 if (qio_task_propagate_error(task, &err)) { - trace_migration_socket_outgoing_error(error_get_pretty(err)); - goto out; + goto fail; } =20 - trace_migration_socket_outgoing_connected(); - if (migrate_zero_copy_send() && !qio_channel_has_feature(sioc, QIO_CHANNEL_FEATURE_WRITE_ZERO_COPY= )) { error_setg(&err, "Zero copy send feature not detected in host kern= el"); + goto fail; } =20 -out: - migration_channel_connect(data->s, sioc, err); - object_unref(OBJECT(sioc)); + trace_migration_socket_outgoing_connected(); + migration_channel_connect(data->s, sioc); + return; +fail: + trace_migration_socket_outgoing_error(error_get_pretty(err)); + migration_connect_error_propagate(data->s, err); } =20 void socket_start_outgoing_migration(MigrationState *s, diff --git a/migration/tls.c b/migration/tls.c index 82f58cbc78..837b08294f 100644 --- a/migration/tls.c +++ b/migration/tls.c @@ -104,16 +104,17 @@ static void migration_tls_outgoing_handshake(QIOTask = *task, gpointer opaque) { MigrationState *s =3D opaque; - QIOChannel *ioc =3D QIO_CHANNEL(qio_task_get_source(task)); + g_autoptr(QIOChannel) ioc =3D QIO_CHANNEL(qio_task_get_source(task)); Error *err =3D NULL; =20 if (qio_task_propagate_error(task, &err)) { trace_migration_tls_outgoing_handshake_error(error_get_pretty(err)= ); - } else { - trace_migration_tls_outgoing_handshake_complete(); + migration_connect_error_propagate(s, err); + return; } - migration_channel_connect(s, ioc, err); - object_unref(OBJECT(ioc)); + + trace_migration_tls_outgoing_handshake_complete(); + migration_channel_connect(s, ioc); } =20 QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc, @@ -129,8 +130,7 @@ QIOChannelTLS *migration_tls_client_create(QIOChannel *= ioc, return qio_channel_tls_new_client(ioc, creds, migrate_tls_hostname(), = errp); } =20 -void migration_tls_channel_connect(MigrationState *s, - QIOChannel *ioc, +void migration_tls_channel_connect(MigrationState *s, QIOChannel *ioc, Error **errp) { QIOChannelTLS *tioc; diff --git a/migration/tls.h b/migration/tls.h index 7cd9c76013..0e86d38862 100644 --- a/migration/tls.h +++ b/migration/tls.h @@ -29,8 +29,7 @@ void migration_tls_channel_process_incoming(QIOChannel *i= oc, Error **errp); QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc, Error **errp); =20 -void migration_tls_channel_connect(MigrationState *s, - QIOChannel *ioc, +void migration_tls_channel_connect(MigrationState *s, QIOChannel *ioc, Error **errp); void migration_tls_channel_end(QIOChannel *ioc, Error **errp); /* Whether the QIO channel requires further TLS handshake? */ diff --git a/migration/trace-events b/migration/trace-events index da8f909cac..cbf10d0b63 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -204,7 +204,7 @@ migration_transferred_bytes(uint64_t qemu_file, uint64_= t multifd, uint64_t rdma) =20 # channel.c 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, void *err) = "ioc=3D%p ioctype=3D%s err=3D%p" +migration_set_outgoing_channel(void *ioc, const char *ioctype) "ioc=3D%p i= octype=3D%s" =20 # global_state.c migrate_state_too_big(void) "" --=20 2.51.0