From nobody Sat May 18 13:16:24 2024 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530106411677835.0286469796004; Wed, 27 Jun 2018 06:33:31 -0700 (PDT) Received: from localhost ([::1]:59252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYAZS-0005fg-Es for importer@patchew.org; Wed, 27 Jun 2018 09:33:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55693) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYAPQ-0005uI-AF for qemu-devel@nongnu.org; Wed, 27 Jun 2018 09:22:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYAPP-0003Yr-EP for qemu-devel@nongnu.org; Wed, 27 Jun 2018 09:22:56 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50456 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fYAPP-0003YH-9r for qemu-devel@nongnu.org; Wed, 27 Jun 2018 09:22:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E8E54805A530 for ; Wed, 27 Jun 2018 13:22:54 +0000 (UTC) Received: from xz-mi.redhat.com (ovpn-12-57.pek2.redhat.com [10.72.12.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id A446E1C677; Wed, 27 Jun 2018 13:22:52 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 27 Jun 2018 21:22:43 +0800 Message-Id: <20180627132246.5576-2-peterx@redhat.com> In-Reply-To: <20180627132246.5576-1-peterx@redhat.com> References: <20180627132246.5576-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 27 Jun 2018 13:22:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 27 Jun 2018 13:22:54 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v3 1/4] migration: delay postcopy paused state 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: "Dr . David Alan Gilbert" , peterx@redhat.com, Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Before this patch we firstly setup the postcopy-paused state then we clean up the QEMUFile handles. That can be racy if there is a very fast "migrate-recover" command running in parallel. Fix that up. Reported-by: Peter Maydell Reviewed-by: Juan Quintela Signed-off-by: Peter Xu Tested-by: Balamuruhan S --- migration/savevm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index c2f34ffc7c..851d74e8b6 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2194,9 +2194,6 @@ static bool postcopy_pause_incoming(MigrationIncoming= State *mis) /* Clear the triggered bit to allow one recovery */ mis->postcopy_recover_triggered =3D false; =20 - migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, - MIGRATION_STATUS_POSTCOPY_PAUSED); - assert(mis->from_src_file); qemu_file_shutdown(mis->from_src_file); qemu_fclose(mis->from_src_file); @@ -2209,6 +2206,9 @@ static bool postcopy_pause_incoming(MigrationIncoming= State *mis) mis->to_src_file =3D NULL; qemu_mutex_unlock(&mis->rp_mutex); =20 + migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, + MIGRATION_STATUS_POSTCOPY_PAUSED); + /* Notify the fault thread for the invalidated file handle */ postcopy_fault_thread_notify(mis); =20 --=20 2.17.1 From nobody Sat May 18 13:16:24 2024 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530106932384907.5015890925624; Wed, 27 Jun 2018 06:42:12 -0700 (PDT) Received: from localhost ([::1]:59319 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYAi3-00048l-JJ for importer@patchew.org; Wed, 27 Jun 2018 09:42:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYAPT-0005vl-Jv for qemu-devel@nongnu.org; Wed, 27 Jun 2018 09:23:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYAPS-0003d6-I7 for qemu-devel@nongnu.org; Wed, 27 Jun 2018 09:22:59 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50458 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fYAPS-0003cT-9J for qemu-devel@nongnu.org; Wed, 27 Jun 2018 09:22:58 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E1EC2805A530 for ; Wed, 27 Jun 2018 13:22:57 +0000 (UTC) Received: from xz-mi.redhat.com (ovpn-12-57.pek2.redhat.com [10.72.12.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D06E1C674; Wed, 27 Jun 2018 13:22:55 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 27 Jun 2018 21:22:44 +0800 Message-Id: <20180627132246.5576-3-peterx@redhat.com> In-Reply-To: <20180627132246.5576-1-peterx@redhat.com> References: <20180627132246.5576-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 27 Jun 2018 13:22:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 27 Jun 2018 13:22:57 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v3 2/4] migration: move income process out of multifd 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: "Dr . David Alan Gilbert" , peterx@redhat.com, Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Move the call to migration_incoming_process() out of multifd code. It's a bit strange that we can migration generic calls in multifd code. Instead, let multifd_recv_new_channel() return a boolean showing whether it's ready to continue the incoming migration. Signed-off-by: Peter Xu Reviewed-by: Juan Quintela Tested-by: Balamuruhan S --- migration/ram.h | 2 +- migration/migration.c | 5 ++++- migration/ram.c | 11 +++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/migration/ram.h b/migration/ram.h index d386f4d641..457bf54b8c 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -46,7 +46,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); -void multifd_recv_new_channel(QIOChannel *ioc); +bool multifd_recv_new_channel(QIOChannel *ioc); =20 uint64_t ram_pagesize_summary(void); int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t = len); diff --git a/migration/migration.c b/migration/migration.c index e1eaa97df4..6ecea2de30 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -507,7 +507,10 @@ void migration_ioc_process_incoming(QIOChannel *ioc) migration_incoming_setup(f); return; } - multifd_recv_new_channel(ioc); + + if (multifd_recv_new_channel(ioc)) { + migration_incoming_process(); + } } =20 /** diff --git a/migration/ram.c b/migration/ram.c index cd5f55117d..52167d5142 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -873,7 +873,8 @@ bool multifd_recv_all_channels_created(void) return thread_count =3D=3D atomic_read(&multifd_recv_state->count); } =20 -void multifd_recv_new_channel(QIOChannel *ioc) +/* Return true if multifd is ready for the migration, otherwise false */ +bool multifd_recv_new_channel(QIOChannel *ioc) { MultiFDRecvParams *p; Error *local_err =3D NULL; @@ -882,7 +883,7 @@ void multifd_recv_new_channel(QIOChannel *ioc) id =3D multifd_recv_initial_packet(ioc, &local_err); if (id < 0) { multifd_recv_terminate_threads(local_err); - return; + return false; } =20 p =3D &multifd_recv_state->params[id]; @@ -890,7 +891,7 @@ void multifd_recv_new_channel(QIOChannel *ioc) error_setg(&local_err, "multifd: received id '%d' already setup'", id); multifd_recv_terminate_threads(local_err); - return; + return false; } p->c =3D ioc; object_ref(OBJECT(ioc)); @@ -899,9 +900,7 @@ void multifd_recv_new_channel(QIOChannel *ioc) qemu_thread_create(&p->thread, p->name, multifd_recv_thread, p, QEMU_THREAD_JOINABLE); atomic_inc(&multifd_recv_state->count); - if (multifd_recv_state->count =3D=3D migrate_multifd_channels()) { - migration_incoming_process(); - } + return multifd_recv_state->count =3D=3D migrate_multifd_channels(); } =20 /** --=20 2.17.1 From nobody Sat May 18 13:16:24 2024 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530107088173897.1352884186456; Wed, 27 Jun 2018 06:44:48 -0700 (PDT) Received: from localhost ([::1]:59336 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYAkZ-0006Bu-EO for importer@patchew.org; Wed, 27 Jun 2018 09:44:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYAPY-0005zj-BU for qemu-devel@nongnu.org; Wed, 27 Jun 2018 09:23:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYAPV-0003g8-6s for qemu-devel@nongnu.org; Wed, 27 Jun 2018 09:23:04 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50460 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fYAPV-0003fh-3D for qemu-devel@nongnu.org; Wed, 27 Jun 2018 09:23:01 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B7128805A530 for ; Wed, 27 Jun 2018 13:23:00 +0000 (UTC) Received: from xz-mi.redhat.com (ovpn-12-57.pek2.redhat.com [10.72.12.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 960F31C674; Wed, 27 Jun 2018 13:22:58 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 27 Jun 2018 21:22:45 +0800 Message-Id: <20180627132246.5576-4-peterx@redhat.com> In-Reply-To: <20180627132246.5576-1-peterx@redhat.com> References: <20180627132246.5576-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 27 Jun 2018 13:23:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 27 Jun 2018 13:23:00 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v3 3/4] migration: unbreak postcopy recovery 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: "Dr . David Alan Gilbert" , peterx@redhat.com, Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The whole postcopy recovery logic was accidentally broken. We need to fix it in two steps. This is the first step that we should do the recovery when needed. It was bypassed before after commit 36c2f8be2c. Introduce postcopy_try_recovery() helper for the postcopy recovery logic. Call it both in migration_fd_process_incoming() and migration_ioc_process_incoming(). Fixes: 36c2f8be2c ("migration: Delay start of migration main routines") Signed-off-by: Peter Xu Reviewed-by: Juan Quintela Tested-by: Balamuruhan S --- migration/migration.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 6ecea2de30..0a0db49817 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -466,7 +466,8 @@ void migration_incoming_process(void) qemu_coroutine_enter(co); } =20 -void migration_fd_process_incoming(QEMUFile *f) +/* Returns true if recovered from a paused migration, otherwise false */ +static bool postcopy_try_recover(QEMUFile *f) { MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 @@ -491,11 +492,20 @@ void migration_fd_process_incoming(QEMUFile *f) * that source is ready to reply to page requests. */ qemu_sem_post(&mis->postcopy_pause_sem_dst); - } else { - /* New incoming migration */ - migration_incoming_setup(f); - migration_incoming_process(); + return true; + } + + return false; +} + +void migration_fd_process_incoming(QEMUFile *f) +{ + if (postcopy_try_recover(f)) { + return; } + + migration_incoming_setup(f); + migration_incoming_process(); } =20 void migration_ioc_process_incoming(QIOChannel *ioc) @@ -504,6 +514,9 @@ void migration_ioc_process_incoming(QIOChannel *ioc) =20 if (!mis->from_src_file) { QEMUFile *f =3D qemu_fopen_channel_input(ioc); + if (postcopy_try_recover(f)) { + return; + } migration_incoming_setup(f); return; } --=20 2.17.1 From nobody Sat May 18 13:16:24 2024 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530106568522394.4919358378503; Wed, 27 Jun 2018 06:36:08 -0700 (PDT) Received: from localhost ([::1]:59274 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYAcB-0007oU-Lc for importer@patchew.org; Wed, 27 Jun 2018 09:36:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYAPZ-00061C-6g for qemu-devel@nongnu.org; Wed, 27 Jun 2018 09:23:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYAPY-0003jT-5q for qemu-devel@nongnu.org; Wed, 27 Jun 2018 09:23:05 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50464 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fYAPY-0003it-0R for qemu-devel@nongnu.org; Wed, 27 Jun 2018 09:23:04 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A252581663D8 for ; Wed, 27 Jun 2018 13:23:03 +0000 (UTC) Received: from xz-mi.redhat.com (ovpn-12-57.pek2.redhat.com [10.72.12.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A0CD1C674; Wed, 27 Jun 2018 13:23:01 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 27 Jun 2018 21:22:46 +0800 Message-Id: <20180627132246.5576-5-peterx@redhat.com> In-Reply-To: <20180627132246.5576-1-peterx@redhat.com> References: <20180627132246.5576-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 27 Jun 2018 13:23:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 27 Jun 2018 13:23:03 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v3 4/4] migration: unify incoming processing 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: "Dr . David Alan Gilbert" , peterx@redhat.com, Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is the 2nd patch to unbreak postcopy recovery. Let's unify the migration_incoming_process() call at a single place rather than calling it in connection setup codes. This fixes a problem that we will go into incoming migration procedure even if we are trying to recovery from a paused postcopy migration. Fixes: 36c2f8be2c ("migration: Delay start of migration main routines") Signed-off-by: Peter Xu Reviewed-by: Juan Quintela Tested-by: Balamuruhan S --- migration/exec.c | 3 --- migration/fd.c | 3 --- migration/migration.c | 18 ++++++++++++++++-- migration/socket.c | 5 ----- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/migration/exec.c b/migration/exec.c index 0bbeb63c97..375d2e1b54 100644 --- a/migration/exec.c +++ b/migration/exec.c @@ -49,9 +49,6 @@ static gboolean exec_accept_incoming_migration(QIOChannel= *ioc, { migration_channel_process_incoming(ioc); object_unref(OBJECT(ioc)); - if (!migrate_use_multifd()) { - migration_incoming_process(); - } return G_SOURCE_REMOVE; } =20 diff --git a/migration/fd.c b/migration/fd.c index fee34ffdc0..a7c13df4ad 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -49,9 +49,6 @@ static gboolean fd_accept_incoming_migration(QIOChannel *= ioc, { migration_channel_process_incoming(ioc); object_unref(OBJECT(ioc)); - if (!migrate_use_multifd()) { - migration_incoming_process(); - } return G_SOURCE_REMOVE; } =20 diff --git a/migration/migration.c b/migration/migration.c index 0a0db49817..7fc92327d7 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -511,17 +511,31 @@ void migration_fd_process_incoming(QEMUFile *f) void migration_ioc_process_incoming(QIOChannel *ioc) { MigrationIncomingState *mis =3D migration_incoming_get_current(); + bool start_migration; =20 if (!mis->from_src_file) { + /* The first connection (multifd may have multiple) */ QEMUFile *f =3D qemu_fopen_channel_input(ioc); + + /* If it's a recovery, we're done */ if (postcopy_try_recover(f)) { return; } + migration_incoming_setup(f); - return; + + /* + * Common migration only needs one channel, so we can start + * right now. Multifd needs more than one channel, we wait. + */ + start_migration =3D !migrate_use_multifd(); + } else { + /* Multiple connections */ + assert(migrate_use_multifd()); + start_migration =3D multifd_recv_new_channel(ioc); } =20 - if (multifd_recv_new_channel(ioc)) { + if (start_migration) { migration_incoming_process(); } } diff --git a/migration/socket.c b/migration/socket.c index 3456eb76e9..f4c8174400 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -168,12 +168,7 @@ static void socket_accept_incoming_migration(QIONetLis= tener *listener, if (migration_has_all_channels()) { /* Close listening socket as its no longer needed */ qio_net_listener_disconnect(listener); - object_unref(OBJECT(listener)); - - if (!migrate_use_multifd()) { - migration_incoming_process(); - } } } =20 --=20 2.17.1