From nobody Wed Oct 22 13:01:18 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519794872291652.9647345318471; Tue, 27 Feb 2018 21:14:32 -0800 (PST) Received: from localhost ([::1]:42265 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1equ4M-0005Mc-6r for importer@patchew.org; Wed, 28 Feb 2018 00:14:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33556) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqtxG-00080A-IB for qemu-devel@nongnu.org; Wed, 28 Feb 2018 00:07:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqtxD-0000eM-DB for qemu-devel@nongnu.org; Wed, 28 Feb 2018 00:07:02 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47002 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 1eqtxD-0000eB-7f for qemu-devel@nongnu.org; Wed, 28 Feb 2018 00:06:59 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D9CB987ABA for ; Wed, 28 Feb 2018 05:06:58 +0000 (UTC) Received: from xz-mi.redhat.com (ovpn-12-95.pek2.redhat.com [10.72.12.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53D0E2026E04; Wed, 28 Feb 2018 05:06:55 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 28 Feb 2018 13:06:23 +0800 Message-Id: <20180228050633.7410-5-peterx@redhat.com> In-Reply-To: <20180228050633.7410-1-peterx@redhat.com> References: <20180228050633.7410-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 28 Feb 2018 05:06:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 28 Feb 2018 05:06:58 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.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 04/14] migration: let incoming side use thread context 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 , Juan Quintela , Markus Armbruster , peterx@redhat.com, "Dr . David Alan Gilbert" , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini 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 old incoming migration is running in main thread and default gcontext. With the new qio_channel_add_watch_full() we can now let it run in the thread's own gcontext (if there is one). Currently this patch does nothing alone. But when any of the incoming migration is run in another iothread (e.g., the upcoming migrate-recover command), this patch will bind the incoming logic to the iothread instead of the main thread (which may already get page faulted and hanged). RDMA is not considered for now since it's not even using the QIO APIs at all. CC: Juan Quintela CC: Dr. David Alan Gilbert CC: Laurent Vivier Signed-off-by: Peter Xu --- migration/exec.c | 11 ++++++----- migration/fd.c | 11 ++++++----- migration/socket.c | 12 +++++++----- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/migration/exec.c b/migration/exec.c index 0bc5a427dd..f401fc005e 100644 --- a/migration/exec.c +++ b/migration/exec.c @@ -55,6 +55,7 @@ void exec_start_incoming_migration(const char *command, E= rror **errp) { QIOChannel *ioc; const char *argv[] =3D { "/bin/sh", "-c", command, NULL }; + GSource *source; =20 trace_migration_exec_incoming(command); ioc =3D QIO_CHANNEL(qio_channel_command_new_spawn(argv, @@ -65,9 +66,9 @@ void exec_start_incoming_migration(const char *command, E= rror **errp) } =20 qio_channel_set_name(ioc, "migration-exec-incoming"); - qio_channel_add_watch(ioc, - G_IO_IN, - exec_accept_incoming_migration, - NULL, - NULL); + source =3D qio_channel_add_watch_full(ioc, G_IO_IN, + exec_accept_incoming_migration, + NULL, NULL, + g_main_context_get_thread_default(= )); + g_source_unref(source); } diff --git a/migration/fd.c b/migration/fd.c index cd06182d1e..9c593eb3ff 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -55,6 +55,7 @@ void fd_start_incoming_migration(const char *infd, Error = **errp) { QIOChannel *ioc; int fd; + GSource *source; =20 fd =3D strtol(infd, NULL, 0); trace_migration_fd_incoming(fd); @@ -66,9 +67,9 @@ void fd_start_incoming_migration(const char *infd, Error = **errp) } =20 qio_channel_set_name(QIO_CHANNEL(ioc), "migration-fd-incoming"); - qio_channel_add_watch(ioc, - G_IO_IN, - fd_accept_incoming_migration, - NULL, - NULL); + source =3D qio_channel_add_watch_full(ioc, G_IO_IN, + fd_accept_incoming_migration, + NULL, NULL, + g_main_context_get_thread_default(= )); + g_source_unref(source); } diff --git a/migration/socket.c b/migration/socket.c index e090097077..82c330083c 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -164,6 +164,7 @@ static void socket_start_incoming_migration(SocketAddre= ss *saddr, Error **errp) { QIOChannelSocket *listen_ioc =3D qio_channel_socket_new(); + GSource *source; =20 qio_channel_set_name(QIO_CHANNEL(listen_ioc), "migration-socket-listener"); @@ -173,11 +174,12 @@ static void socket_start_incoming_migration(SocketAdd= ress *saddr, return; } =20 - qio_channel_add_watch(QIO_CHANNEL(listen_ioc), - G_IO_IN, - socket_accept_incoming_migration, - listen_ioc, - (GDestroyNotify)object_unref); + source =3D qio_channel_add_watch_full(QIO_CHANNEL(listen_ioc), G_IO_IN, + socket_accept_incoming_migration, + listen_ioc, + (GDestroyNotify)object_unref, + g_main_context_get_thread_default(= )); + g_source_unref(source); } =20 void tcp_start_incoming_migration(const char *host_port, Error **errp) --=20 2.14.3