From patchwork Wed Feb 26 01:02:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13991194 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id CD060C021BB for ; Wed, 26 Feb 2025 01:03:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tn5o7-00045d-Dg; Tue, 25 Feb 2025 20:01:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tn5nb-0003qx-IX for qemu-devel@nongnu.org; Tue, 25 Feb 2025 20:01:22 -0500 Received: from esa11.hc1455-7.c3s2.iphmx.com ([207.54.90.137]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tn5nV-0004xv-2b for qemu-devel@nongnu.org; Tue, 25 Feb 2025 20:01:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1740531673; x=1772067673; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+CR7mMv1ubPow4V3VojBzeRtfH/4mt0zSZmZJSzhgAQ=; b=JJKkOYtXlLT9dxBFIaDZlRwsA/yg00rqhla0pKhr7phAuZqKw4At6gZs LjU4cMC7qvni5oNdSMV8pzEXc7F/AjI/X1Ahist4Itd4IbJ+KylV2SBRp qjWvBNxU/ph2F6qXWYNwyCxuBGxtb404InESoCd8eoWjuDMA8vvpDut+b ziNNtESVQPQsHeHe7dbzEjZReO89hapWaXRDKWJFnlV8zDy+DzJ+juzKc NZ8AtZiiHXHuyxwgSZ4oSW7CaNsxt83zWrlS0vrh+J8iSm73GC4DrrOwr hIB4n8Yyd+NelXW0KDvxyVrfaynuhpFn+1qZ3iTdHATAHHX57Jw7hZDPj g==; X-CSE-ConnectionGUID: 1X7Mo1fZSmSKlfuYdK14Gw== X-CSE-MsgGUID: QmZY4jBbRMuQVVSa7asFTg== X-IronPort-AV: E=McAfee;i="6700,10204,11356"; a="170638628" X-IronPort-AV: E=Sophos;i="6.13,316,1732546800"; d="scan'208";a="170638628" Received: from unknown (HELO oym-r4.gw.nic.fujitsu.com) ([210.162.30.92]) by esa11.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2025 10:01:08 +0900 Received: from oym-m4.gw.nic.fujitsu.com (oym-nat-oym-m4.gw.nic.fujitsu.com [192.168.87.61]) by oym-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 2EEAF7E04F for ; Wed, 26 Feb 2025 10:01:06 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by oym-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id E74B7D4BE4 for ; Wed, 26 Feb 2025 10:01:05 +0900 (JST) Received: from iaas-rdma.. (unknown [10.167.135.44]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 55BBB1A006C; Wed, 26 Feb 2025 09:01:05 +0800 (CST) To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Li Zhijian Subject: [PATCH v3 1/6] migration: Prioritize RDMA in ram_save_target_page() Date: Wed, 26 Feb 2025 09:02:33 +0800 Message-ID: <20250226010238.727348-2-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20250226010238.727348-1-lizhijian@fujitsu.com> References: <20250226010238.727348-1-lizhijian@fujitsu.com> MIME-Version: 1.0 Received-SPF: pass client-ip=207.54.90.137; envelope-from=lizhijian@fujitsu.com; helo=esa11.hc1455-7.c3s2.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Li Zhijian X-Patchwork-Original-From: Li Zhijian via From: "Zhijian Li (Fujitsu)" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Address an error in RDMA-based migration by ensuring RDMA is prioritized when saving pages in `ram_save_target_page()`. Previously, the RDMA protocol's page-saving step was placed after other protocols due to a refactoring in commit bc38dc2f5f3. This led to migration failures characterized by unknown control messages and state loading errors destination: (qemu) qemu-system-x86_64: Unknown control message QEMU FILE qemu-system-x86_64: error while loading state section id 1(ram) qemu-system-x86_64: load of migration failed: Operation not permitted source: (qemu) qemu-system-x86_64: RDMA is in an error state waiting migration to abort! qemu-system-x86_64: failed to save SaveStateEntry with id(name): 1(ram): -1 qemu-system-x86_64: rdma migration: recv polling control error! qemu-system-x86_64: warning: Early error. Sending error. qemu-system-x86_64: warning: rdma migration: send polling control error RDMA migration implemented its own protocol/method to send pages to destination side, hand over to RDMA first to prevent pages being saved by other protocol. Fixes: bc38dc2f5f3 ("migration: refactor ram_save_target_page functions") Reviewed-by: Peter Xu Signed-off-by: Li Zhijian --- V3: collect Reviewed tags --- migration/ram.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 589b6505eb2..424df6d9f13 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1964,6 +1964,11 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss) ram_addr_t offset = ((ram_addr_t)pss->page) << TARGET_PAGE_BITS; int res; + /* Hand over to RDMA first */ + if (control_save_page(pss, offset, &res)) { + return res; + } + if (!migrate_multifd() || migrate_zero_page_detection() == ZERO_PAGE_DETECTION_LEGACY) { if (save_zero_page(rs, pss, offset)) { @@ -1976,10 +1981,6 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss) return ram_save_multifd_page(block, offset); } - if (control_save_page(pss, offset, &res)) { - return res; - } - return ram_save_page(rs, pss); } From patchwork Wed Feb 26 01:02:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13991190 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C962DC021B2 for ; Wed, 26 Feb 2025 01:02:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tn5nw-0003tB-2y; Tue, 25 Feb 2025 20:01:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tn5na-0003qu-Te for qemu-devel@nongnu.org; Tue, 25 Feb 2025 20:01:20 -0500 Received: from esa8.hc1455-7.c3s2.iphmx.com ([139.138.61.253]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tn5nV-0004xw-55 for qemu-devel@nongnu.org; Tue, 25 Feb 2025 20:01:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1740531672; x=1772067672; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xQxh6ZKJcD8h9uh7LimZaDmonoqQcftA6fpMZd31xqg=; b=iJp8BiigAGCocdgNJwcqGu7r955Ecu02+G4XgxNqFfO3Myz2CSOzPcwr 7MJ8NdWbmyS+CdrP0k782Bt3LeZ80vMv3KQjZwDDyivq+zlaLgzrCv9Ak uW8tuq5JJ3p8TfWXEl1wc9A1R3EGNCy/S2WBCaZm3FdSbNxsB6QbL7cBb 1Hyh166EXG3YZXVY5kLKzlMa2zs3L51MazGOZfXz/1FwVztt5X3XJyZq5 svR6E8Z6Vn9pYLz/SwTnmTpTzUWKz03Km9AyZwULl5X+A79wHlVoAaogV rnYMn13D2+lIgqAq7FHAvf5Krty/usUMYREA9i3oZogXi7ggSWqGyjmgJ w==; X-CSE-ConnectionGUID: 5IRT4OTsTZWOrNQqWN9uvw== X-CSE-MsgGUID: sGn0Y3wWQrumlUgeIzvrEA== X-IronPort-AV: E=McAfee;i="6700,10204,11356"; a="179156072" X-IronPort-AV: E=Sophos;i="6.13,316,1732546800"; d="scan'208";a="179156072" Received: from unknown (HELO oym-r1.gw.nic.fujitsu.com) ([210.162.30.89]) by esa8.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2025 10:01:08 +0900 Received: from oym-m3.gw.nic.fujitsu.com (oym-nat-oym-m3.gw.nic.fujitsu.com [192.168.87.60]) by oym-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id 9D0B6D4812 for ; Wed, 26 Feb 2025 10:01:06 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by oym-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id 650C8D774C for ; Wed, 26 Feb 2025 10:01:06 +0900 (JST) Received: from iaas-rdma.. (unknown [10.167.135.44]) by edo.cn.fujitsu.com (Postfix) with ESMTP id C3EEC1A0073; Wed, 26 Feb 2025 09:01:05 +0800 (CST) To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Li Zhijian Subject: [PATCH v3 2/6] migration: Add migration_capabilities_and_transport_compatible() helper Date: Wed, 26 Feb 2025 09:02:34 +0800 Message-ID: <20250226010238.727348-3-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20250226010238.727348-1-lizhijian@fujitsu.com> References: <20250226010238.727348-1-lizhijian@fujitsu.com> MIME-Version: 1.0 Received-SPF: pass client-ip=139.138.61.253; envelope-from=lizhijian@fujitsu.com; helo=esa8.hc1455-7.c3s2.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Li Zhijian X-Patchwork-Original-From: Li Zhijian via From: "Zhijian Li (Fujitsu)" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Similar to migration_channels_and_transport_compatible(), introduce a new helper migration_capabilities_and_transport_compatible() to check if the capabilites is compatible with the transport. Currently, only move the capabilities vs RDMA transport to this function. Reviewed-by: Peter Xu Signed-off-by: Li Zhijian --- V3: - collect Reviewed tag - reorder: 5th -> 2nd --- migration/migration.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index c597aa707e5..2eacae25e0e 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -238,6 +238,30 @@ migration_channels_and_transport_compatible(MigrationAddress *addr, return true; } +static bool +migration_capabilities_and_transport_compatible(MigrationAddress *addr, + Error **errp) +{ + if (addr->transport == MIGRATION_ADDRESS_TYPE_RDMA) { + if (migrate_xbzrle()) { + error_setg(errp, "RDMA and XBZRLE can't be used together"); + return false; + } + if (migrate_multifd()) { + error_setg(errp, "RDMA and multifd can't be used together"); + return false; + } + } + + return true; +} + +static bool migration_transport_compatible(MigrationAddress *addr, Error **errp) +{ + return migration_channels_and_transport_compatible(addr, errp) && + migration_capabilities_and_transport_compatible(addr, errp); +} + static gint page_request_addr_cmp(gconstpointer ap, gconstpointer bp) { uintptr_t a = (uintptr_t) ap, b = (uintptr_t) bp; @@ -716,7 +740,7 @@ static void qemu_start_incoming_migration(const char *uri, bool has_channels, } /* transport mechanism not suitable for migration? */ - if (!migration_channels_and_transport_compatible(addr, errp)) { + if (!migration_transport_compatible(addr, errp)) { return; } @@ -735,14 +759,6 @@ static void qemu_start_incoming_migration(const char *uri, bool has_channels, } #ifdef CONFIG_RDMA } else if (addr->transport == MIGRATION_ADDRESS_TYPE_RDMA) { - if (migrate_xbzrle()) { - error_setg(errp, "RDMA and XBZRLE can't be used together"); - return; - } - if (migrate_multifd()) { - error_setg(errp, "RDMA and multifd can't be used together"); - return; - } rdma_start_incoming_migration(&addr->u.rdma, errp); #endif } else if (addr->transport == MIGRATION_ADDRESS_TYPE_EXEC) { @@ -2159,7 +2175,7 @@ void qmp_migrate(const char *uri, bool has_channels, } /* transport mechanism not suitable for migration? */ - if (!migration_channels_and_transport_compatible(addr, errp)) { + if (!migration_transport_compatible(addr, errp)) { return; } From patchwork Wed Feb 26 01:02:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13991189 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 2981AC021BE for ; Wed, 26 Feb 2025 01:02:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tn5o8-00048M-Ar; Tue, 25 Feb 2025 20:01:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tn5nf-0003rU-0m for qemu-devel@nongnu.org; Tue, 25 Feb 2025 20:01:24 -0500 Received: from esa10.hc1455-7.c3s2.iphmx.com ([139.138.36.225]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tn5nb-0004xu-DT for qemu-devel@nongnu.org; Tue, 25 Feb 2025 20:01:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1740531679; x=1772067679; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CSirQC4EObPjqlof3ujDjuP/Nb1WlYAJXM11TAR57ys=; b=UEe6KEA4TgKTS+YsedFVSwq6ywx63b7dIKcw9bA8RWv/UFIvzq5XzkuQ ZFYTgAItb1sHTUHCrocrGKtSnfgOFftJcDmMcTwNjX6ytaCvR3JMe1A+l FblPraa0jNN4FRcRb/847aFYX+SSzyh4mVRRSI/BJl93WrFm3OCstUBKH 4XCCaMHDR6nPYuB+wH5UCAoJkFolc4nHu+P3fz5CP+drc97p9mLD7I0Lb 2guPz3f5BIiyvv7g7JvdhB5y4bQYIFR11HCNIlbwYvmDmWFeVBKroqsAq XV7MoQirAbiMsiUrz1Y3s7dLMBvqGs4PZ9SOhYzWM546FPtTSHt4fFR9i Q==; X-CSE-ConnectionGUID: 4go/2eHGTsSR5RNNtYJw2w== X-CSE-MsgGUID: flp0eF/eTBe39ir6kndDxA== X-IronPort-AV: E=McAfee;i="6700,10204,11356"; a="178520693" X-IronPort-AV: E=Sophos;i="6.13,316,1732546800"; d="scan'208";a="178520693" Received: from unknown (HELO yto-r4.gw.nic.fujitsu.com) ([218.44.52.220]) by esa10.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2025 10:01:09 +0900 Received: from yto-m2.gw.nic.fujitsu.com (yto-nat-yto-m2.gw.nic.fujitsu.com [192.168.83.65]) by yto-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 25374D5052 for ; Wed, 26 Feb 2025 10:01:07 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by yto-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id DE24BD50B3 for ; Wed, 26 Feb 2025 10:01:06 +0900 (JST) Received: from iaas-rdma.. (unknown [10.167.135.44]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 4143B1A000B; Wed, 26 Feb 2025 09:01:06 +0800 (CST) To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Li Zhijian Subject: [PATCH v3 3/6] migration: disable RDMA + postcopy-ram Date: Wed, 26 Feb 2025 09:02:35 +0800 Message-ID: <20250226010238.727348-4-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20250226010238.727348-1-lizhijian@fujitsu.com> References: <20250226010238.727348-1-lizhijian@fujitsu.com> MIME-Version: 1.0 Received-SPF: pass client-ip=139.138.36.225; envelope-from=lizhijian@fujitsu.com; helo=esa10.hc1455-7.c3s2.iphmx.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Li Zhijian X-Patchwork-Original-From: Li Zhijian via From: "Zhijian Li (Fujitsu)" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org It's believed that RDMA + postcopy-ram has been broken for a while. Rather than spending time re-enabling it, let's simply disable it as a trade-off. Reviewed-by: Peter Xu Signed-off-by: Li Zhijian --- V3: - collect Reviewed tag - reoder: 6th -> 3th --- migration/migration.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index 2eacae25e0e..d414a4b1379 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -251,6 +251,10 @@ migration_capabilities_and_transport_compatible(MigrationAddress *addr, error_setg(errp, "RDMA and multifd can't be used together"); return false; } + if (migrate_postcopy_ram()) { + error_setg(errp, "RDMA and postcopy-ram can't be used together"); + return false; + } } return true; From patchwork Wed Feb 26 01:02:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13991191 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 35028C021BB for ; Wed, 26 Feb 2025 01:02:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tn5o5-00040p-Oe; Tue, 25 Feb 2025 20:01:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tn5nd-0003rI-Pa for qemu-devel@nongnu.org; Tue, 25 Feb 2025 20:01:24 -0500 Received: from esa2.hc1455-7.c3s2.iphmx.com ([207.54.90.48]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tn5nV-0004yF-CL for qemu-devel@nongnu.org; Tue, 25 Feb 2025 20:01:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1740531674; x=1772067674; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7PBvoitHF7A+13zdpcsFHx6PTRDE0C2rhaDiyx486rU=; b=j0nzDPKgNB7J1C5gvprFtSnRliJBIL7xhJQXcR/oR2bgTDkqELb3d40T uBUQEub0GDCX/lrOkxpW5QlIzfAtuYIWhlzmJ8n3icnNzQr7/oP2sGEZr czENYSSy/bKRvqCObjTGoxJKX54HnlwamzKxPUlHfcFdHpaiqWa3a0P7k jVnm/Fh3wkfDrPzXsRqJKb7jwusJK7IBDw5w1Rg5bONwknOV3MC783Efg sU/x5aIklnZyHoh2uzX6ayjycauu6NtW4JrmHQRib/Ye4vWg7cYIhazPj 0TsgrtnRVUfg/dy0EVZ7Zbl/5/iperBGaVnkQJSkH5r2v4fFm/TVoL8cQ w==; X-CSE-ConnectionGUID: YukOeBzDSbSnblT1JUQuaA== X-CSE-MsgGUID: ZXZWfFqlR5WENfjxWY77hg== X-IronPort-AV: E=McAfee;i="6700,10204,11356"; a="191194312" X-IronPort-AV: E=Sophos;i="6.13,316,1732546800"; d="scan'208";a="191194312" Received: from unknown (HELO yto-r4.gw.nic.fujitsu.com) ([218.44.52.220]) by esa2.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2025 10:01:10 +0900 Received: from yto-m2.gw.nic.fujitsu.com (yto-nat-yto-m2.gw.nic.fujitsu.com [192.168.83.65]) by yto-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 9B72BD5042 for ; Wed, 26 Feb 2025 10:01:07 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by yto-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 617F1D50B1 for ; Wed, 26 Feb 2025 10:01:07 +0900 (JST) Received: from iaas-rdma.. (unknown [10.167.135.44]) by edo.cn.fujitsu.com (Postfix) with ESMTP id B85711A006C; Wed, 26 Feb 2025 09:01:06 +0800 (CST) To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Li Zhijian Subject: [PATCH v3 4/6] migration/rdma: Remove redundant migration_in_postcopy checks Date: Wed, 26 Feb 2025 09:02:36 +0800 Message-ID: <20250226010238.727348-5-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20250226010238.727348-1-lizhijian@fujitsu.com> References: <20250226010238.727348-1-lizhijian@fujitsu.com> MIME-Version: 1.0 Received-SPF: pass client-ip=207.54.90.48; envelope-from=lizhijian@fujitsu.com; helo=esa2.hc1455-7.c3s2.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Li Zhijian X-Patchwork-Original-From: Li Zhijian via From: "Zhijian Li (Fujitsu)" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Since we have disabled RDMA + postcopy, it's safe to remove the migration_in_postcopy() that follows the migrate_rdma(). Signed-off-by: Li Zhijian --- V3: reorder: 7th->4th --- migration/rdma.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 76fb0349238..e5b4ac599b1 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3284,7 +3284,7 @@ err: int rdma_control_save_page(QEMUFile *f, ram_addr_t block_offset, ram_addr_t offset, size_t size) { - if (!migrate_rdma() || migration_in_postcopy()) { + if (!migrate_rdma()) { return RAM_SAVE_CONTROL_NOT_SUPP; } @@ -3829,7 +3829,7 @@ int rdma_block_notification_handle(QEMUFile *f, const char *name) int rdma_registration_start(QEMUFile *f, uint64_t flags) { - if (!migrate_rdma() || migration_in_postcopy()) { + if (!migrate_rdma()) { return 0; } @@ -3861,7 +3861,7 @@ int rdma_registration_stop(QEMUFile *f, uint64_t flags) RDMAControlHeader head = { .len = 0, .repeat = 1 }; int ret; - if (!migrate_rdma() || migration_in_postcopy()) { + if (!migrate_rdma()) { return 0; } From patchwork Wed Feb 26 01:02:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13991193 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C5EABC021BB for ; Wed, 26 Feb 2025 01:03:24 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tn5oA-0004Du-Ar; Tue, 25 Feb 2025 20:01:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tn5nm-0003t9-Ge for qemu-devel@nongnu.org; Tue, 25 Feb 2025 20:01:34 -0500 Received: from esa1.hc1455-7.c3s2.iphmx.com ([207.54.90.47]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tn5nd-00051D-Ly for qemu-devel@nongnu.org; Tue, 25 Feb 2025 20:01:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1740531682; x=1772067682; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jYuHGHFwJgUSZ8fd1FkvvadoSY3u79MwvRktdvNIgbY=; b=Dpx8gbWm8/nXwJUbsreQ5yTyt88OGY6Bok3VYXDh4L33HbATp5LvDDux FuAy1xbdZH0D5vtnICSfjNFCoaIyBzvhktYYTEmxXizWzQ1mg5R+pgvwY e+He2pm0C/fZQ3F6lLs6wFYlGJ+uREWqIKmg6NbQ9DAjLZK+e+5LPvy7k BSfrnpA0AOW0lSqmGJEkTrnDlNUDhtATLtvgeuZrIPGviOD22MhnZ+10S HrbtOlm1fg7E+4sdZLpiJn8w5B9VycFIN4UJWeZNuYmW6U8kfzuqPP4s2 PVRIqF1MNrtlNx0BQeZ41tsJXHy5MagDk4w49r+0zFC6bPRNFBtD88lO/ A==; X-CSE-ConnectionGUID: YWwKU41/R469v6Fz/2EACg== X-CSE-MsgGUID: RC+s+2WxSre/I9baq1/fZA== X-IronPort-AV: E=McAfee;i="6700,10204,11356"; a="191206654" X-IronPort-AV: E=Sophos;i="6.13,316,1732546800"; d="scan'208";a="191206654" Received: from unknown (HELO oym-r3.gw.nic.fujitsu.com) ([210.162.30.91]) by esa1.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2025 10:01:10 +0900 Received: from oym-m1.gw.nic.fujitsu.com (oym-nat-oym-m1.gw.nic.fujitsu.com [192.168.87.58]) by oym-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id 128B6C227C for ; Wed, 26 Feb 2025 10:01:08 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by oym-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id CBF0DD8B6A for ; Wed, 26 Feb 2025 10:01:07 +0900 (JST) Received: from iaas-rdma.. (unknown [10.167.135.44]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 3B6CD1A000B; Wed, 26 Feb 2025 09:01:07 +0800 (CST) To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Li Zhijian Subject: [PATCH v3 5/6] migration: Unfold control_save_page() Date: Wed, 26 Feb 2025 09:02:37 +0800 Message-ID: <20250226010238.727348-6-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20250226010238.727348-1-lizhijian@fujitsu.com> References: <20250226010238.727348-1-lizhijian@fujitsu.com> MIME-Version: 1.0 Received-SPF: pass client-ip=207.54.90.47; envelope-from=lizhijian@fujitsu.com; helo=esa1.hc1455-7.c3s2.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Li Zhijian X-Patchwork-Original-From: Li Zhijian via From: "Zhijian Li (Fujitsu)" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org control_save_page() is for RDMA only, unfold it to make the code more clear. In addition: - Similar to other branches style in ram_save_target_page(), involve RDMA only if the condition 'migrate_rdma()' is true. - Further simplify the code by removing the RAM_SAVE_CONTROL_NOT_SUPP. Signed-off-by: Li Zhijian --- V3: squash previous 2nd, 3th, 4th into one patch --- migration/ram.c | 34 +++++++--------------------------- migration/rdma.c | 7 ++----- migration/rdma.h | 3 +-- 3 files changed, 10 insertions(+), 34 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 424df6d9f13..c363034c882 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1143,32 +1143,6 @@ static int save_zero_page(RAMState *rs, PageSearchStatus *pss, return len; } -/* - * @pages: the number of pages written by the control path, - * < 0 - error - * > 0 - number of pages written - * - * Return true if the pages has been saved, otherwise false is returned. - */ -static bool control_save_page(PageSearchStatus *pss, - ram_addr_t offset, int *pages) -{ - int ret; - - ret = rdma_control_save_page(pss->pss_channel, pss->block->offset, offset, - TARGET_PAGE_SIZE); - if (ret == RAM_SAVE_CONTROL_NOT_SUPP) { - return false; - } - - if (ret == RAM_SAVE_CONTROL_DELAYED) { - *pages = 1; - return true; - } - *pages = ret; - return true; -} - /* * directly send the page to the stream * @@ -1965,7 +1939,13 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss) int res; /* Hand over to RDMA first */ - if (control_save_page(pss, offset, &res)) { + if (migrate_rdma()) { + res = rdma_control_save_page(pss->pss_channel, pss->block->offset, + offset, TARGET_PAGE_SIZE); + + if (res == RAM_SAVE_CONTROL_DELAYED) { + res = 1; + } return res; } diff --git a/migration/rdma.c b/migration/rdma.c index e5b4ac599b1..08eb924ffaa 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3284,14 +3284,11 @@ err: int rdma_control_save_page(QEMUFile *f, ram_addr_t block_offset, ram_addr_t offset, size_t size) { - if (!migrate_rdma()) { - return RAM_SAVE_CONTROL_NOT_SUPP; - } + assert(migrate_rdma()); int ret = qemu_rdma_save_page(f, block_offset, offset, size); - if (ret != RAM_SAVE_CONTROL_DELAYED && - ret != RAM_SAVE_CONTROL_NOT_SUPP) { + if (ret != RAM_SAVE_CONTROL_DELAYED) { if (ret < 0) { qemu_file_set_error(f, ret); } diff --git a/migration/rdma.h b/migration/rdma.h index f55f28bbed1..8eeb0117b91 100644 --- a/migration/rdma.h +++ b/migration/rdma.h @@ -33,7 +33,6 @@ void rdma_start_incoming_migration(InetSocketAddress *host_port, Error **errp); #define RAM_CONTROL_ROUND 1 #define RAM_CONTROL_FINISH 3 -#define RAM_SAVE_CONTROL_NOT_SUPP -1000 #define RAM_SAVE_CONTROL_DELAYED -2000 #ifdef CONFIG_RDMA @@ -56,7 +55,7 @@ static inline int rdma_control_save_page(QEMUFile *f, ram_addr_t block_offset, ram_addr_t offset, size_t size) { - return RAM_SAVE_CONTROL_NOT_SUPP; + g_assert_not_reached(); } #endif #endif From patchwork Wed Feb 26 01:02:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13991192 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 825F8C021B2 for ; Wed, 26 Feb 2025 01:03:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tn5oA-0004Ex-If; Tue, 25 Feb 2025 20:01:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tn5nd-0003rH-OP for qemu-devel@nongnu.org; Tue, 25 Feb 2025 20:01:22 -0500 Received: from esa8.hc1455-7.c3s2.iphmx.com ([139.138.61.253]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tn5nX-0004yT-Gg for qemu-devel@nongnu.org; Tue, 25 Feb 2025 20:01:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1740531675; x=1772067675; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jd+DdY5eY77B7kVpkL1NpFZ69YDj7OrP1FP6uOvMgB8=; b=o/x70lEpq2sD/P4usaVmso8pOb60TDaiiyQFp3FKJGYNhYCBPZJGgdyc oKCTr0x6yeC1ScznAabDBYgXYx0/IQlhtLVoO93e9o9gVVNDqjGSd3s79 FFQPtE95xMV7WUTQPm39h2int9JL2Y40SSY/l3F3DKXOxhPf6YKerRTK/ FkdDZcQdhGvS+V8tccAZ5aL39ibAmw3+r18Kd+swcLBwWHvIMioofuLIm 6r2qBYrd9PRgFrwrny/f3bMO02QNpgOjVfHetpAsM40pLY2SA8a+ou5PD H7ZM7f37IhDMjOXfsLR50i4ljlSoEiLGigEdJJX45qYaHEL8foSN5vdRi g==; X-CSE-ConnectionGUID: f0N1Df3uRtKUIMq79vN59g== X-CSE-MsgGUID: HLYAI4VxRXWjS5ZQv8fxAA== X-IronPort-AV: E=McAfee;i="6700,10204,11356"; a="179156084" X-IronPort-AV: E=Sophos;i="6.13,316,1732546800"; d="scan'208";a="179156084" Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa8.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2025 10:01:10 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 7F8F8E6881 for ; Wed, 26 Feb 2025 10:01:08 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 452BFBDC94 for ; Wed, 26 Feb 2025 10:01:08 +0900 (JST) Received: from iaas-rdma.. (unknown [10.167.135.44]) by edo.cn.fujitsu.com (Postfix) with ESMTP id A85861A006C; Wed, 26 Feb 2025 09:01:07 +0800 (CST) To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Li Zhijian Subject: [PATCH v3 6/6] migration: Add qtest for migration over RDMA Date: Wed, 26 Feb 2025 09:02:38 +0800 Message-ID: <20250226010238.727348-7-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20250226010238.727348-1-lizhijian@fujitsu.com> References: <20250226010238.727348-1-lizhijian@fujitsu.com> MIME-Version: 1.0 Received-SPF: pass client-ip=139.138.61.253; envelope-from=lizhijian@fujitsu.com; helo=esa8.hc1455-7.c3s2.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Li Zhijian X-Patchwork-Original-From: Li Zhijian via From: "Zhijian Li (Fujitsu)" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This qtest requires there is a RDMA(RoCE) link in the host. In order to make the test work smoothly, introduce a scripts/rdma-migration-helper.sh to - setup a new Soft-RoCE(aka RXE) if it's root - detect existing RoCE link Test will be skipped if there is no available RoCE link. # Start of rdma tests # Running /x86_64/migration/precopy/rdma/plain ok 1 /x86_64/migration/precopy/rdma/plain # SKIP There is no available rdma link to run RDMA migration test. To enable the test: (1) Run 'scripts/rdma-migration-helper.sh setup' with root and rerun the test or (2) Run the test with root privilege # End of rdma tests Reviewed-by: Peter Xu Signed-off-by: Li Zhijian --- MAINTAINERS | 1 + scripts/rdma-migration-helper.sh | 41 +++++++++++++++++ tests/qtest/migration/precopy-tests.c | 64 +++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100755 scripts/rdma-migration-helper.sh diff --git a/MAINTAINERS b/MAINTAINERS index 3848d37a38d..15360fcdc4b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3480,6 +3480,7 @@ R: Li Zhijian R: Peter Xu S: Odd Fixes F: migration/rdma* +F: scripts/rdma-migration-helper.sh Migration dirty limit and dirty page rate M: Hyman Huang diff --git a/scripts/rdma-migration-helper.sh b/scripts/rdma-migration-helper.sh new file mode 100755 index 00000000000..66557d9e267 --- /dev/null +++ b/scripts/rdma-migration-helper.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copied from blktests +get_ipv4_addr() +{ + ip -4 -o addr show dev "$1" | + sed -n 's/.*[[:blank:]]inet[[:blank:]]*\([^[:blank:]/]*\).*/\1/p' | + tr -d '\n' +} + +has_soft_rdma() +{ + rdma link | grep -q " netdev $1[[:blank:]]*\$" +} + +rdma_rxe_setup_detect() +{ + ( + cd /sys/class/net && + for i in *; do + [ -e "$i" ] || continue + [ "$i" = "lo" ] && continue + [ "$(<"$i/addr_len")" = 6 ] || continue + [ "$(<"$i/carrier")" = 1 ] || continue + + has_soft_rdma "$i" && break + [ "$operation" = "setup" ] && + rdma link add "${i}_rxe" type rxe netdev "$i" && break + done + has_soft_rdma "$i" || return + get_ipv4_addr "$i" + ) +} + +operation=${1:-setup} + +if [ "$operation" == "setup" ] || [ "$operation" == "detect" ]; then + rdma_rxe_setup_detect +else + echo "Usage: $0 [setup | detect]" +fi diff --git a/tests/qtest/migration/precopy-tests.c b/tests/qtest/migration/precopy-tests.c index ba273d10b9a..bf97f4e9325 100644 --- a/tests/qtest/migration/precopy-tests.c +++ b/tests/qtest/migration/precopy-tests.c @@ -99,6 +99,66 @@ static void test_precopy_unix_dirty_ring(void) test_precopy_common(&args); } +#ifdef CONFIG_RDMA + +#define RDMA_MIGRATION_HELPER "scripts/rdma-migration-helper.sh" +static int new_rdma_link(char *buffer) +{ + const char *argument = (geteuid() == 0) ? "setup" : "detect"; + char cmd[1024]; + + snprintf(cmd, sizeof(cmd), "%s %s", RDMA_MIGRATION_HELPER, argument); + + FILE *pipe = popen(cmd, "r"); + if (pipe == NULL) { + perror("Failed to run script"); + return -1; + } + + int idx = 0; + while (fgets(buffer + idx, 128 - idx, pipe) != NULL) { + idx += strlen(buffer); + } + + int status = pclose(pipe); + if (status == -1) { + perror("Error reported by pclose()"); + return -1; + } else if (WIFEXITED(status)) { + return WEXITSTATUS(status); + } + + return -1; +} + +static void test_precopy_rdma_plain(void) +{ + char buffer[128] = {}; + + if (new_rdma_link(buffer)) { + g_test_skip("\nThere is no available rdma link to run RDMA migration test.\n" + "To enable the test:\n" + "(1) Run \'" RDMA_MIGRATION_HELPER " setup\' with root and rerun the test\n" + "or\n" + "(2) Run the test with root privilege\n"); + return; + } + + /* + * TODO: query a free port instead of hard code. + * 29200=('R'+'D'+'M'+'A')*100 + **/ + g_autofree char *uri = g_strdup_printf("rdma:%s:29200", buffer); + + MigrateCommon args = { + .listen_uri = uri, + .connect_uri = uri, + }; + + test_precopy_common(&args); +} +#endif + static void test_precopy_tcp_plain(void) { MigrateCommon args = { @@ -1124,6 +1184,10 @@ static void migration_test_add_precopy_smoke(MigrationTestEnv *env) test_multifd_tcp_uri_none); migration_test_add("/migration/multifd/tcp/plain/cancel", test_multifd_tcp_cancel); +#ifdef CONFIG_RDMA + migration_test_add("/migration/precopy/rdma/plain", + test_precopy_rdma_plain); +#endif } void migration_test_add_precopy(MigrationTestEnv *env)