From patchwork Tue May 25 08:05:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 12278097 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3839DC2B9F8 for ; Tue, 25 May 2021 08:08:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BD3E96135F for ; Tue, 25 May 2021 08:08:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD3E96135F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=cn.fujitsu.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llS6q-0004DL-IL for qemu-devel@archiver.kernel.org; Tue, 25 May 2021 04:08:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llS5F-0002r0-3D for qemu-devel@nongnu.org; Tue, 25 May 2021 04:06:37 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:26023 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llS57-0003Cb-NF for qemu-devel@nongnu.org; Tue, 25 May 2021 04:06:36 -0400 IronPort-Data: A9a23:hZHK9KmsFCeYuvD4M8a+t8bo5gy7JERdPkR7XQ2eYbTBsI5bpz1WymMbXzuBbqqCN2f3Lth0b9/gph8EsJLRm98xSQdo+CA2RRqmi+KfW43BcR2Y0wB+jyH7ZBs+qZ1YM7EsFehsJpPnjkrrYuKJQUVUj/nSH+KhUrKcYUideCc/IMsfoUM68wIGqt4w6TSJK1vlVeLa+6UzCnf8s9JHGj58B5a4lf9alK+aVAX0EbAJTasjUFf2zxH5BX+ETE27ByOQroJ8RoZWSwtfpYxV8F81/z91Yj+kur39NEMXQL/OJhXIgX1TM0SgqkEa4HVsjeBgb7xBAatUo2zhc9RZzNRftZ2ySA4vFqPRmuUBSAQeGCZ7VUFD0OafcSfv7JbLliUqdFOpmZ2CFnoeJIAd56N7DH9D8dQeLzYCaA3FgPi5qJq3RehojMk5MOHxMY8fs20mxjbcZd4/XJHFX6jO7PdC0Tswj9wIFvHbD/f1wxIHgA/oOkUJYwlITsll2rrAu5U2SBUAwHr9mEb9yzK7INRN7YXQ IronPort-HdrOrdr: A9a23:r1EgQamOnrV/S2xScqwpRv0BGJ7pDfI53DAbv31ZSRFFG/FwWfrCoB1p726QtN9xYhEdcL+7V5VoLUm2yXcX2+gs1NWZMjUO0VHARL2KhrGP/9SUIVydygcy781dmtBFeb7NMWQ= X-IronPort-AV: E=Sophos;i="5.82,327,1613404800"; d="scan'208";a="108785201" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 May 2021 16:06:19 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id 7EDFE4C369E5; Tue, 25 May 2021 16:06:17 +0800 (CST) Received: from G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 25 May 2021 16:06:16 +0800 Received: from G08CNEXCHPEKD08.g08.fujitsu.local (10.167.33.83) by G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 25 May 2021 16:06:16 +0800 Received: from FNSTPC.g08.fujitsu.local (10.167.226.45) by G08CNEXCHPEKD08.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 25 May 2021 16:06:15 +0800 From: Li Zhijian To: , Subject: [PATCH v2 1/4] migration/rdma: cleanup rmda in rdma_start_incoming_migration error path Date: Tue, 25 May 2021 16:05:49 +0800 Message-ID: <20210525080552.28259-1-lizhijian@cn.fujitsu.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-yoursite-MailScanner-ID: 7EDFE4C369E5.A1ECB X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: lizhijian@fujitsu.com Received-SPF: neutral client-ip=183.91.158.132; envelope-from=lizhijian@fujitsu.com; helo=heian.cn.fujitsu.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Li Zhijian Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" the error path after calling qemu_rdma_dest_init() should do rdma cleanup Signed-off-by: Li Zhijian Reviewed-by: Dr. David Alan Gilbert --- migration/rdma.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 41726cc74a8..7e7595faabf 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -4040,7 +4040,7 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp) if (ret) { ERROR(errp, "listening on socket!"); - goto err; + goto cleanup_rdma; } trace_rdma_start_incoming_migration_after_rdma_listen(); @@ -4050,7 +4050,7 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp) rdma_return_path = qemu_rdma_data_init(host_port, &local_err); if (rdma_return_path == NULL) { - goto err; + goto cleanup_rdma; } qemu_rdma_return_path_dest_init(rdma_return_path, rdma); @@ -4059,6 +4059,9 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp) qemu_set_fd_handler(rdma->channel->fd, rdma_accept_incoming_migration, NULL, (void *)(intptr_t)rdma); return; + +cleanup_rdma: + qemu_rdma_cleanup(rdma); err: error_propagate(errp, local_err); if (rdma) { From patchwork Tue May 25 08:05:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 12278101 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7A27C2B9F8 for ; Tue, 25 May 2021 08:10:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 522ED6135F for ; Tue, 25 May 2021 08:10:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 522ED6135F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=cn.fujitsu.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llS9M-0008FP-H8 for qemu-devel@archiver.kernel.org; Tue, 25 May 2021 04:10:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46670) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llS5K-0002sk-Ek for qemu-devel@nongnu.org; Tue, 25 May 2021 04:06:42 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:26027 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llS5F-0003F0-3Y for qemu-devel@nongnu.org; Tue, 25 May 2021 04:06:42 -0400 IronPort-Data: A9a23:F6Lh5KAXyF/9sBVW/xPhw5YqxClBgxIJ4g17XOLfU1K+0Tp3gzBTnGJLD23SP62LYWunKt91O9nlo0IBuZ+Ax9UxeLYW3SszFioV86IpJjg4wn/YZnrUdouaJK5ex512huLocYZkFBcwmj/3auK49SQmifnTLlbBILWs1h5ZFFYMpBgJ2UoLd94R2uaEsPDha++/kYqaT/73ZDdJ7wVJ3lc8sMpvnv/AUMPa41v0tnRmDRxCUcS3e3M9VPrzLonpR5f0rxU9IwK0ewrD5OnREmLx9BFrBM6nk6rgbwsBRbu60Qqm0yIQAvb9xEMZ4HFaPqUTbZLwbW9TiieJntJwwdNlu4GySBsyI+vHn+F1vxxwSnkuYv0bouacSZS4mYnJp6HcSFP1zvBzSU07I4Ac0uBwB25I6LofMj9lRhyMhua8zainYvNhisQqMI/gO4Z3kmh9zDfFAPIvaYrOT6XD+ZlT2zJYuyzkNZ4yfOJAMXw2MkuGOEYJZz8q5FsFtL/ArhHCn/dw8Tp5fZYK3lU= IronPort-HdrOrdr: A9a23:ktWICaNuvYYz/cBcTiWjsMiBIKoaSvp037Eqv3oedfUzSL3/qynOpoVj6faaslYssR0b9exofZPwJE80lqQFhrX5X43SPzUO0VHAROoJgLcKgQeQfxEWndQ96U4PScdD4aXLfDpHZNjBkXSFOudl0N+a67qpmOub639sSDthY6Zm4xwRMHfhLmRGABlBGYEiFIeRou5Opz+bc3wRacihQlYfWeyrnaywqLvWJQ4BGwU86BSDyReh6LvBGRCe2RsEFxNjqI1SiVT4rw== X-IronPort-AV: E=Sophos;i="5.82,327,1613404800"; d="scan'208";a="108785213" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 May 2021 16:06:32 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id E14644C369E5; Tue, 25 May 2021 16:06:27 +0800 (CST) Received: from G08CNEXCHPEKD08.g08.fujitsu.local (10.167.33.83) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 25 May 2021 16:06:26 +0800 Received: from FNSTPC.g08.fujitsu.local (10.167.226.45) by G08CNEXCHPEKD08.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 25 May 2021 16:06:26 +0800 From: Li Zhijian To: , Subject: [PATCH v2 2/4] migration/rdma: Fix rdma_addrinfo res leaks Date: Tue, 25 May 2021 16:05:50 +0800 Message-ID: <20210525080552.28259-2-lizhijian@cn.fujitsu.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210525080552.28259-1-lizhijian@cn.fujitsu.com> References: <20210525080552.28259-1-lizhijian@cn.fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: E14644C369E5.AE0D6 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: lizhijian@fujitsu.com Received-SPF: neutral client-ip=183.91.158.132; envelope-from=lizhijian@fujitsu.com; helo=heian.cn.fujitsu.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Li Zhijian Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" rdma_freeaddrinfo() is the reverse operation of rdma_getaddrinfo() Signed-off-by: Li Zhijian Reviewed-by: Dr. David Alan Gilbert --- migration/rdma.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/migration/rdma.c b/migration/rdma.c index 7e7595faabf..651534e8255 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -987,10 +987,12 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp) } } + rdma_freeaddrinfo(res); ERROR(errp, "could not resolve address %s", rdma->host); goto err_resolve_get_addr; route: + rdma_freeaddrinfo(res); qemu_rdma_dump_gid("source_resolve_addr", rdma->cm_id); ret = rdma_get_cm_event(rdma->channel, &cm_event); @@ -2593,6 +2595,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp) break; } + rdma_freeaddrinfo(res); if (!e) { ERROR(errp, "Error: could not rdma_bind_addr!"); goto err_dest_init_bind_addr; From patchwork Tue May 25 08:05:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 12278099 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F585C2B9F8 for ; Tue, 25 May 2021 08:08:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 732606135F for ; Tue, 25 May 2021 08:08:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 732606135F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=cn.fujitsu.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llS6t-0004LB-C5 for qemu-devel@archiver.kernel.org; Tue, 25 May 2021 04:08:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llS5N-0002tq-CF for qemu-devel@nongnu.org; Tue, 25 May 2021 04:06:48 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:26023 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llS5I-0003Cb-3R for qemu-devel@nongnu.org; Tue, 25 May 2021 04:06:44 -0400 IronPort-Data: A9a23:Tr6arq0uPRh0X/SJjvbD5elzkn2cJEfYwER7XOPLsXnJ3T4q32BWzjQbC2+Pa/qNZTSnfI1xYIu39UkA7ceDyNE2QQE+nZ1PZygU8JKaX7x1DatR0xu6d5SFFAQ+hyknQoGowPscEzmM/H9BDpC79SMljfzSGuKnYAL5EnsZqTFMGX5JZS1Ly7ZRbr5A2bBVMivV0T/Ai5S31GyNh1aYBlkpB5er83uDihhdVAQw5TTSbdgT1LPXeuJ84Jg3fcldJFOgKmVY83LTegrN8F251juxExYFAdXjnKv5c1ERX/jZOg3mZnh+AvDk20Yd4HdplPtT2Pk0MC+7jx2NnsJxyddMvJqYRxorP7HXhaIWVBww/yRWZPUWp++aeyHh2SCU5wicG5f2+N13AUQreIEV5OtzKWdJ8/MeNXYKdB/rr+65wbaxR/Nwrt4uIMniIMUUvXQI5SjEDPA6TJTKa7/H6d9RwHE7gcUmIBp0T6L1chI2NFKZPUIJYQxRVfoDcC6TriGXW1VlRJi9/MLbO1Tu8TE= IronPort-HdrOrdr: A9a23:tppvTq5IsLZF4DbIlAPXwPTXdLJyesId70hD6qkRc20wTiX8ra2TdZsguyMc9wx6ZJhNo7G90cq7MBbhHPxOkOos1N6ZNWGIhILCFvAB0WKN+V3dMhy73utc+IMlSKJmFeD3ZGIQse/KpCW+DPYsqePqzJyV X-IronPort-AV: E=Sophos;i="5.82,327,1613404800"; d="scan'208";a="108785216" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 May 2021 16:06:39 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id 262EC4C369E5; Tue, 25 May 2021 16:06:38 +0800 (CST) Received: from G08CNEXCHPEKD08.g08.fujitsu.local (10.167.33.83) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 25 May 2021 16:06:37 +0800 Received: from FNSTPC.g08.fujitsu.local (10.167.226.45) by G08CNEXCHPEKD08.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 25 May 2021 16:06:37 +0800 From: Li Zhijian To: , Subject: [PATCH v2 3/4] migration/rdma: destination: create the return patch after the first accept Date: Tue, 25 May 2021 16:05:51 +0800 Message-ID: <20210525080552.28259-3-lizhijian@cn.fujitsu.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210525080552.28259-1-lizhijian@cn.fujitsu.com> References: <20210525080552.28259-1-lizhijian@cn.fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 262EC4C369E5.A07F9 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: lizhijian@fujitsu.com Received-SPF: neutral client-ip=183.91.158.132; envelope-from=lizhijian@fujitsu.com; helo=heian.cn.fujitsu.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Li Zhijian Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" destination side: $ build/qemu-system-x86_64 -enable-kvm -netdev tap,id=hn0,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown -device e1000,netdev=hn0,mac=50:52:54:00:11:22 -boot c -drive if=none,file=./Fedora-rdma-server-migration.qcow2,id=drive-virtio-disk0 -device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0 -m 2048 -smp 2 -device piix3-usb-uhci -device usb-tablet -monitor stdio -vga qxl -spice streaming-video=filter,port=5902,disable-ticketing -incoming rdma:192.168.1.10:8888 (qemu) migrate_set_capability postcopy-ram on (qemu) dest_init RDMA Device opened: kernel name rocep1s0f0 uverbs device name uverbs0, infiniband_verbs class device path /sys/class/infiniband_verbs/uverbs0, infiniband class device path /sys/class/infiniband/rocep1s0f0, transport: (2) Ethernet Segmentation fault (core dumped) (gdb) bt #0 qemu_rdma_accept (rdma=0x0) at ../migration/rdma.c:3272 #1 rdma_accept_incoming_migration (opaque=0x0) at ../migration/rdma.c:3986 #2 0x0000563c9e51f02a in aio_dispatch_handler (ctx=ctx@entry=0x563ca0606010, node=0x563ca12b2150) at ../util/aio-posix.c:329 #3 0x0000563c9e51f752 in aio_dispatch_handlers (ctx=0x563ca0606010) at ../util/aio-posix.c:372 #4 aio_dispatch (ctx=0x563ca0606010) at ../util/aio-posix.c:382 #5 0x0000563c9e4f4d9e in aio_ctx_dispatch (source=, callback=, user_data=) at ../util/async.c:306 #6 0x00007fe96ef3fa9f in g_main_context_dispatch () at /lib64/libglib-2.0.so.0 #7 0x0000563c9e4ffeb8 in glib_pollfds_poll () at ../util/main-loop.c:231 #8 os_host_main_loop_wait (timeout=12188789) at ../util/main-loop.c:254 #9 main_loop_wait (nonblocking=nonblocking@entry=0) at ../util/main-loop.c:530 #10 0x0000563c9e3c7211 in qemu_main_loop () at ../softmmu/runstate.c:725 #11 0x0000563c9dfd46fe in main (argc=, argv=, envp=) at ../softmmu/main.c:50 The rdma return path will not be created when qemu incoming is starting since migrate_copy() is false at that moment, then a NULL return path rdma was referenced if the user enabled postcopy later. Signed-off-by: Li Zhijian Reviewed-by: Dr. David Alan Gilbert --- V2: alloc memory for host_port --- migration/rdma.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 651534e8255..d829d08d076 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -316,6 +316,7 @@ typedef struct RDMALocalBlocks { typedef struct RDMAContext { char *host; int port; + char *host_port; RDMAWorkRequestData wr_data[RDMA_WRID_MAX]; @@ -2392,7 +2393,9 @@ static void qemu_rdma_cleanup(RDMAContext *rdma) rdma->channel = NULL; } g_free(rdma->host); + g_free(rdma->host_port); rdma->host = NULL; + rdma->host_port = NULL; } @@ -2648,6 +2651,7 @@ static void *qemu_rdma_data_init(const char *host_port, Error **errp) if (!inet_parse(addr, host_port, NULL)) { rdma->port = atoi(addr->port); rdma->host = g_strdup(addr->host); + rdma->host_port = g_strdup(host_port); } else { ERROR(errp, "bad RDMA migration address '%s'", host_port); g_free(rdma); @@ -3276,6 +3280,7 @@ static int qemu_rdma_accept(RDMAContext *rdma) .private_data = &cap, .private_data_len = sizeof(cap), }; + RDMAContext *rdma_return_path = NULL; struct rdma_cm_event *cm_event; struct ibv_context *verbs; int ret = -EINVAL; @@ -3291,6 +3296,20 @@ static int qemu_rdma_accept(RDMAContext *rdma) goto err_rdma_dest_wait; } + /* + * initialize the RDMAContext for return path for postcopy after first + * connection request reached. + */ + if (migrate_postcopy() && !rdma->is_return_path) { + rdma_return_path = qemu_rdma_data_init(rdma->host_port, NULL); + if (rdma_return_path == NULL) { + rdma_ack_cm_event(cm_event); + goto err_rdma_dest_wait; + } + + qemu_rdma_return_path_dest_init(rdma_return_path, rdma); + } + memcpy(&cap, cm_event->param.conn.private_data, sizeof(cap)); network_to_caps(&cap); @@ -3406,6 +3425,7 @@ static int qemu_rdma_accept(RDMAContext *rdma) err_rdma_dest_wait: rdma->error_state = ret; qemu_rdma_cleanup(rdma); + g_free(rdma_return_path); return ret; } @@ -4048,17 +4068,6 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp) trace_rdma_start_incoming_migration_after_rdma_listen(); - /* initialize the RDMAContext for return path */ - if (migrate_postcopy()) { - rdma_return_path = qemu_rdma_data_init(host_port, &local_err); - - if (rdma_return_path == NULL) { - goto cleanup_rdma; - } - - qemu_rdma_return_path_dest_init(rdma_return_path, rdma); - } - qemu_set_fd_handler(rdma->channel->fd, rdma_accept_incoming_migration, NULL, (void *)(intptr_t)rdma); return; @@ -4069,6 +4078,7 @@ err: error_propagate(errp, local_err); if (rdma) { g_free(rdma->host); + g_free(rdma->host_port); } g_free(rdma); g_free(rdma_return_path); From patchwork Tue May 25 08:05:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 12278133 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3609BC4707F for ; Tue, 25 May 2021 08:12:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DE910613F9 for ; Tue, 25 May 2021 08:12:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE910613F9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=cn.fujitsu.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llSB7-00021K-SI for qemu-devel@archiver.kernel.org; Tue, 25 May 2021 04:12:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llS5d-000381-LI for qemu-devel@nongnu.org; Tue, 25 May 2021 04:07:01 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:26035 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llS5W-0003NV-Mo for qemu-devel@nongnu.org; Tue, 25 May 2021 04:07:01 -0400 IronPort-Data: A9a23:V+L836J8F0ZFe4DJFE+R65clxSXFcZb7ZxGrkP8bfHDv0GsngzMGzWAZCG3TbKnbZmv1KNgjYIrlpxhX7MCEyoNqS1BcGVNFFSwT8ZWfbTi6wuYcBwvLd4ubChsPA/w2MrEsF+hpCC+GzvuRGuK59yAkiPvUHuGU5NPsYUideyc1EU/Ntjozw4bVsqYw6TSIK1vlVeHa+qUzC3f5s9JACV/43orYwP9ZUFsejxtD1rA2TagjUFYzDBD5BrpHTU26ByOQroW5goeHq+j/ILGRpgs1/j8mDJWrj7T6blYXBLXVOGBiiFIPA+773EcE/Xd0j87XN9JFAatTozGIjdBwytREs7S+VAUoIrbR3u8aVnG0FgknZf0ZqOKdeiDXXcu7iheun2HX6+xjCVxzMYAG9+JfB2ZI+voFbjcXYXiri+23xLi2UPVEnMkvLMD3eogYvxlI1CzYC+orRZnrWajG5dZEmjw3g6hz8Vz2DyYCQWM3Kk2ePFsUYRFKYK/SVdyA3hHXGwC0YnrPzUbv31Xu8Q== IronPort-HdrOrdr: A9a23:Y+HixqkO72UPr6sjbuDPnuCPswLpDfI53DAbv31ZSRFFG/FwWfrCoB1p726QtN9xYhEdcL+7V5VoLUm2yXcX2+gs1NWZMjUO0VHARL2KhrGP/9SUIVydygcy781dmtBFeb7NMWQ= X-IronPort-AV: E=Sophos;i="5.82,327,1613404800"; d="scan'208";a="108785230" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 May 2021 16:06:52 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id 7C5C54C369FD; Tue, 25 May 2021 16:06:50 +0800 (CST) Received: from G08CNEXCHPEKD08.g08.fujitsu.local (10.167.33.83) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 25 May 2021 16:06:39 +0800 Received: from FNSTPC.g08.fujitsu.local (10.167.226.45) by G08CNEXCHPEKD08.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 25 May 2021 16:06:39 +0800 From: Li Zhijian To: , Subject: [PATCH v2 4/4] migration/rdma: source: poll cm_event from return path Date: Tue, 25 May 2021 16:05:52 +0800 Message-ID: <20210525080552.28259-4-lizhijian@cn.fujitsu.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210525080552.28259-1-lizhijian@cn.fujitsu.com> References: <20210525080552.28259-1-lizhijian@cn.fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 7C5C54C369FD.ABB6D X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: lizhijian@fujitsu.com Received-SPF: neutral client-ip=183.91.158.132; envelope-from=lizhijian@fujitsu.com; helo=heian.cn.fujitsu.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Li Zhijian Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" source side always blocks if postcopy is only enabled at source side. users are not able to cancel this migration in this case. Let source side have chance to cancel this migration Signed-off-by: Li Zhijian Reviewed-by: Dr. David Alan Gilbert --- V2: utilize poll to check cm event --- migration/rdma.c | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index d829d08d076..f67e21b4f54 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -36,6 +36,7 @@ #include #include "trace.h" #include "qom/object.h" +#include /* * Print and error on both the Monitor and the Log file. @@ -2460,7 +2461,36 @@ err_rdma_source_init: return -1; } -static int qemu_rdma_connect(RDMAContext *rdma, Error **errp) +static int qemu_get_cm_event_timeout(RDMAContext *rdma, + struct rdma_cm_event **cm_event, + long msec, Error **errp) +{ + int ret; + struct pollfd poll_fd = { + .fd = rdma->channel->fd, + .events = POLLIN, + .revents = 0 + }; + + do { + ret = poll(&poll_fd, 1, msec); + } while (ret < 0 && errno == EINTR); + + if (ret == 0) { + ERROR(errp, "poll cm event timeout"); + return -1; + } else if (ret < 0) { + ERROR(errp, "failed to pull cm event, errno=%i", errno); + return -1; + } else if (poll_fd.revents & POLLIN) { + return rdma_get_cm_event(rdma->channel, cm_event); + } else { + ERROR(errp, "no POLLIN event, revent=%x", poll_fd.revents); + return -1; + } +} + +static int qemu_rdma_connect(RDMAContext *rdma, Error **errp, bool return_path) { RDMACapabilities cap = { .version = RDMA_CONTROL_VERSION_CURRENT, @@ -2498,7 +2528,11 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp) goto err_rdma_source_connect; } - ret = rdma_get_cm_event(rdma->channel, &cm_event); + if (return_path) { + ret = qemu_get_cm_event_timeout(rdma, &cm_event, 5000, errp); + } else { + ret = rdma_get_cm_event(rdma->channel, &cm_event); + } if (ret) { perror("rdma_get_cm_event after rdma_connect"); ERROR(errp, "connecting to destination!"); @@ -4111,7 +4145,7 @@ void rdma_start_outgoing_migration(void *opaque, } trace_rdma_start_outgoing_migration_after_rdma_source_init(); - ret = qemu_rdma_connect(rdma, errp); + ret = qemu_rdma_connect(rdma, errp, false); if (ret) { goto err; @@ -4132,7 +4166,7 @@ void rdma_start_outgoing_migration(void *opaque, goto return_path_err; } - ret = qemu_rdma_connect(rdma_return_path, errp); + ret = qemu_rdma_connect(rdma_return_path, errp, true); if (ret) { goto return_path_err;