From nobody Thu Apr 3 12:22:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@fujitsu.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1741156065; cv=none; d=zohomail.com; s=zohoarc; b=Kplo4R5XMyFODPcRC9U1ICIrOITuR87s4tpqa1S18f9PKM8K6WZwJEAOD2e9+gjfAmjcgRVzGpLNW3Rd0s8K8Lvt/3iJcip+j0C5AMBmkuU3VLnpKF8yNIePlUX/1uP9THqel3CuupwB7v2eLu+xCcNWEVXrUVqAj08IIiFLOE0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741156065; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=q9Ac5MDNEThYyzPUyh8cFDhr05WIKqsIc1+y08l0LmY=; b=U/6WHJia9tu9BNNqpOtCdCLGOgQKP3myHVM9N0EVk5/1nDLiO7f/vBQokHh1hYgPvURogbpmhSpc4ZpDDKtJWiX+IAZyLf5EK80lQ3Inj4bsry/VKaA4v+8VxB1uoc+6S/U2CB3e9GxWwTN6LRy9yCrAjo8MTVpwUChsqSd+gw4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@fujitsu.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1741156065404453.4735710492913; Tue, 4 Mar 2025 22:27:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tpiDo-0002Fr-AS; Wed, 05 Mar 2025 01:27:12 -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 1tpiDd-0002E9-KH for qemu-devel@nongnu.org; Wed, 05 Mar 2025 01:27:04 -0500 Received: from esa4.hc1455-7.c3s2.iphmx.com ([68.232.139.117]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tpiDa-0007es-VH for qemu-devel@nongnu.org; Wed, 05 Mar 2025 01:27:00 -0500 Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa4.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2025 15:26:54 +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 065B8D4C39 for ; Wed, 5 Mar 2025 15:26:52 +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 BA8D9BDB65 for ; Wed, 5 Mar 2025 15:26:51 +0900 (JST) Received: from iaas-rdma.. (unknown [10.167.135.44]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 186A61A00A0; Wed, 5 Mar 2025 14:26:51 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1741156018; x=1772692018; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Kf7nUzx6bCEoflN6wH/5kN4a9SJ7oJCr6a8XCP/ryZQ=; b=KFRYd/AnNPYsZSOl2ZScphO92Htx+raxGTQfFz3+knMvI43xrS3R4ESV Xa7obXXsAgBT8XZav7d+4NvQ/NV0RpqcrYd5XSFCDp720epxzdk6hgRkU z7DQVNS6uiXekQcGsvE0kkpQ+0eK0BHe94bBqEkPHzKTg+ZT4D/BZKfxp 3YfA0fiNPJyl7vrTupO7oAEPj8OEoq+IbPxt8lhSMXrzcVeNZiB0Aq5d/ wCn5ODQk9sSuVxThRwdFDJRyH7cLzBue3Gcvjs9En2HLOa3V7YcvPdAeM ju90q1K0/I3WfkJuQXRUZr7RyqIk+u7kjNSYzB6RAkqlXHMur0cyuVwDO Q==; X-CSE-ConnectionGUID: CoscqJ2BRgybZGaWcVAZ0w== X-CSE-MsgGUID: /eRXmp2JSKezmJ275wcmOA== X-IronPort-AV: E=McAfee;i="6700,10204,11363"; a="192279487" X-IronPort-AV: E=Sophos;i="6.14,222,1736780400"; d="scan'208";a="192279487" To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Li Zhijian Subject: [PATCH v5 2/6] migration: check RDMA and capabilities are compatible on both sides Date: Wed, 5 Mar 2025 14:28:21 +0800 Message-ID: <20250305062825.772629-3-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20250305062825.772629-1-lizhijian@fujitsu.com> References: <20250305062825.772629-1-lizhijian@fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.139.117; envelope-from=lizhijian@fujitsu.com; helo=esa4.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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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 From: Li Zhijian via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1741156068557019100 Content-Type: text/plain; charset="utf-8" Depending on the order of starting RDMA and setting capability, they can be categorized into the following scenarios: Source: S1: [set capabilities] -> [Start RDMA outgoing] Destination: D1: [set capabilities] -> [Start RDMA incoming] D2: [Start RDMA incoming] -> [set capabilities] Previously, compatibility between RDMA and capabilities was verified only in scenario D1, potentially causing migration failures in other situations. For scenarios S1 and D1, we can seamlessly incorporate migration_transport_compatible() to address compatibility between channels and capabilities vs transport. For scenario D2, ensure compatibility within migrate_caps_check(). Reviewed-by: Peter Xu Signed-off-by: Li Zhijian --- V4: - Remove Reviewed-tag and cover above D2 scenario V3: - collect Reviewed tag - reorder: 5th -> 2nd --- migration/migration.c | 30 ++++++++++++++++++++---------- migration/options.c | 21 +++++++++++++++++++++ migration/options.h | 1 + 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index c597aa707e5..0736d3a6728 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -238,6 +238,24 @@ migration_channels_and_transport_compatible(MigrationA= ddress *addr, return true; } =20 +static bool +migration_capabilities_and_transport_compatible(MigrationAddress *addr, + Error **errp) +{ + if (addr->transport =3D=3D MIGRATION_ADDRESS_TYPE_RDMA) { + return migrate_rdma_caps_check(migrate_get_current()->capabilities, + errp); + } + + 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 =3D (uintptr_t) ap, b =3D (uintptr_t) bp; @@ -716,7 +734,7 @@ static void qemu_start_incoming_migration(const char *u= ri, bool has_channels, } =20 /* transport mechanism not suitable for migration? */ - if (!migration_channels_and_transport_compatible(addr, errp)) { + if (!migration_transport_compatible(addr, errp)) { return; } =20 @@ -735,14 +753,6 @@ static void qemu_start_incoming_migration(const char *= uri, bool has_channels, } #ifdef CONFIG_RDMA } else if (addr->transport =3D=3D 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 =3D=3D MIGRATION_ADDRESS_TYPE_EXEC) { @@ -2159,7 +2169,7 @@ void qmp_migrate(const char *uri, bool has_channels, } =20 /* transport mechanism not suitable for migration? */ - if (!migration_channels_and_transport_compatible(addr, errp)) { + if (!migration_transport_compatible(addr, errp)) { return; } =20 diff --git a/migration/options.c b/migration/options.c index bb259d192a9..c6f18df5864 100644 --- a/migration/options.c +++ b/migration/options.c @@ -439,6 +439,20 @@ static bool migrate_incoming_started(void) return !!migration_incoming_get_current()->transport_data; } =20 +bool migrate_rdma_caps_check(bool *caps, Error **errp) +{ + if (caps[MIGRATION_CAPABILITY_XBZRLE]) { + error_setg(errp, "RDMA and XBZRLE can't be used together"); + return false; + } + if (caps[MIGRATION_CAPABILITY_MULTIFD]) { + error_setg(errp, "RDMA and multifd can't be used together"); + return false; + } + + return true; +} + /** * @migration_caps_check - check capability compatibility * @@ -602,6 +616,13 @@ bool migrate_caps_check(bool *old_caps, bool *new_caps= , Error **errp) } } =20 + /* + * On destination side, check the cases that capability is being set + * after incoming thread has started. + */ + if (migrate_rdma() && !migrate_rdma_caps_check(new_caps, errp)) { + return false; + } return true; } =20 diff --git a/migration/options.h b/migration/options.h index 762be4e641a..82d839709e7 100644 --- a/migration/options.h +++ b/migration/options.h @@ -57,6 +57,7 @@ bool migrate_tls(void); =20 /* capabilities helpers */ =20 +bool migrate_rdma_caps_check(bool *caps, Error **errp); bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp); =20 /* parameters */ --=20 2.44.0