From nobody Sun Apr 28 09:48:01 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502778251646448.73866842419636; Mon, 14 Aug 2017 23:24:11 -0700 (PDT) Received: from localhost ([::1]:41774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhVGs-0001y5-2d for importer@patchew.org; Tue, 15 Aug 2017 02:24:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhVFg-0001Eu-Vo for qemu-devel@nongnu.org; Tue, 15 Aug 2017 02:22:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dhVFc-0004sF-20 for qemu-devel@nongnu.org; Tue, 15 Aug 2017 02:22:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50288) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dhVFb-0004s1-Rb for qemu-devel@nongnu.org; Tue, 15 Aug 2017 02:22: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 BCDAFCA360 for ; Tue, 15 Aug 2017 06:17:20 +0000 (UTC) Received: from pxdev.xzpeter.org.com (dhcp-15-224.nay.redhat.com [10.66.15.224]) by smtp.corp.redhat.com (Postfix) with ESMTP id 999615D6A4; Tue, 15 Aug 2017 06:17:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BCDAFCA360 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Tue, 15 Aug 2017 14:17:02 +0800 Message-Id: <1502777827-18874-2-git-send-email-peterx@redhat.com> In-Reply-To: <1502777827-18874-1-git-send-email-peterx@redhat.com> References: <1502777827-18874-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.38]); Tue, 15 Aug 2017 06:17:20 +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 1/6] migration: free SocketAddress where allocated 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 , "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" Freeing the SocketAddress struct in socket_start_incoming_migration is slightly confusing. Let's free the address in the same context where we allocated it. Signed-off-by: Peter Xu --- migration/socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/socket.c b/migration/socket.c index 757d382..9fc6cb3 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -168,7 +168,6 @@ static void socket_start_incoming_migration(SocketAddre= ss *saddr, =20 if (qio_channel_socket_listen_sync(listen_ioc, saddr, errp) < 0) { object_unref(OBJECT(listen_ioc)); - qapi_free_SocketAddress(saddr); return; } =20 @@ -177,7 +176,6 @@ static void socket_start_incoming_migration(SocketAddre= ss *saddr, socket_accept_incoming_migration, listen_ioc, (GDestroyNotify)object_unref); - qapi_free_SocketAddress(saddr); } =20 void tcp_start_incoming_migration(const char *host_port, Error **errp) @@ -188,10 +186,12 @@ void tcp_start_incoming_migration(const char *host_po= rt, Error **errp) socket_start_incoming_migration(saddr, &err); } error_propagate(errp, err); + qapi_free_SocketAddress(saddr); } =20 void unix_start_incoming_migration(const char *path, Error **errp) { SocketAddress *saddr =3D unix_build_address(path); socket_start_incoming_migration(saddr, errp); + qapi_free_SocketAddress(saddr); } --=20 2.7.4 From nobody Sun Apr 28 09:48:01 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150277837757032.580886757361895; Mon, 14 Aug 2017 23:26:17 -0700 (PDT) Received: from localhost ([::1]:41833 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhVIu-0003Xe-CV for importer@patchew.org; Tue, 15 Aug 2017 02:26:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhVGR-0001oJ-9l for qemu-devel@nongnu.org; Tue, 15 Aug 2017 02:23:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dhVGM-0005CG-Cs for qemu-devel@nongnu.org; Tue, 15 Aug 2017 02:23:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48148) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dhVGM-0005Bj-3f for qemu-devel@nongnu.org; Tue, 15 Aug 2017 02:23:38 -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 633AE2C96E0 for ; Tue, 15 Aug 2017 06:17:23 +0000 (UTC) Received: from pxdev.xzpeter.org.com (dhcp-15-224.nay.redhat.com [10.66.15.224]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A29E5D6A4; Tue, 15 Aug 2017 06:17:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 633AE2C96E0 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Tue, 15 Aug 2017 14:17:03 +0800 Message-Id: <1502777827-18874-3-git-send-email-peterx@redhat.com> In-Reply-To: <1502777827-18874-1-git-send-email-peterx@redhat.com> References: <1502777827-18874-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.29]); Tue, 15 Aug 2017 06:17:23 +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 2/6] migration: return incoming task tag for sockets 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 , "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" For socket based incoming migration, we attached a background task onto main loop to handle the acception of connections. We never had a way to destroy it before, only if we finished the migration. Let's allow socket_start_incoming_migration() to return the source tag of the listening async work, so that we may be able to clean it up in the future. Signed-off-by: Peter Xu --- migration/socket.c | 36 ++++++++++++++++++++++++------------ migration/socket.h | 4 ++-- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/migration/socket.c b/migration/socket.c index 9fc6cb3..6ee51ef 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -158,8 +158,12 @@ out: } =20 =20 -static void socket_start_incoming_migration(SocketAddress *saddr, - Error **errp) +/* + * Returns the tag ID of the watch that is attached to global main + * loop (>0), or zero if failure detected. + */ +static guint socket_start_incoming_migration(SocketAddress *saddr, + Error **errp) { QIOChannelSocket *listen_ioc =3D qio_channel_socket_new(); =20 @@ -168,30 +172,38 @@ static void socket_start_incoming_migration(SocketAdd= ress *saddr, =20 if (qio_channel_socket_listen_sync(listen_ioc, saddr, errp) < 0) { object_unref(OBJECT(listen_ioc)); - return; + return 0; } =20 - qio_channel_add_watch(QIO_CHANNEL(listen_ioc), - G_IO_IN, - socket_accept_incoming_migration, - listen_ioc, - (GDestroyNotify)object_unref); + return qio_channel_add_watch(QIO_CHANNEL(listen_ioc), + G_IO_IN, + socket_accept_incoming_migration, + listen_ioc, + (GDestroyNotify)object_unref); } =20 -void tcp_start_incoming_migration(const char *host_port, Error **errp) +guint tcp_start_incoming_migration(const char *host_port, Error **errp) { Error *err =3D NULL; SocketAddress *saddr =3D tcp_build_address(host_port, &err); + guint tag; + if (!err) { - socket_start_incoming_migration(saddr, &err); + tag =3D socket_start_incoming_migration(saddr, &err); } error_propagate(errp, err); qapi_free_SocketAddress(saddr); + + return tag; } =20 -void unix_start_incoming_migration(const char *path, Error **errp) +guint unix_start_incoming_migration(const char *path, Error **errp) { SocketAddress *saddr =3D unix_build_address(path); - socket_start_incoming_migration(saddr, errp); + guint tag; + + tag =3D socket_start_incoming_migration(saddr, errp); qapi_free_SocketAddress(saddr); + + return tag; } diff --git a/migration/socket.h b/migration/socket.h index 6b91e9d..bc8a59a 100644 --- a/migration/socket.h +++ b/migration/socket.h @@ -16,12 +16,12 @@ =20 #ifndef QEMU_MIGRATION_SOCKET_H #define QEMU_MIGRATION_SOCKET_H -void tcp_start_incoming_migration(const char *host_port, Error **errp); +guint tcp_start_incoming_migration(const char *host_port, Error **errp); =20 void tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp); =20 -void unix_start_incoming_migration(const char *path, Error **errp); +guint unix_start_incoming_migration(const char *path, Error **errp); =20 void unix_start_outgoing_migration(MigrationState *s, const char *path, Error **errp); --=20 2.7.4 From nobody Sun Apr 28 09:48:01 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502777923983103.29483588914911; Mon, 14 Aug 2017 23:18:43 -0700 (PDT) Received: from localhost ([::1]:41586 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhVBZ-0006SB-Uv for importer@patchew.org; Tue, 15 Aug 2017 02:18:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhVAR-0005pD-VC for qemu-devel@nongnu.org; Tue, 15 Aug 2017 02:17:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dhVAO-00017y-QU for qemu-devel@nongnu.org; Tue, 15 Aug 2017 02:17:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34070) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dhVAO-00017J-KA for qemu-devel@nongnu.org; Tue, 15 Aug 2017 02:17:28 -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 222DA4E334 for ; Tue, 15 Aug 2017 06:17:26 +0000 (UTC) Received: from pxdev.xzpeter.org.com (dhcp-15-224.nay.redhat.com [10.66.15.224]) by smtp.corp.redhat.com (Postfix) with ESMTP id D68FE5D6A4; Tue, 15 Aug 2017 06:17:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 222DA4E334 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Tue, 15 Aug 2017 14:17:04 +0800 Message-Id: <1502777827-18874-4-git-send-email-peterx@redhat.com> In-Reply-To: <1502777827-18874-1-git-send-email-peterx@redhat.com> References: <1502777827-18874-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.38]); Tue, 15 Aug 2017 06:17:26 +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 3/6] migration: return incoming task tag for exec 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 , "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" Return the async task tag for exec typed incoming migration in exec_start_incoming_migration(). Signed-off-by: Peter Xu --- migration/exec.c | 18 +++++++++++------- migration/exec.h | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/migration/exec.c b/migration/exec.c index 08b599e..ef1fb4c 100644 --- a/migration/exec.c +++ b/migration/exec.c @@ -52,7 +52,11 @@ static gboolean exec_accept_incoming_migration(QIOChanne= l *ioc, return FALSE; /* unregister */ } =20 -void exec_start_incoming_migration(const char *command, Error **errp) +/* + * Returns the tag ID of the watch that is attached to global main + * loop (>0), or zero if failure detected. + */ +guint exec_start_incoming_migration(const char *command, Error **errp) { QIOChannel *ioc; const char *argv[] =3D { "/bin/sh", "-c", command, NULL }; @@ -62,13 +66,13 @@ void exec_start_incoming_migration(const char *command,= Error **errp) O_RDWR, errp)); if (!ioc) { - return; + return 0; } =20 qio_channel_set_name(ioc, "migration-exec-incoming"); - qio_channel_add_watch(ioc, - G_IO_IN, - exec_accept_incoming_migration, - NULL, - NULL); + return qio_channel_add_watch(ioc, + G_IO_IN, + exec_accept_incoming_migration, + NULL, + NULL); } diff --git a/migration/exec.h b/migration/exec.h index b210ffd..0a7aada 100644 --- a/migration/exec.h +++ b/migration/exec.h @@ -19,7 +19,7 @@ =20 #ifndef QEMU_MIGRATION_EXEC_H #define QEMU_MIGRATION_EXEC_H -void exec_start_incoming_migration(const char *host_port, Error **errp); +guint exec_start_incoming_migration(const char *host_port, Error **errp); =20 void exec_start_outgoing_migration(MigrationState *s, const char *host_por= t, Error **errp); --=20 2.7.4 From nobody Sun Apr 28 09:48:01 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502778005152838.25633830855; Mon, 14 Aug 2017 23:20:05 -0700 (PDT) Received: from localhost ([::1]:41628 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhVCu-0007RK-2V for importer@patchew.org; Tue, 15 Aug 2017 02:20:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhVAS-0005pG-Uv for qemu-devel@nongnu.org; Tue, 15 Aug 2017 02:17:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dhVAR-00018h-PV for qemu-devel@nongnu.org; Tue, 15 Aug 2017 02:17:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43804) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dhVAR-00018Y-Jt for qemu-devel@nongnu.org; Tue, 15 Aug 2017 02:17:31 -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 A248D3E2BD for ; Tue, 15 Aug 2017 06:17:30 +0000 (UTC) Received: from pxdev.xzpeter.org.com (dhcp-15-224.nay.redhat.com [10.66.15.224]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D1375D6A4; Tue, 15 Aug 2017 06:17:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A248D3E2BD Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Tue, 15 Aug 2017 14:17:05 +0800 Message-Id: <1502777827-18874-5-git-send-email-peterx@redhat.com> In-Reply-To: <1502777827-18874-1-git-send-email-peterx@redhat.com> References: <1502777827-18874-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.30]); Tue, 15 Aug 2017 06:17:30 +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 4/6] migration: return incoming task tag for fd 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 , "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" Allow to return the task tag in fd_start_incoming_migration(). Signed-off-by: Peter Xu --- migration/fd.c | 18 +++++++++++------- migration/fd.h | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/migration/fd.c b/migration/fd.c index 30f5258..e9a548c 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -52,7 +52,11 @@ static gboolean fd_accept_incoming_migration(QIOChannel = *ioc, return FALSE; /* unregister */ } =20 -void fd_start_incoming_migration(const char *infd, Error **errp) +/* + * Returns the tag ID of the watch that is attached to global main + * loop (>0), or zero if failure detected. + */ +guint fd_start_incoming_migration(const char *infd, Error **errp) { QIOChannel *ioc; int fd; @@ -63,13 +67,13 @@ void fd_start_incoming_migration(const char *infd, Erro= r **errp) ioc =3D qio_channel_new_fd(fd, errp); if (!ioc) { close(fd); - return; + return 0; } =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); + return qio_channel_add_watch(ioc, + G_IO_IN, + fd_accept_incoming_migration, + NULL, + NULL); } diff --git a/migration/fd.h b/migration/fd.h index a14a63c..94cdea8 100644 --- a/migration/fd.h +++ b/migration/fd.h @@ -16,7 +16,7 @@ =20 #ifndef QEMU_MIGRATION_FD_H #define QEMU_MIGRATION_FD_H -void fd_start_incoming_migration(const char *path, Error **errp); +guint fd_start_incoming_migration(const char *path, Error **errp); =20 void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp); --=20 2.7.4 From nobody Sun Apr 28 09:48:01 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502777930895809.4663542735225; Mon, 14 Aug 2017 23:18:50 -0700 (PDT) Received: from localhost ([::1]:41589 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhVBh-0006YB-JQ for importer@patchew.org; Tue, 15 Aug 2017 02:18:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhVAV-0005rF-Ki for qemu-devel@nongnu.org; Tue, 15 Aug 2017 02:17:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dhVAU-00019o-Gr for qemu-devel@nongnu.org; Tue, 15 Aug 2017 02:17:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34876) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dhVAU-00019Y-7e for qemu-devel@nongnu.org; Tue, 15 Aug 2017 02:17:34 -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 3C4852C96DC for ; Tue, 15 Aug 2017 06:17:33 +0000 (UTC) Received: from pxdev.xzpeter.org.com (dhcp-15-224.nay.redhat.com [10.66.15.224]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2536F5D6A4; Tue, 15 Aug 2017 06:17:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3C4852C96DC Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Tue, 15 Aug 2017 14:17:06 +0800 Message-Id: <1502777827-18874-6-git-send-email-peterx@redhat.com> In-Reply-To: <1502777827-18874-1-git-send-email-peterx@redhat.com> References: <1502777827-18874-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.29]); Tue, 15 Aug 2017 06:17:33 +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 5/6] migration: store listen task tag 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 , "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" Store the task tag for migration types: tcp/unix/fd/exec in current MigrationIncomingState struct. For defered migration, no need to store task tag since there is no task running in the main loop at all. For RDMA, let's mark it as todo. Signed-off-by: Peter Xu --- migration/migration.c | 22 ++++++++++++++++++---- migration/migration.h | 2 ++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index c9b7085..daf356b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -171,6 +171,7 @@ void migration_incoming_state_destroy(void) mis->from_src_file =3D NULL; } =20 + mis->listen_task_tag =3D 0; qemu_event_destroy(&mis->main_thread_load_event); } =20 @@ -265,25 +266,31 @@ int migrate_send_rp_req_pages(MigrationIncomingState = *mis, const char *rbname, void qemu_start_incoming_migration(const char *uri, Error **errp) { const char *p; + guint task_tag =3D 0; + MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 qapi_event_send_migration(MIGRATION_STATUS_SETUP, &error_abort); if (!strcmp(uri, "defer")) { deferred_incoming_migration(errp); } else if (strstart(uri, "tcp:", &p)) { - tcp_start_incoming_migration(p, errp); + task_tag =3D tcp_start_incoming_migration(p, errp); #ifdef CONFIG_RDMA } else if (strstart(uri, "rdma:", &p)) { + /* TODO: store task tag for RDMA migrations */ rdma_start_incoming_migration(p, errp); #endif } else if (strstart(uri, "exec:", &p)) { - exec_start_incoming_migration(p, errp); + task_tag =3D exec_start_incoming_migration(p, errp); } else if (strstart(uri, "unix:", &p)) { - unix_start_incoming_migration(p, errp); + task_tag =3D unix_start_incoming_migration(p, errp); } else if (strstart(uri, "fd:", &p)) { - fd_start_incoming_migration(p, errp); + task_tag =3D fd_start_incoming_migration(p, errp); } else { error_setg(errp, "unknown migration protocol: %s", uri); + return; } + + mis->listen_task_tag =3D task_tag; } =20 static void process_incoming_migration_bh(void *opaque) @@ -422,6 +429,13 @@ void migration_fd_process_incoming(QEMUFile *f) co =3D qemu_coroutine_create(process_incoming_migration_co, f); qemu_coroutine_enter(co); } + + /* + * 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. + */ + mis->listen_task_tag =3D 0; } =20 /* diff --git a/migration/migration.h b/migration/migration.h index d041369..1f4faef 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -26,6 +26,8 @@ /* State for the incoming migration */ struct MigrationIncomingState { QEMUFile *from_src_file; + /* Task tag for incoming listen port. Valid when >0. */ + guint listen_task_tag; =20 /* * Free at the start of the main state load, set as the main thread fi= nishes --=20 2.7.4 From nobody Sun Apr 28 09:48:01 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502778091764170.80035860930548; Mon, 14 Aug 2017 23:21:31 -0700 (PDT) Received: from localhost ([::1]:41676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhVEI-0008O1-Jq for importer@patchew.org; Tue, 15 Aug 2017 02:21:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhVAc-0005w5-7w for qemu-devel@nongnu.org; Tue, 15 Aug 2017 02:17:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dhVAY-0001B9-VK for qemu-devel@nongnu.org; Tue, 15 Aug 2017 02:17:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49118) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dhVAY-0001At-MA for qemu-devel@nongnu.org; Tue, 15 Aug 2017 02:17:38 -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 B1E84A036F for ; Tue, 15 Aug 2017 06:17:37 +0000 (UTC) Received: from pxdev.xzpeter.org.com (dhcp-15-224.nay.redhat.com [10.66.15.224]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA6395D6A4; Tue, 15 Aug 2017 06:17:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B1E84A036F Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Tue, 15 Aug 2017 14:17:07 +0800 Message-Id: <1502777827-18874-7-git-send-email-peterx@redhat.com> In-Reply-To: <1502777827-18874-1-git-send-email-peterx@redhat.com> References: <1502777827-18874-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.39]); Tue, 15 Aug 2017 06:17:37 +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 6/6] 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 , "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" 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. Signed-off-by: Peter Xu --- migration/migration.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index daf356b..696cc7c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1288,17 +1288,39 @@ void migrate_del_blocker(Error *reason) migration_blockers =3D g_slist_remove(migration_blockers, reason); } =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; +} + 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 +1329,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) --=20 2.7.4