From nobody Thu Nov 6 10:18:25 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1540818396805325.14662220042453; Mon, 29 Oct 2018 06:06:36 -0700 (PDT) Received: from localhost ([::1]:45446 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gH7Fb-0007ag-Ko for importer@patchew.org; Mon, 29 Oct 2018 09:06:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gH78J-0000HI-64 for qemu-devel@nongnu.org; Mon, 29 Oct 2018 08:59:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gH78I-0002fb-6S for qemu-devel@nongnu.org; Mon, 29 Oct 2018 08:59:03 -0400 Received: from smtp.nue.novell.com ([195.135.221.5]:49561) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gH78H-0002eM-Ss for qemu-devel@nongnu.org; Mon, 29 Oct 2018 08:59:02 -0400 Received: from localhost.localdomain ([45.122.156.254]) by smtp.nue.novell.com with ESMTP (NOT encrypted); Mon, 29 Oct 2018 13:58:57 +0100 From: Fei Li To: qemu-devel@nongnu.org Date: Mon, 29 Oct 2018 20:58:16 +0800 Message-Id: <20181029125818.28720-6-fli@suse.com> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20181029125818.28720-1-fli@suse.com> References: <20181029125818.28720-1-fli@suse.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.135.221.5 Subject: [Qemu-devel] [PATCH RFC v6 5/7] migration: fix the multifd code when receiving less channels 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: quintela@redhat.com, famz@redhat.com, armbru@redhat.com, peterx@redhat.com, dgilbert@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In our current code, when multifd is used during migration, if there is an error before the destination receives all new channels, the source keeps running, however the destination does not exit but keeps waiting until the source is killed deliberately. Fix this by simply killing the destination when it fails to receive packet via some channel. Cc: Dr. David Alan Gilbert Cc: Peter Xu Signed-off-by: Fei Li --- migration/channel.c | 7 ++++++- migration/migration.c | 9 +++++++-- migration/migration.h | 2 +- migration/ram.c | 17 ++++++++++++++--- migration/ram.h | 2 +- 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/migration/channel.c b/migration/channel.c index 33e0e9b82f..572be4245a 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -44,7 +44,12 @@ void migration_channel_process_incoming(QIOChannel *ioc) error_report_err(local_err); } } else { - migration_ioc_process_incoming(ioc); + Error *local_err =3D NULL; + migration_ioc_process_incoming(ioc, &local_err); + if (local_err) { + error_report_err(local_err); + exit(EXIT_FAILURE); + } } } =20 diff --git a/migration/migration.c b/migration/migration.c index 8b36e7f184..87dfc7374f 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -541,7 +541,7 @@ void migration_fd_process_incoming(QEMUFile *f) migration_incoming_process(); } =20 -void migration_ioc_process_incoming(QIOChannel *ioc) +void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) { MigrationIncomingState *mis =3D migration_incoming_get_current(); bool start_migration; @@ -563,9 +563,14 @@ void migration_ioc_process_incoming(QIOChannel *ioc) */ start_migration =3D !migrate_use_multifd(); } else { + Error *local_err =3D NULL; /* Multiple connections */ assert(migrate_use_multifd()); - start_migration =3D multifd_recv_new_channel(ioc); + start_migration =3D multifd_recv_new_channel(ioc, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } } =20 if (start_migration) { diff --git a/migration/migration.h b/migration/migration.h index f7813f8261..7df4d426d0 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -229,7 +229,7 @@ struct MigrationState void migrate_set_state(int *state, int old_state, int new_state); =20 void migration_fd_process_incoming(QEMUFile *f); -void migration_ioc_process_incoming(QIOChannel *ioc); +void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp); void migration_incoming_process(void); =20 bool migration_has_all_channels(void); diff --git a/migration/ram.c b/migration/ram.c index 4db3b3e8f4..8f03afe228 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1072,6 +1072,7 @@ out: static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque) { MultiFDSendParams *p =3D opaque; + MigrationState *s =3D migrate_get_current(); QIOChannel *sioc =3D QIO_CHANNEL(qio_task_get_source(task)); Error *local_err =3D NULL; =20 @@ -1080,6 +1081,7 @@ static void multifd_new_send_channel_async(QIOTask *t= ask, gpointer opaque) } =20 if (qio_task_propagate_error(task, &local_err)) { + migrate_set_state(&s->state, s->state, MIGRATION_STATUS_FAILED); if (multifd_save_cleanup(&local_err) !=3D 0) { migrate_set_error(migrate_get_current(), local_err); } @@ -1337,16 +1339,20 @@ bool multifd_recv_all_channels_created(void) } =20 /* Return true if multifd is ready for the migration, otherwise false */ -bool multifd_recv_new_channel(QIOChannel *ioc) +bool multifd_recv_new_channel(QIOChannel *ioc, Error **errp) { + MigrationIncomingState *mis =3D migration_incoming_get_current(); MultiFDRecvParams *p; Error *local_err =3D NULL; int id; =20 id =3D multifd_recv_initial_packet(ioc, &local_err); if (id < 0) { + error_propagate_prepend(errp, local_err, + "failed to receive packet via multifd channel %x: = ", + multifd_recv_state->count); multifd_recv_terminate_threads(local_err, false); - return false; + goto fail; } =20 p =3D &multifd_recv_state->params[id]; @@ -1354,7 +1360,8 @@ bool multifd_recv_new_channel(QIOChannel *ioc) error_setg(&local_err, "multifd: received id '%d' already setup'", id); multifd_recv_terminate_threads(local_err, true); - return false; + error_propagate(errp, local_err); + goto fail; } p->c =3D ioc; object_ref(OBJECT(ioc)); @@ -1366,6 +1373,10 @@ bool multifd_recv_new_channel(QIOChannel *ioc) QEMU_THREAD_JOINABLE); atomic_inc(&multifd_recv_state->count); return multifd_recv_state->count =3D=3D migrate_multifd_channels(); +fail: + qemu_fclose(mis->from_src_file); + mis->from_src_file =3D NULL; + return false; } =20 /** diff --git a/migration/ram.h b/migration/ram.h index 83ff1bc11a..046d3074be 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -47,7 +47,7 @@ int multifd_save_cleanup(Error **errp); int multifd_load_setup(void); int multifd_load_cleanup(Error **errp); bool multifd_recv_all_channels_created(void); -bool multifd_recv_new_channel(QIOChannel *ioc); +bool multifd_recv_new_channel(QIOChannel *ioc, Error **errp); =20 uint64_t ram_pagesize_summary(void); int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t = len); --=20 2.13.7