From nobody Sat Feb 7 02:29:44 2026 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 1504083550372719.6073053320597; Wed, 30 Aug 2017 01:59:10 -0700 (PDT) Received: from localhost ([::1]:49138 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmyq4-0004yn-5e for importer@patchew.org; Wed, 30 Aug 2017 04:59:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmyTY-0001FE-7B for qemu-devel@nongnu.org; Wed, 30 Aug 2017 04:35:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmyTX-0004lf-3j for qemu-devel@nongnu.org; Wed, 30 Aug 2017 04:35:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43892) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmyTW-0004ki-R7 for qemu-devel@nongnu.org; Wed, 30 Aug 2017 04:35:51 -0400 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 CBD058046A; Wed, 30 Aug 2017 08:35:49 +0000 (UTC) Received: from pxdev.xzpeter.org.com (dhcp-14-103.nay.redhat.com [10.66.14.103]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6833184792; Wed, 30 Aug 2017 08:35:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CBD058046A Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 30 Aug 2017 16:32:29 +0800 Message-Id: <1504081950-2528-33-git-send-email-peterx@redhat.com> In-Reply-To: <1504081950-2528-1-git-send-email-peterx@redhat.com> References: <1504081950-2528-1-git-send-email-peterx@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.28]); Wed, 30 Aug 2017 08:35:49 +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] [RFC v2 32/33] migration: allow migrate_incoming for paused VM 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: Laurent Vivier , Andrea Arcangeli , Juan Quintela , Alexey Perevalov , peterx@redhat.com, "Dr . David Alan Gilbert" 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" migrate_incoming command is previously only used when we were providing "-incoming defer" in the command line, to defer the incoming migration channel creation. However there is similar requirement when we are paused during postcopy migration. The old incoming channel might have been destroyed already. We may need another new channel for the recovery to happen. This patch leveraged the same interface, but allows the user to specify incoming migration channel even for paused postcopy. Meanwhile, now migration listening ports are always detached manually using the tag, rather than using return values of dispatchers. Signed-off-by: Peter Xu --- migration/exec.c | 2 +- migration/fd.c | 2 +- migration/migration.c | 39 +++++++++++++++++++++++++++++---------- migration/socket.c | 2 +- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/migration/exec.c b/migration/exec.c index ef1fb4c..26fc37d 100644 --- a/migration/exec.c +++ b/migration/exec.c @@ -49,7 +49,7 @@ static gboolean exec_accept_incoming_migration(QIOChannel= *ioc, { migration_channel_process_incoming(ioc); object_unref(OBJECT(ioc)); - return FALSE; /* unregister */ + return TRUE; /* keep it registered */ } =20 /* diff --git a/migration/fd.c b/migration/fd.c index e9a548c..7d0aefa 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -49,7 +49,7 @@ static gboolean fd_accept_incoming_migration(QIOChannel *= ioc, { migration_channel_process_incoming(ioc); object_unref(OBJECT(ioc)); - return FALSE; /* unregister */ + return TRUE; /* keep it registered */ } =20 /* diff --git a/migration/migration.c b/migration/migration.c index daf356b..5812478 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -175,6 +175,17 @@ void migration_incoming_state_destroy(void) qemu_event_destroy(&mis->main_thread_load_event); } =20 +static bool migrate_incoming_detach_listen(MigrationIncomingState *mis) +{ + if (mis->listen_task_tag) { + /* Never fail */ + g_source_remove(mis->listen_task_tag); + mis->listen_task_tag =3D 0; + return true; + } + return false; +} + static void migrate_generate_event(int new_state) { if (migrate_use_events()) { @@ -432,10 +443,9 @@ void migration_fd_process_incoming(QEMUFile *f) =20 /* * When reach here, we should not need the listening port any - * more. We'll detach the listening task soon, let's reset the - * listen task tag. + * more. Detach the listening port explicitly. */ - mis->listen_task_tag =3D 0; + migrate_incoming_detach_listen(mis); } =20 /* @@ -1291,14 +1301,25 @@ void migrate_del_blocker(Error *reason) void qmp_migrate_incoming(const char *uri, Error **errp) { Error *local_err =3D NULL; - static bool once =3D true; + MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 - if (!deferred_incoming) { - error_setg(errp, "For use with '-incoming defer'"); + if (!deferred_incoming && + mis->state !=3D MIGRATION_STATUS_POSTCOPY_PAUSED) { + error_setg(errp, "For use with '-incoming defer'" + " or PAUSED postcopy migration only."); return; } - if (!once) { - error_setg(errp, "The incoming migration has already been started"= ); + + /* + * Destroy existing listening task if exist. Logically this should + * not really happen at all (for either deferred migration or + * postcopy migration, we should both detached the listening + * task). So raise an error but still we safely detach it. + */ + if (migrate_incoming_detach_listen(mis)) { + error_report("%s: detected existing listen channel, " + "while it should not exist", __func__); + /* Continue */ } =20 qemu_start_incoming_migration(uri, &local_err); @@ -1307,8 +1328,6 @@ void qmp_migrate_incoming(const char *uri, Error **er= rp) error_propagate(errp, local_err); return; } - - once =3D false; } =20 bool migration_is_blocked(Error **errp) diff --git a/migration/socket.c b/migration/socket.c index 6ee51ef..e3e453f 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -154,7 +154,7 @@ static gboolean socket_accept_incoming_migration(QIOCha= nnel *ioc, out: /* Close listening socket as its no longer needed */ qio_channel_close(ioc, NULL); - return FALSE; /* unregister */ + return TRUE; /* keep it registered */ } =20 =20 --=20 2.7.4