From nobody Mon Jun 8 03:21:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1780392458; cv=pass; d=zohomail.com; s=zohoarc; b=ZgFAEVyYPJ7ekbph9Eo8fUOmtpkmEolPqOc1wY6XZbLG5/u6hneFh/pF5EseLMpCGlXezTwpvEleJFXXqMw+O9r1mfXxHvwZC+GpzUHFHvDrmLo6kMnCJmGj0zM0CsRH5MsKFzICGYZ2LnsYibEcpOmaq42R2+ehdzKQZrVVJvk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780392458; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cxOLli5hATDfFw0edNBnF9MskuVfcm1vtBR85JdTAYM=; b=KoxOSyR+ft1d4iyEak58xPne17sewqmRkMSukhPxKuKsU3m3VKi27gItXoo49vQ0Dp+4/y7lx6eBNC3cDXJlnKcVa3wc/QmflnM5RYoLHkc5L2gR3w5yQXqVf1mP66Sn10UR6I8K377FCrIoe3TFPceIYX5V8NRmloI7AvcKDXs= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780392458216171.08763589342618; Tue, 2 Jun 2026 02:27:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wULOt-0005qk-47; Tue, 02 Jun 2026 05:27:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULOq-0005qZ-6T for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:27:04 -0400 Received: from mail-westus3azlp170110003.outbound.protection.outlook.com ([2a01:111:f403:c107::3] helo=PH0PR06CU001.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULOo-0003yq-Kf for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:27:03 -0400 Received: from CH2PR18CA0012.namprd18.prod.outlook.com (2603:10b6:610:4f::22) by CH3PR12MB9078.namprd12.prod.outlook.com (2603:10b6:610:196::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.71.16; Tue, 2 Jun 2026 09:26:53 +0000 Received: from CH2PEPF0000013F.namprd02.prod.outlook.com (2603:10b6:610:4f:cafe::72) by CH2PR18CA0012.outlook.office365.com (2603:10b6:610:4f::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.71.17 via Frontend Transport; Tue, 2 Jun 2026 09:26:53 +0000 Received: from mail.nvidia.com (216.228.117.160) by CH2PEPF0000013F.mail.protection.outlook.com (10.167.244.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.5 via Frontend Transport; Tue, 2 Jun 2026 09:26:53 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:26:35 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:26:34 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Tue, 2 Jun 2026 02:26:29 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cswFY0AsTWo/s0EWQpVFdXlNl1j0g7t+KJOS40GG1FMyHdtWrzP+q2nOhaiqi5J/cNaZHyZLEoJzS4dfsvAQDCMrFiil7/FfPECfCN50cft7uucsTdRn1/dLEcWFXqI1DBDR5pL1rR+azWEUrH21zCcWLjUNDpGwneZxQ0BuZo3q1AZ5oysh8Je/J++ZSEC0rSaQRNminyBEG+A1H2WzqKPPvFbUBbU92B4CD68tsyadBzCyWIrpfdN3ekh4lT8ZN6Yq34PRbI32547coxXfcWeF+bst7B7liYut+mQz1kMGpFDVEyR7LXar17TBU1/Vmwpmx80+56V3g0lpR/xEhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cxOLli5hATDfFw0edNBnF9MskuVfcm1vtBR85JdTAYM=; b=IMUjqRFv2LU+9rcK7xjFUnEaYmDY/GoUkWjGceJZixDscDDEvt4lqjOza95hz/Ykvw1EM7PobolS48HedHsLPFxz7Jx1MFVBrL7pn/575FB9khBJhaeTqJEGvqj6eCnNRQWPEhC+/5fPrrZHxGWFn0gilmoMyyRTlwUjkP4PjhKz92AoyXPS4sDxoW0M+FnNbhTlY3OAExqZc4eOCzBN9eJDLP1skPigDRvw+i3XLrCgPTh82nubtGiJ590rgmVG7GbIRIj7NRCG7aQWTXFIsO1YN0pgczNOZ+n8FtkMyGP1WayoBNX/uGUWeVzl8uza/d84zjNzZ8CWt59iyugiBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cxOLli5hATDfFw0edNBnF9MskuVfcm1vtBR85JdTAYM=; b=quKCS1SBfJH8vXsjaVTfkVXK8FgxgeZrkx6D9yEyS/qpR288graNPYIXn//sltO1xOU2PCaL+YRX5hWb4fqDBA0Lx3D6xb9PFkDwM6Khyy7v/7apPxx53F4FISkk1zM1i7xIaATGZCaPBD06eOP/1UlPGr2YDDF8R/aYfzf+8oB2avTsWPcKyDcm7cu4gprawI+4keFIHDrb1eAxykzbq+xnT3ffL8qgtM3lJ/1wtlCfIVqiOK7OesNBbiTVu6j1VSrBGR4Bvuv/NQW2adMyL102ZdbN70zBU5E41Z3a46GdFtbN1/Awom5fOWa9FGjjK2A29LGNXNkhpxqs32FaOg== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; 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=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Xu , Fabiano Rosas , Pierrick Bouvier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhao Liu , Halil Pasic , "Christian Borntraeger" , Jason Herne , Richard Henderson , Ilya Leoshkevich , David Hildenbrand , Eric Farman , Matthew Rosato , "Cornelia Huck" , Eric Blake , "Vladimir Sementsov-Ogievskiy" , John Snow , Markus Armbruster , Maor Gottlieb , Avihai Horon Subject: [PATCH v2 01/13] migration: Propagate errors in migration_completion_precopy() Date: Tue, 2 Jun 2026 12:26:09 +0300 Message-ID: <20260602092621.382-2-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20260602092621.382-1-avihaih@nvidia.com> References: <20260602092621.382-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF0000013F:EE_|CH3PR12MB9078:EE_ X-MS-Office365-Filtering-Correlation-Id: 7902df4b-f992-4ca8-aa44-08dec089156e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|7416014|1800799024|36860700016|22082099003|18002099003|56012099006|11063799006; X-Microsoft-Antispam-Message-Info: E9eeSsK4gPETRgd4zRWZA1UyhDkNtcvyZvVEIpaKAP36+FudkEyb8LHYRP3vx+IKyvqOZVKuGwe8ciQ94LeYQl/mLIBlugZUqGyJK7K6+wU3reLegtgg6OJK4O7GLaV42jjrNSSywzXR3pUbtaPDINSJBZ+4X5gw8UsB3VSiBDBndQqnixs61e//7VbADKVdr97H6Sr0ex7vsR/i5XORzLwBpReBhUpGztJPSruyGks6F8q/vnT+pehtPzC7wkWW5p6N3izI2wYUt0PjTV+WyS5l6BgvGnXfNmeAvRwRkEzZkX5e2Kgd3AvQyYz5YFydPFKqNU4TqTiRYg+Wwsz8WHWSbt9rWm9rMk0WAFVVQlI6Uaq0XAwi3mPepLYpKjpnqJ3OWqP2ieqtBdxK1o7RoMiAycCMKJ4QcUDQddle2e1TcPEk3EN2isTD8YF/m9bd487SzrOIljP9KD6T4LuS4HcbMe6Kenqdq9IKoSQV2IYCkl9oUQAdmR7klMA46kvglyg63uHk34lPUuCTDm4X4JSDJg98hpUqlyba8N2CyiTAAmLJ4qI/KtDCYj28V3HYEvQnfrDppEpLSGDRq1tZ65VXxrxBXqGl1vhrvztfuJozv8KHmBvK+MdLhggQwzxXW+iffdvZt2HTwtiedJjfWkqezrlFDfihns0KOEKK9Ltv7Qpl9gvajso5GG9BS2yN+VfQHI5cZ51yKZYi1+BW6mRxceuORipKdyzYyWyA1U4= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(82310400026)(376014)(7416014)(1800799024)(36860700016)(22082099003)(18002099003)(56012099006)(11063799006); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: h6PCj5s1LPPlXGvEz/d/jMgEp6Tb0oaA1U2iM5AhhuduEuDleUTp5bJqLqc/qcrB7YO2h7zxodiHyso8u/XnMR7E6lpqnBDngonZIF1WpM5gf7G2lwKWVVkpw3oLtETLJkTTMSCtnpdEQONnTDcCsQ0eSCk2uwCybhithd29U/V0SOQn92EqCJmKxGv6IDJseSgt7J9LSxzk+S9ZjwXFWXTeP7NVf5+c/7kDnFJp9bmmbOcS27Vii1cIB6fi32gaw4L3DVBDutvrlLJWj8blnX+FczQo6lCu00gEcp69Scp+8yVYcRW0t65NRUXb18rcxsBmjqdQDX0mzhXgPf8nemZ9qD8dUm+x7rCVtxbZ++Xn/Ac3Tj7uoaOkXxhv59qaT5+YxzTDnMyNNZ2ORdWQeBdPv1ZEiyzTzN42dGbyA2j9GF1PnBFxzEag/9TbK8TF X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2026 09:26:53.4285 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7902df4b-f992-4ca8-aa44-08dec089156e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF0000013F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9078 Received-SPF: permerror client-ip=2a01:111:f403:c107::3; envelope-from=avihaih@nvidia.com; helo=PH0PR06CU001.outbound.protection.outlook.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1780392459796154100 Content-Type: text/plain; charset="utf-8" migration_completion_precopy() doesn't propagate errors to migration core which leads to error information loss. Fix that. This prepares for a follow-up where migration_switchover_start() can fail on switchover-ack and still report a useful error. Errors from qemu_savevm_state_complete_precopy() are not propagated yet as it requires more plumbing. Signed-off-by: Avihai Horon --- migration/migration.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 074d3f2c69..7488a94206 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2814,7 +2814,7 @@ static bool migration_switchover_start(MigrationState= *s, Error **errp) return true; } =20 -static int migration_completion_precopy(MigrationState *s) +static int migration_completion_precopy(MigrationState *s, Error **errp) { int ret; =20 @@ -2823,11 +2823,12 @@ static int migration_completion_precopy(MigrationSt= ate *s) if (!migrate_mode_is_cpr()) { ret =3D migration_stop_vm(s, RUN_STATE_FINISH_MIGRATE); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to stop the VM"); goto out_unlock; } } =20 - if (!migration_switchover_start(s, NULL)) { + if (!migration_switchover_start(s, errp)) { ret =3D -EFAULT; goto out_unlock; } @@ -2869,7 +2870,7 @@ static void migration_completion(MigrationState *s) Error *local_err =3D NULL; =20 if (s->state =3D=3D MIGRATION_STATUS_ACTIVE) { - ret =3D migration_completion_precopy(s); + ret =3D migration_completion_precopy(s, &local_err); } else if (s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE) { migration_completion_postcopy(s); } else { @@ -2900,7 +2901,9 @@ static void migration_completion(MigrationState *s) return; =20 fail: - if (qemu_file_get_error_obj(s->to_dst_file, &local_err)) { + if (local_err) { + migrate_error_propagate(s, local_err); + } else if (qemu_file_get_error_obj(s->to_dst_file, &local_err)) { migrate_error_propagate(s, local_err); } else if (ret) { error_setg_errno(&local_err, -ret, "Error in migration completion"= ); --=20 2.40.1 From nobody Mon Jun 8 03:21:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1780392458; cv=pass; d=zohomail.com; s=zohoarc; b=fbL+TGzu6WHtfGkHL4VGawHoSUCYmzTvRh5iaOFLH6xnTFyPhpA6Ba+7RpQJ1Lk+5YjXzgMA74tqFxzvef2KlVnJIYyU9SQ/VdJHDKpW0HqVtymxD3s1QMSpwukmD++NMLYawgMk8Cad4IRHpDzXwR+lGKPBkP48kqU5wJQeOsY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780392458; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KwRXWXQThKiP1E2K10xzkOuF2awOCZv8PDIiP3uGgW4=; b=YIn9viIzebJbQ2zFbrq1Zk4YjHkIfSGLM6BmJDmoULUHZOrdWtX4HVGSjOsaLLDLf2tnU31ndzoIxSGpuMjfpywzZ+FrG510PGt6oMpvnMjZjpyKrze6klMIFc0YxwiNqv2IHde9k+mjpEHiiB1T4M5iA7hmTH2AMpkTBRQAEdk= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780392458723323.3790364051539; Tue, 2 Jun 2026 02:27:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wULP0-0005rt-B2; Tue, 02 Jun 2026 05:27:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULOy-0005rO-RB for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:27:12 -0400 Received: from mail-centralusazlp170110009.outbound.protection.outlook.com ([2a01:111:f403:c111::9] helo=DM5PR21CU001.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULOw-00041N-Nc for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:27:12 -0400 Received: from SA0PR12CA0012.namprd12.prod.outlook.com (2603:10b6:806:6f::17) by IA1PR12MB6211.namprd12.prod.outlook.com (2603:10b6:208:3e5::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.7; Tue, 2 Jun 2026 09:27:01 +0000 Received: from SN1PEPF0002636D.namprd02.prod.outlook.com (2603:10b6:806:6f:cafe::7f) by SA0PR12CA0012.outlook.office365.com (2603:10b6:806:6f::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.71.15 via Frontend Transport; Tue, 2 Jun 2026 09:27:00 +0000 Received: from mail.nvidia.com (216.228.117.161) by SN1PEPF0002636D.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.5 via Frontend Transport; Tue, 2 Jun 2026 09:27:00 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:26:41 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:26:41 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Tue, 2 Jun 2026 02:26:35 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=c0XIcC7IAO1mGIjIZ7+nLTd+sNJN8PoumOtRgjUuld8Smp06xHS/gs4qQzTd9iL3zcdsR1b22C0AmfmiKb0jBaSBnYWFuUaTU2FeDOp9YHOnR8vT8j+1iVwqugk6u6rZw9TSX4G4MBogvzkT9MWSi6tDLIZpijyINbKGoDL23R4LtXrAa2fhoyeEioXNT5gO7v/mnhGekF3ZoaBbImgjen4NH6tiFp7hmMsd2qD38pQPq5LcrvRqS9isLfgZ62dBYYDIBXHA6Vt8VnCO3WdEwfOxA1cypM12OcOgSPtcvtzPYwwCfXO8mLJ5SZbeFoXZlDDmcl/ZlIsH2leIQ8w1Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KwRXWXQThKiP1E2K10xzkOuF2awOCZv8PDIiP3uGgW4=; b=P2CHfIWb/haYURlRvTgvewbuVUR1znYIdZ8o+csv015MRmGqUPl6PaLIjAp5JelDCEvwU6NfOCIYZ12c3ZegpLd9oilOoeoGLecePXykwks+yFlklVdxvHNONqeCGvIqrJnYi2GGS/o9hJNuqYXCDPCL6Vk5ZnjWx/05s7jYY44TNsCQzxlk8fTSHKxf0T0jHIcZqxFcRPh4CBt3K0AB7g2Slgc3lSMmo9lLcA3ccgvpWlxK7rBaU0otnfRVudsfhoLjB5lThDFTOu2jnXdwjl4SqChpj8opPSSywsBP+FvxBfysCgG3HUqbh2JS+KqUlX4CrhR49hk5Q8MofMEm4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KwRXWXQThKiP1E2K10xzkOuF2awOCZv8PDIiP3uGgW4=; b=SjkdFN/tq44WPyexRNWgex3upIPIobxVxhvq5gkdj3c8YRFrYO7M9Tun6iEQ7zZyY0ep2qLFgw+qfrimJ99bB2Alt82Go1o6G6UbvZvgiLyF5yKaWeT08D8etGkBZKzt62s0YeqmBv6HpwBanWnhsFPKF3CbVLDDZSyMK6+/Yc2qPnIxgs5zM/F+cE+pcywHpoJOdZLRb9X9oz7IQ47R98ccGKtb1xAerX8EDIAGWf0fM79ux6G+Nd1xSnQyi2b20gS+yo0YWlBSjwrccaYkTZCzC+HSrfUYjzvqtuGSZaBVN2Jl03tRN1lb6FaHH+MbZEIh+ZNNoHC2vSruvIpmnw== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; 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=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Xu , Fabiano Rosas , Pierrick Bouvier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhao Liu , Halil Pasic , "Christian Borntraeger" , Jason Herne , Richard Henderson , Ilya Leoshkevich , David Hildenbrand , Eric Farman , Matthew Rosato , "Cornelia Huck" , Eric Blake , "Vladimir Sementsov-Ogievskiy" , John Snow , Markus Armbruster , Maor Gottlieb , Avihai Horon Subject: [PATCH v2 02/13] migration: Run final save_query_pending at switchover Date: Tue, 2 Jun 2026 12:26:10 +0300 Message-ID: <20260602092621.382-3-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20260602092621.382-1-avihaih@nvidia.com> References: <20260602092621.382-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636D:EE_|IA1PR12MB6211:EE_ X-MS-Office365-Filtering-Correlation-Id: af7d2936-509c-489d-3970-08dec0891963 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700016|376014|7416014|1800799024|56012099006|11063799006|5023799004|6133799003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: 935l/d2F1Le2qno8JJroKN+FHU3zKjOA8KQELeEjqgq4J+F+XuM6NfD9EwdyLEltdTMYgqPciWRVvremsfwaRXBXdT3E06qnLHAQQiWfVT7QMdzwfy6bamGROBuL9RmoZvDgNE3bF24ZMK+NAhSzKTVAIygmMqTz0ab5eTN7St0k/jbmG1Oi0xHp9HEEswlXobQHxGyH5NjE4VMYW15YE2onULAJ3ZjW4hfoYn+NaWql+rFAFVe1h/Ftc2pqOtk6FdHJ9SkHfxnYNgMTPlObhIhexPORWlP27bWLRKaBo2xtCKyU24JwSWb/QE9diwC1lQSoaFC7zB9DdYZCR6ewm/aYaNAWuFgzkabyE0RCyS6NCsS+EjHBGowPjqfxvxr9fdwKZb/gjav4Zhbx+SJZF99+Co8kWWNABkF3hSKqL5JcpA5wKfDXVY1lQ+Tbs2pmRN3FA/DJDwor9nv72yEADLtngKXmds2372qBCif7HscTTsULE4+LOyGw1+fOfiJ4YBQxRKJgxSxVCKqW+GdRC58wgX3WSq75jhLu0esx7uAdSPWXo1cnV/xnP72arvdYyEMO5HQCvjs/g/N1pQ9YGnOEdxLTlCW0IHkd1A82e0KxP3aHfoS+plQQbzYBhsGU+jYJlkcUthnbCncS03nKYDrh7oZtbp/n1zUiGfEgYm88qJ5sqlXag/ybdKMnIlrjWIoYWGaa/PGCo+J6NDh4auWrsWreKwLtu/Pjk/ALPAg= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230040)(82310400026)(36860700016)(376014)(7416014)(1800799024)(56012099006)(11063799006)(5023799004)(6133799003)(18002099003)(22082099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CcUwI3fBJhu2EyLsuefaPHLn/Xz/bPfx2p6Ao50h3Or+BolkWHKnc39SUXvd1E7YqESHkcLsQBd+34jhg2YZx6bn8fDlvDUbV7cVIashs6zZRDXtEwbZfrYuHzD8xrQOL5/F4mgIfmfSPQFrBQqVXYxgOdU44xTPaDu+bell9IN5VfKvMAKewrd0UwYVaBRRtMiocFf1Eii61U3im3lYS43wyxQq2YiOgux0HCBfVSpLgXjxsWE2GikhBmgaKcPL8hqkMT+lt0BoeKX1HK8HcYWuDvwSFRAm5CIiYdqUSVBSum59FI2I0vBkNaRcVpXD7dygBxig2de8VBmVKAH7RTgKFpkkj6VNy5mRngKBx3hZuAMhiZw8AI+js4k8FeSOlGjRT2Hcxso0UKkcXxzR7loUpkEqjeSN0xOf2lBY/ztIcoXDF/D3IEWJ9khWy08p X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2026 09:27:00.0691 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: af7d2936-509c-489d-3970-08dec0891963 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6211 Received-SPF: permerror client-ip=2a01:111:f403:c111::9; envelope-from=avihaih@nvidia.com; helo=DM5PR21CU001.outbound.protection.outlook.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FORGED_SPF_HELO=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1780392459837158500 Content-Type: text/plain; charset="utf-8" Before switchover, the source needs one last exact pending query so modules can flush dirty state. This is currently done ad hoc in modules handlers. For example, RAM syncs its dirty bitmap in its save_complete handler. This should be a general concept relevant for any module, so extract it to migration core instead by running a final save_query_pending before switchover. The final query requires special handling by modules (e.g., it's called with BQL locked, during VM stop), so extend save_query_pending SaveVMHandlers callback and qemu_savevm_query_pending() with a "final" flag so migration modules can tell the last pending query during switchover from periodic iteration queries. Not all modules need the final query; skip it for those who don't need. Signed-off-by: Avihai Horon --- include/migration/register.h | 41 ++++++++++++++++++---------------- migration/savevm.h | 3 ++- hw/s390x/s390-stattrib.c | 9 ++++++-- hw/vfio/migration.c | 6 ++++- migration/block-dirty-bitmap.c | 6 ++++- migration/migration.c | 7 ++++-- migration/ram.c | 37 ++++++++++++++++++------------ migration/savevm.c | 27 +++++++++++++++++----- migration/trace-events | 2 +- 9 files changed, 91 insertions(+), 47 deletions(-) diff --git a/include/migration/register.h b/include/migration/register.h index 5e5e0ee432..6f632123f1 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -171,6 +171,28 @@ typedef struct SaveVMHandlers { */ bool (*is_active_iterate)(void *opaque); =20 + /** + * @save_query_pending + * + * This estimates the remaining data to transfer on the source side. + * + * When @exact is true, a module must report accurate results. When + * @exact is false, a module may report estimates. + * + * It's highly recommended that modules implement a faster version of + * the query path (for example, by proper caching on the counters) if + * an accurate query will be time-consuming. + * + * @opaque: data pointer passed to register_savevm_live() + * @pending: pointer to a MigPendingData struct + * @exact: set to true for an accurate (slow) query + * @final: set to true for the final query during switchover. When fin= al is + * true, the query is called with BQL locked. Otherwise, it's called w= ith + * BQL unlocked. + */ + void (*save_query_pending)(void *opaque, MigPendingData *pending, + bool exact, bool final); + /* This runs outside the BQL in the migration case, and * within the lock in the savevm case. The callback had better only * use data that is local to the migration thread or protected @@ -210,25 +232,6 @@ typedef struct SaveVMHandlers { */ bool (*save_postcopy_prepare)(QEMUFile *f, void *opaque, Error **errp); =20 - /** - * @save_query_pending - * - * This estimates the remaining data to transfer on the source side. - * - * When @exact is true, a module must report accurate results. When - * @exact is false, a module may report estimates. - * - * It's highly recommended that modules implement a faster version of - * the query path (for example, by proper caching on the counters) if - * an accurate query will be time-consuming. - * - * @opaque: data pointer passed to register_savevm_live() - * @pending: pointer to a MigPendingData struct - * @exact: set to true for an accurate (slow) query - */ - void (*save_query_pending)(void *opaque, MigPendingData *pending, - bool exact); - /** * @load_state * diff --git a/migration/savevm.h b/migration/savevm.h index 96fdf96d4e..10b3d78a5f 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -45,7 +45,8 @@ int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy); void qemu_savevm_state_cleanup(void); void qemu_savevm_state_complete_postcopy(QEMUFile *f); int qemu_savevm_state_complete_precopy(MigrationState *s); -void qemu_savevm_query_pending(MigPendingData *pending, bool exact); +void qemu_savevm_query_pending_iter(MigPendingData *pending, bool exact); +void qemu_savevm_query_pending_final(MigPendingData *pending); int qemu_savevm_state_complete_precopy_iterable(QEMUFile *f, bool in_postc= opy); bool qemu_savevm_state_postcopy_prepare(QEMUFile *f, Error **errp); void qemu_savevm_state_end(QEMUFile *f); diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c index c334714b31..aed0c6844d 100644 --- a/hw/s390x/s390-stattrib.c +++ b/hw/s390x/s390-stattrib.c @@ -190,12 +190,17 @@ static int cmma_save_setup(QEMUFile *f, void *opaque,= Error **errp) } =20 static void cmma_state_pending(void *opaque, MigPendingData *pending, - bool exact) + bool exact, bool final) { S390StAttribState *sas =3D S390_STATTRIB(opaque); S390StAttribClass *sac =3D S390_STATTRIB_GET_CLASS(sas); - long long res =3D sac->get_dirtycount(sas); + long long res; =20 + if (final) { + return; + } + + res =3D sac->get_dirtycount(sas); if (res >=3D 0) { pending->precopy_bytes +=3D res; } diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index fb12b9717f..95072d6664 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -622,12 +622,16 @@ static void vfio_state_pending_sync(VFIODevice *vbase= dev) } =20 static void vfio_state_pending(void *opaque, MigPendingData *pending, - bool exact) + bool exact, bool final) { VFIODevice *vbasedev =3D opaque; VFIOMigration *migration =3D vbasedev->migration; uint64_t precopy_size, stopcopy_size; =20 + if (final) { + return; + } + if (exact) { vfio_state_pending_sync(vbasedev); } diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 7ef3759e53..66ed91de03 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -767,12 +767,16 @@ static int dirty_bitmap_save_complete(QEMUFile *f, vo= id *opaque) } =20 static void dirty_bitmap_state_pending(void *opaque, MigPendingData *data, - bool exact) + bool exact, bool final) { DBMSaveState *s =3D &((DBMState *)opaque)->save; SaveBitmapState *dbms; uint64_t pending =3D 0; =20 + if (final) { + return; + } + bql_lock(); =20 QSIMPLEQ_FOREACH(dbms, &s->dbms_list, entry) { diff --git a/migration/migration.c b/migration/migration.c index 7488a94206..df8ed3a9fd 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2787,12 +2787,15 @@ static bool migration_switchover_prepare(MigrationS= tate *s) static bool migration_switchover_start(MigrationState *s, Error **errp) { ERRP_GUARD(); + MigPendingData pending =3D {}; =20 if (!migration_switchover_prepare(s)) { error_setg(errp, "Switchover is interrupted"); return false; } =20 + qemu_savevm_query_pending_final(&pending); + /* Inactivate disks except in COLO */ if (!migrate_colo()) { /* @@ -3285,7 +3288,7 @@ static void migration_iteration_go_next(MigPendingDat= a *pending) /* * Do a slow sync first before boosting the iteration count. */ - qemu_savevm_query_pending(pending, true); + qemu_savevm_query_pending_iter(pending, true); =20 /* * Update the dirty information for the whole system for this @@ -3336,7 +3339,7 @@ static MigIterateState migration_iteration_run(Migrat= ionState *s) bool complete_ready; =20 /* Fast path - get the estimated amount of pending data */ - qemu_savevm_query_pending(&pending, false); + qemu_savevm_query_pending_iter(&pending, false); =20 if (in_postcopy) { /* diff --git a/migration/ram.c b/migration/ram.c index fc38ffbf8a..4e3f442593 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3376,10 +3376,6 @@ static int ram_save_complete(QEMUFile *f, void *opaq= ue) rs->last_stage =3D !migration_in_colo_state(); =20 WITH_RCU_READ_LOCK_GUARD() { - if (!migration_in_postcopy()) { - migration_bitmap_sync_precopy(true); - } - ret =3D rdma_registration_start(f, RAM_CONTROL_FINISH); if (ret < 0) { qemu_file_set_error(f, ret); @@ -3442,25 +3438,38 @@ static int ram_save_complete(QEMUFile *f, void *opa= que) return qemu_fflush(f); } =20 -static void ram_state_pending(void *opaque, MigPendingData *pending, - bool exact) +static void ram_state_pending_sync(bool exact, bool final) { - RAMState **temp =3D opaque; - RAMState *rs =3D *temp; - uint64_t remaining_size; - /* * Sync is not needed either with: (1) a fast query, or (2) after * postcopy has started (no new dirty will generate anymore). */ - if (exact && !migration_in_postcopy()) { + if (!exact || migration_in_postcopy()) { + return; + } + + /* Final pending query is called with BQL locked */ + if (!final) { bql_lock(); - WITH_RCU_READ_LOCK_GUARD() { - migration_bitmap_sync_precopy(false); - } + } + + WITH_RCU_READ_LOCK_GUARD() { + migration_bitmap_sync_precopy(final); + } + + if (!final) { bql_unlock(); } +} + +static void ram_state_pending(void *opaque, MigPendingData *pending, + bool exact, bool final) +{ + RAMState **temp =3D opaque; + RAMState *rs =3D *temp; + uint64_t remaining_size; =20 + ram_state_pending_sync(exact, final); remaining_size =3D rs->migration_dirty_pages * TARGET_PAGE_SIZE; =20 if (migrate_postcopy_ram()) { diff --git a/migration/savevm.c b/migration/savevm.c index 23adaf9dd9..22cb6a15c6 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1795,7 +1795,8 @@ int qemu_savevm_state_complete_precopy(MigrationState= *s) return qemu_fflush(f); } =20 -void qemu_savevm_query_pending(MigPendingData *pending, bool exact) +static void qemu_savevm_query_pending(MigPendingData *pending, bool exact, + bool final) { SaveStateEntry *se; =20 @@ -1808,7 +1809,7 @@ void qemu_savevm_query_pending(MigPendingData *pendin= g, bool exact) if (!qemu_savevm_state_active(se)) { continue; } - se->ops->save_query_pending(se->opaque, pending, exact); + se->ops->save_query_pending(se->opaque, pending, exact, final); } =20 pending->total_bytes =3D pending->precopy_bytes + @@ -1817,16 +1818,30 @@ void qemu_savevm_query_pending(MigPendingData *pend= ing, bool exact) /* * Update system remaining dirty bytes whenever QEMU queries. It will * make the value to be not as accurate, but should still be pretty - * close to reality when this got invoked frequently while iterating. + * close to reality when this got invoked frequently while iterating. = Don't + * update in final query as some modules may skip it if not needed. */ - mig_stats.dirty_bytes_total =3D pending->total_bytes; - - trace_qemu_savevm_query_pending(exact, pending->precopy_bytes, + if (!final) { + mig_stats.dirty_bytes_total =3D pending->total_bytes; + } + trace_qemu_savevm_query_pending(exact, final, pending->precopy_bytes, pending->stopcopy_bytes, pending->postcopy_bytes, pending->total_bytes); } =20 +void qemu_savevm_query_pending_iter(MigPendingData *pending, bool exact) +{ + qemu_savevm_query_pending(pending, exact, false); +} + +void qemu_savevm_query_pending_final(MigPendingData *pending) +{ + g_assert(bql_locked()); + + qemu_savevm_query_pending(pending, true, true); +} + void qemu_savevm_state_cleanup(void) { SaveStateEntry *se; diff --git a/migration/trace-events b/migration/trace-events index de99d976ab..1c9212d3e2 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -7,7 +7,7 @@ qemu_loadvm_state_section_partend(uint32_t section_id) "%u" qemu_loadvm_state_post_main(int ret) "%d" qemu_loadvm_state_section_startfull(uint32_t section_id, const char *idstr= , uint32_t instance_id, uint32_t version_id) "%u(%s) %u %u" qemu_savevm_send_packaged(void) "" -qemu_savevm_query_pending(bool exact, uint64_t precopy, uint64_t stopcopy,= uint64_t postcopy, uint64_t total) "exact=3D%d, precopy=3D%"PRIu64", stopc= opy=3D%"PRIu64", postcopy=3D%"PRIu64", total=3D%"PRIu64 +qemu_savevm_query_pending(bool exact, bool final, uint64_t precopy, uint64= _t stopcopy, uint64_t postcopy, uint64_t total) "exact=3D%d, final=3D%d, pr= ecopy=3D%"PRIu64", stopcopy=3D%"PRIu64", postcopy=3D%"PRIu64", total=3D%"PR= Iu64 loadvm_state_switchover_ack_needed(unsigned int switchover_ack_pending_num= ) "Switchover ack pending num=3D%u" loadvm_state_setup(void) "" loadvm_state_cleanup(void) "" --=20 2.40.1 From nobody Mon Jun 8 03:21:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1780392476; cv=pass; d=zohomail.com; s=zohoarc; b=QHkOct0xsvJJxJWPzoW5NFxmOcxZaEQLaO6NouffaKApp239kJO4CVB4VVXv0maGZmbpgFDSMemr0lIFQyhbTy1b+ox3SJGzSOmQ3Lh82wi6ZoSw8XOqWiV4HX1kYcQLj26EFmOxZ37y+3azEY/JZvAuY6SJIrhBf+vpBXD1Wuk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780392476; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=J5n6UbtBQcN7ozLNDYIg22VzgNx59cINg2pmE/3tCVc=; b=nHx17UeF2y0HvZLVEYwImsscRhqeNuEsXpVRtPWuWxXxsV3GS7thiLmP5rSEK+vc1M8IrwfQtnYnCPM00fy1KB4r7E0UP6vz1Bt4o6q+bWIgGLK9R7edMTPX/ncaxO78i10soVW8rygE2aTOyyIBk8aTYz5WLxEEutRmjK0TfVc= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780392476414401.8924724685619; Tue, 2 Jun 2026 02:27:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wULOz-0005rp-Eb; Tue, 02 Jun 2026 05:27:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULOx-0005rE-Jz for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:27:11 -0400 Received: from mail-northcentralusazlp170130007.outbound.protection.outlook.com ([2a01:111:f403:c105::7] helo=CH4PR04CU002.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULOw-00041M-6c for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:27:11 -0400 Received: from SA0PR12CA0019.namprd12.prod.outlook.com (2603:10b6:806:6f::24) by CY8PR12MB8363.namprd12.prod.outlook.com (2603:10b6:930:7a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.71.16; Tue, 2 Jun 2026 09:27:04 +0000 Received: from SN1PEPF0002636D.namprd02.prod.outlook.com (2603:10b6:806:6f:cafe::4f) by SA0PR12CA0019.outlook.office365.com (2603:10b6:806:6f::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.71.16 via Frontend Transport; Tue, 2 Jun 2026 09:27:04 +0000 Received: from mail.nvidia.com (216.228.117.161) by SN1PEPF0002636D.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.5 via Frontend Transport; Tue, 2 Jun 2026 09:27:04 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:26:48 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:26:47 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Tue, 2 Jun 2026 02:26:42 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ey90g4Y7Dtywwn2WkUHILQaQyGZwKdHG8WnAQDiBX2dI2lh2Mz6v7Dn7WLweJ86dzmHJAE0LEo/tHKdRSpdc0lHaL4LvEguT9LE6gxYEfT8zHs7jh9Wo2aQ8Eo/ytgabA9jMzrltFDxPEgxd+NRenvitI3BYWc33dy3JIoo6vMfnh6BewKDG9uYU0sRoTt8Wg2fhHvb4rL7JaAJ70Z7pzww8efJGeXbJhRBRxOPaqkZI7VOdGQiamc8zk0Im31JD3yv1TYtBmZ24xbCDKNXQwoDSIVhEbR2k4W57Dd21goY0usWWRsEmSqvC3YHapRZ0dBxzjWqSqa4OATocqfGaLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=J5n6UbtBQcN7ozLNDYIg22VzgNx59cINg2pmE/3tCVc=; b=Ym6jYONpJonQuqwssvW2/UNW2c1GhA9MOiOtFc8tR4uHa5cThcXHkxVEKuia7DuDRRkOOQNFkpyy/BqyxRMPeyhx58kTnlnvWrjObiMWBnhb3kb3X4dcsbKnnmZOu5US/9Ch4uJFLWTFoe/AN2YhFLGnZyx2EaDuTbfk254gtxbjK8gnRGamHSS41wos2WRK6O6c/YnR0uPF/KGacAnPPD/fNTDpXpa6NtWlEO8y4OeEPmrOcp1ciW6WMiwtZq/30sy5Ago38AqgxPxE9Pv30Q0MnYHA1RixPE801RSutLb2afUTBqhXvXcK4248Wg8a0ICbxfbSxXtK5YLoMfkRzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=J5n6UbtBQcN7ozLNDYIg22VzgNx59cINg2pmE/3tCVc=; b=LB/Q7wtzXIsab72kbrbizxmWgElBt4+OJn/MIByUh0laV51xpvHJeQJWXj6/vnXBzVMq2SY2Vedo5Kp9r5f1wsUufAJEHVGD7Fh7JjzUO4O8a2rm/XgG+9+beWkVgRE6K0EdErm9wwF6e5a/8Wyu6d6mPpqrqqTKqxGIbSXc+QlVHQNDKdmBMC2T2UjZr4ofYBjKSV7/R9GUybL6bH2v4VZtTn1gJFSJ/ER3fgqOWLcgtStKbifswFF4dS3YGBtMD4Huh//5G6LbYrBl8elAkbM9pdSLQvCLC3Ak0SUqqMmtVqk+8mqiR24XiYuy2fukpsWZLGjC8EnUksMJZlxJTQ== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; 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=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Xu , Fabiano Rosas , Pierrick Bouvier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhao Liu , Halil Pasic , "Christian Borntraeger" , Jason Herne , Richard Henderson , Ilya Leoshkevich , David Hildenbrand , Eric Farman , Matthew Rosato , "Cornelia Huck" , Eric Blake , "Vladimir Sementsov-Ogievskiy" , John Snow , Markus Armbruster , Maor Gottlieb , Avihai Horon Subject: [PATCH v2 03/13] migration: Log the approver in qemu_loadvm_approve_switchover() Date: Tue, 2 Jun 2026 12:26:11 +0300 Message-ID: <20260602092621.382-4-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20260602092621.382-1-avihaih@nvidia.com> References: <20260602092621.382-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636D:EE_|CY8PR12MB8363:EE_ X-MS-Office365-Filtering-Correlation-Id: 308772cf-3db7-44a3-b963-08dec0891bf0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|82310400026|1800799024|376014|36860700016|18002099003|22082099003|56012099006|11063799006; X-Microsoft-Antispam-Message-Info: uUQy/YIdK1FdLUZNk3RPIiOFh+x+djjyJks4W7DJQIq3Bjz5I2OlYPjWHbYssZ9VMGbRUVQhOKA2AI/aPzsuJq/OqlVRUcyxa7cJiboJog/Zd+4/gO8qfr8kBuMCGD52t1qMjQEG9xY1t+O0yzsQeqyH8jvkPX/f9/luep8okHccP8HIeb8UCkj0+XN17LpczSIoelbY7GhnPiibcCMyxUtMONJsI9+rsSxpxBP1jFPBBr12EYFUs/OKdlM+/ZKf9Pr00qphtcRcHLfym+hm6WiBjoI4n7IVq1hJM1U5BdbGQnMGUkGGrAYpvbHxc2m7speWgVIpRrO28pISP3o8SGpG80aTc0PN/S72wH81kPK7fi0kKhD4LC5t58yWUcI4oNZXpRPM5EGMtEBk+aD6mrX25ucORLtQR8QOiRPbXzY+Ge4Y14FkoAbEriI492Puh2St+C9eNsUGx5cn6ncIdtMZMN47KweanzKDqLOOV1fiPprnXdLnI7QbH0wYnbiJ4LOPBv3KPx+vTZly4NbQvMf/U1ZQd5qYIZNE0FyRhDENG2oaR/FChhmw4b+07bDnO1AvGW8h2/eM0GVtxRiktZmk3w+rxQn/zGBMMRUZO5qeYnViQD6H5jtp7u5T5xKyuuKyidKbxsoFUxoZi2ODnr5eHPR27hBfzph1+J3JSnNo6r1eLWalnr9pzQ7HEwVStAH8DgaUtMRrLahb1veir6tCKDpXCf7PSWfCRDsGuCo= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230040)(7416014)(82310400026)(1800799024)(376014)(36860700016)(18002099003)(22082099003)(56012099006)(11063799006); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OPrcmlR/Dy/u8LepCVIo3y4SDJnSTXKMZ4i4XGPrRYLf1ANC3oGaQsMsllMJhMYW+y3FdglRXC6KpM/A/HhrwyoGCyywkLv1SSgDIjag1mpA42KfjfkYffTV59uxkBnxNToR0U11LT+WeVGjfduWtDpfWaeHfYZVFHolsEOQpEIboZOQ3hWigZOjylRwuH+/Dvw0Y90BW8c5FxR5wCAZy5POnyhz8wsAHmKQbupWpHuctzLFsUChz4euMQZVFwmVXjCtByky18JPLNh5mp+sUW2KB5YUVcnOdeGxh8voMv/MGtign5scRwnWmaV9RM0VK4E5/GomuZWe2gV9npHssZew/5cRWpXgaPD2DpzV+OXLS00u18TT6H/ANsqFccYdw4BJvdR7QO1XPojE2CJuV25bSGyppWHE4SwtIaCgAtotinmHmnSHra8CtLvy6X69 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2026 09:27:04.3407 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 308772cf-3db7-44a3-b963-08dec0891bf0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8363 Received-SPF: permerror client-ip=2a01:111:f403:c105::7; envelope-from=avihaih@nvidia.com; helo=CH4PR04CU002.outbound.protection.outlook.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FORGED_SPF_HELO=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1780392477896154100 Content-Type: text/plain; charset="utf-8" Pass the device name that approved switchover to qemu_loadvm_approve_switchover() and log it in the trace for debugging purposes. Reviewed-by: Peter Xu Signed-off-by: Avihai Horon --- migration/savevm.h | 2 +- hw/vfio/migration.c | 2 +- migration/savevm.c | 4 ++-- migration/trace-events | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/migration/savevm.h b/migration/savevm.h index 10b3d78a5f..0d732eb0f7 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -71,7 +71,7 @@ void qemu_loadvm_state_cleanup(MigrationIncomingState *mi= s); int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis, Error **errp); int qemu_load_device_state(QEMUFile *f, Error **errp); -int qemu_loadvm_approve_switchover(void); +int qemu_loadvm_approve_switchover(const char *approver); int qemu_savevm_state_non_iterable(QEMUFile *f, Error **errp); int qemu_savevm_state_non_iterable_early(QEMUFile *f, JSONWriter *vmdesc, diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 95072d6664..49266cbd76 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -846,7 +846,7 @@ static int vfio_load_state(QEMUFile *f, void *opaque, i= nt version_id) return -EINVAL; } =20 - ret =3D qemu_loadvm_approve_switchover(); + ret =3D qemu_loadvm_approve_switchover(vbasedev->name); if (ret) { error_report( "%s: qemu_loadvm_approve_switchover failed, err=3D%d (= %s)", diff --git a/migration/savevm.c b/migration/savevm.c index 22cb6a15c6..fd870345b4 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -3172,7 +3172,7 @@ int qemu_load_device_state(QEMUFile *f, Error **errp) return 0; } =20 -int qemu_loadvm_approve_switchover(void) +int qemu_loadvm_approve_switchover(const char *approver) { MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 @@ -3181,7 +3181,7 @@ int qemu_loadvm_approve_switchover(void) } =20 mis->switchover_ack_pending_num--; - trace_loadvm_approve_switchover(mis->switchover_ack_pending_num); + trace_loadvm_approve_switchover(approver, mis->switchover_ack_pending_= num); =20 if (mis->switchover_ack_pending_num) { return 0; diff --git a/migration/trace-events b/migration/trace-events index 1c9212d3e2..c0c433744c 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -24,7 +24,7 @@ loadvm_postcopy_ram_handle_discard_end(void) "" loadvm_postcopy_ram_handle_discard_header(const char *ramid, uint16_t len)= "%s: %ud" loadvm_process_command(const char *s, uint16_t len) "com=3D%s len=3D%d" loadvm_process_command_ping(uint32_t val) "0x%x" -loadvm_approve_switchover(unsigned int switchover_ack_pending_num) "Switch= over ack pending num=3D%u" +loadvm_approve_switchover(const char *approver, unsigned int switchover_ac= k_pending_num) "Approver %s, switchover_ack_pending_num %u" postcopy_ram_listen_thread_exit(void) "" postcopy_ram_listen_thread_start(void) "" qemu_savevm_send_postcopy_advise(void) "" --=20 2.40.1 From nobody Mon Jun 8 03:21:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1780392509; cv=pass; d=zohomail.com; s=zohoarc; b=mj6eSqO4lXxDHRWB3dbOTvS7Se3PhF/ZckdP9ZKQfRzkYn0dSH+LLR4Dbd4ECecID2ZuCGBrtd/rpF18XKf2uF7ymc8j6dsFNu+SGyirdj43EZQC7/P587fwc95GAdoZHEvmYdvj16c5+LhIB5MeZDRbiXh+9ANr1hUo68hGo9g= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780392509; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Qdsxysvd/vL/pVguOeDs/agi60N/8Kn2Ho1M7ePij/o=; b=IBSztB07f9+b1iCVyKCCzDWgFNnzBN/FrvV4z2OaXm5o7kW8X3gqJS6YpGP6udZMwOeIkIb00S0R/Q2pJ8FM1iSDdT76OCrAGjOGKRYch9kNeoE9ZSWWXbW5E02rr7w2BiuIJX7/gYxpKhOMYyC0PMnn5WzLuYmmDQw+wjktBUw= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17803925098411014.1721732764726; Tue, 2 Jun 2026 02:28:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wULPE-0005tx-Sf; Tue, 02 Jun 2026 05:27:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULPD-0005tV-RX for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:27:27 -0400 Received: from mail-westusazlp170100005.outbound.protection.outlook.com ([2a01:111:f403:c001::5] helo=BYAPR05CU005.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULPA-00047T-3e for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:27:27 -0400 Received: from CH5PR05CA0013.namprd05.prod.outlook.com (2603:10b6:610:1f0::26) by IA1PR12MB6259.namprd12.prod.outlook.com (2603:10b6:208:3e5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.7; Tue, 2 Jun 2026 09:27:11 +0000 Received: from CH2PEPF00000142.namprd02.prod.outlook.com (2603:10b6:610:1f0:cafe::66) by CH5PR05CA0013.outlook.office365.com (2603:10b6:610:1f0::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.92.7 via Frontend Transport; Tue, 2 Jun 2026 09:27:10 +0000 Received: from mail.nvidia.com (216.228.117.160) by CH2PEPF00000142.mail.protection.outlook.com (10.167.244.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.5 via Frontend Transport; Tue, 2 Jun 2026 09:27:10 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:26:54 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:26:54 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Tue, 2 Jun 2026 02:26:48 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qoEsxxYsgPlx7DKxZ7wcUtHxJ2A9/KwVNFBAQIz86fV1K+Iu6pRk0wHR/2H8PsF0+g74obxeD/8Bcnf7vmZSPzJdSp7HMKhkDLQso6q97N6ow+tm5EHFac33lwrktC+YBlbCvt70wtewVDrFjgDGiG2IhRLAXoodqRMB5lD57ONMoiQk5g/YbWVQ1/Z4P1zctJOfPOHLUJS8Y+KH7zvT97tGTPWLMKKM9aAnDRwB4aLEXw3qvo5u+xuI4Pk1nNPmoJNxRtF8tcpyUIIe2sqmC0UKBbuHl4/4Pnw/ZSuOJWbjTWh7UCybaTeUacuaqD9hk5zhvipNlGvRCaBw10oq+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Qdsxysvd/vL/pVguOeDs/agi60N/8Kn2Ho1M7ePij/o=; b=vjnyqj8+6ZYHHJgVW727gwngw2394GeIR9B+WM2pZz3XZhZlHdcG8slX7ArJ42GuP4FCFfzk4nomxyvkpE+laUdn5FZG1au7Gb6Ce2wAyYWHVU6idXLQ8LqY0Nk3b/BQg5125QhFv3IFQ9ZZREfgZVuYSDttFvuG4Fqn4AI7fElY6YXjmSMAO3wnhxOEkHPYf3ShZMzXanf4g6JbC1IhbEEcyP/E/ddf0mY0UJ/41m1netWdelelDI0f3al1nuXFqjymF7b1vjueUK7a6fqxI7RLJALadAl2xgA4ZmZ1hgYZ93IagblLQbhRUXe/J26nQwbQcTba/ZA803U+rhfQPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Qdsxysvd/vL/pVguOeDs/agi60N/8Kn2Ho1M7ePij/o=; b=mlKcRzY0WCIK/UC9vORMFvYhApaJo+fvFsvX8QHHlyvSXifvSO6hfg+mDasX/BZJPinmDWfEYJARAeQwy85JXrvDo4PSSegTai9zZ12s4jwardYVuRo8ifgz9Z21iWKNPLsAlZonr6bY3OzpjMkJnNhdgyj4CEVHk3J4ut9L7QGotd44CwM+oVeIim1WVStto8vp0fvocABNuYOERx42vxeyLJEosDcXQuFK2Cdg2ltahCJ+yzE9bh2yvM4d/5HbUC5S7kDNhtvjqWD3aaRTk5MG3cViwyT1vZfygIDnpmHvRXxRAwg/fM5O7ufv8YDi5G9B/9TRldWIqN8UZh0/QA== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; 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=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Xu , Fabiano Rosas , Pierrick Bouvier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhao Liu , Halil Pasic , "Christian Borntraeger" , Jason Herne , Richard Henderson , Ilya Leoshkevich , David Hildenbrand , Eric Farman , Matthew Rosato , "Cornelia Huck" , Eric Blake , "Vladimir Sementsov-Ogievskiy" , John Snow , Markus Armbruster , Maor Gottlieb , Avihai Horon Subject: [PATCH v2 04/13] migration: Replace switchover_ack_needed SaveVMHandler Date: Tue, 2 Jun 2026 12:26:12 +0300 Message-ID: <20260602092621.382-5-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20260602092621.382-1-avihaih@nvidia.com> References: <20260602092621.382-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000142:EE_|IA1PR12MB6259:EE_ X-MS-Office365-Filtering-Correlation-Id: afc89234-fe83-4d46-15d8-08dec0891faf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|7416014|36860700016|82310400026|376014|18002099003|11063799006|22082099003|56012099006; X-Microsoft-Antispam-Message-Info: zlvVaUl5UIZkSYf41Q99R0gh5aGreKorITlM8KC5Li7L6TjovyrdrqQ5ZcIhPZOqlETAtxthW1pbHwWJ0CdWXOLY/ZjeHOSVG2nioQ4eSeFCWVz05X5S2LqWP2DGKa78/wOtjvEa/S4fM5FveJR94jCk/tAM2PpS8U9SQiHmYJH26pEHPz9eQ9yurbUyFaT9quuRYLXFW4MJpyMQyDJEifyfc5qccYB1luhHirDWFwd2bfxegdA5vwOyj2DFLV3oL9MilgD8mSoTNIslxPCoBoA0A7P8+DrioI7hIQUZKmkxf2Q35wmFvFF9MdZ/UH5gIdIfaR7gmPDgP34cz3MTV73c45XHrMGiBndlZd5tZbhnVB06nclzYHFKpc/ZD15kSO8xiNtbPIWkXOloJvJZ2VDQa9viDvmuUo3pmW0f1g+J1eL5nlQTN4xtSwHyqkvWqYal+MLbMV4M/qbzHdLyoGIX7A3aYpgLS2ufvZXGLQQ5zaTvtbleKjW50jl/hxV3dHPA3jO9Og8+i6l7IweIC73oQDqxk8JYIOvoFESIzl5XYm9PSuAWHnQ+6Cnl9LNX74JojmVPrauhmDYC6IEAyY5fLF/H/9vJ4UseAtqGOwlURszxTNgHWyQWCBrPx/PM4QPnQS+dC8ibEomA9Av/jAbkguNaXmJhcZgimSB77TN07LS11Vf356L/lZIl2ypV/2qOgjMAh68DI/HjBc5Bd6TseY2ETxmAuePDeYW9hVE= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(1800799024)(7416014)(36860700016)(82310400026)(376014)(18002099003)(11063799006)(22082099003)(56012099006); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hUiRm4ApPy+KmYOl1Zxdx3PHufgyGXAhLUz4k9ghlpR2PwbLPcBa258KeaxosmP5BBjMtWs/0SUAR7wWgz+U59X8aPQKRZiSubxA/I41pQvGmDO9DWUqP/kwtz+u57eL9rboG3dB6BLamo65YR7YXES+DjfbgIkB9jtlHtq090lSOKTVk1Bws0/C3+vdD1FZ1J4BwZ0jqLTOBUyLjvXFobEzEu0FTc85f3AN6RUMd53c8rmGxa0zZ34PkRzSKv0QWlOo4YgxeTS5OM7ecLEX1SZ1vnzEe8wdvwHR3Gv05J5uDunu7e8JRAw1OeNj/X3Lrt/aIRGnd5g/zjRL6B9emYeq78Lt+jTUoSgHtxHE/oPp/1s2ru/5Yt3emT/W2UtvO39XXt8YAuuaElUC3lhRyL62TpLGvQ7E87E3NAw737maphmza0TKVNSEpMkvUGQW X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2026 09:27:10.6238 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: afc89234-fe83-4d46-15d8-08dec0891faf X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF00000142.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6259 Received-SPF: permerror client-ip=2a01:111:f403:c001::5; envelope-from=avihaih@nvidia.com; helo=BYAPR05CU005.outbound.protection.outlook.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FORGED_SPF_HELO=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1780392512190154100 Content-Type: text/plain; charset="utf-8" A new switchover-ack mechanism that will replace the existing one will be added in the following patches. The new mechanism will not use switchover_ack_needed SaveVMHandler, however, the old mechanism must still be kept for backward compatibility. To keep things clear and decrease API surface of old code, replace switchover_ack_needed SaveVMHandler with a regular function migration_request_switchover_ack(). No functional changes intended. Acked-by: Peter Xu Signed-off-by: Avihai Horon --- docs/devel/migration/vfio.rst | 3 --- include/migration/misc.h | 2 ++ include/migration/register.h | 13 ------------- hw/vfio/migration.c | 18 ++++++++++-------- migration/migration.c | 15 +++++++++++++++ migration/savevm.c | 21 --------------------- migration/trace-events | 2 +- 7 files changed, 28 insertions(+), 46 deletions(-) diff --git a/docs/devel/migration/vfio.rst b/docs/devel/migration/vfio.rst index 691061d182..854277b11c 100644 --- a/docs/devel/migration/vfio.rst +++ b/docs/devel/migration/vfio.rst @@ -59,9 +59,6 @@ VFIO implements the device hooks for the iterative approa= ch as follows: * A ``save_live_iterate`` function that reads the VFIO device's data from = the vendor driver during iterative pre-copy phase. =20 -* A ``switchover_ack_needed`` function that checks if the VFIO device uses - "switchover-ack" migration capability when this capability is enabled. - * A ``switchover_start`` function that in the multifd mode starts a thread= that reassembles the multifd received data and loads it in-order into the dev= ice. In the non-multifd mode this function is a NOP. diff --git a/include/migration/misc.h b/include/migration/misc.h index 3159a5e53c..a2219c981b 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -156,4 +156,6 @@ bool multifd_device_state_save_thread_should_exit(void); void multifd_abort_device_state_save_threads(void); bool multifd_join_device_state_save_threads(void); =20 +void migration_request_switchover_ack(const char *requester); + #endif diff --git a/include/migration/register.h b/include/migration/register.h index 6f632123f1..a61c4236d2 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -302,19 +302,6 @@ typedef struct SaveVMHandlers { */ int (*resume_prepare)(MigrationState *s, void *opaque); =20 - /** - * @switchover_ack_needed - * - * Checks if switchover ack should be used. Called only on - * destination. - * - * @opaque: data pointer passed to register_savevm_live() - * - * Returns true if switchover ack should be used and false - * otherwise - */ - bool (*switchover_ack_needed)(void *opaque); - /** * @switchover_start * diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 49266cbd76..6303f006a2 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -487,6 +487,14 @@ static bool vfio_precopy_supported(VFIODevice *vbasede= v) return migration->mig_flags & VFIO_MIGRATION_PRE_COPY; } =20 +static void vfio_request_switchover_ack(VFIODevice *vbasedev) +{ + if (vfio_precopy_supported(vbasedev)) { + /* Precopy support implies switchover-ack is needed */ + migration_request_switchover_ack(vbasedev->name); + } +} + /* ---------------------------------------------------------------------- = */ =20 static int vfio_save_prepare(void *opaque, Error **errp) @@ -775,6 +783,8 @@ static int vfio_load_setup(QEMUFile *f, void *opaque, E= rror **errp) return ret; } =20 + vfio_request_switchover_ack(vbasedev); + return 0; } =20 @@ -873,13 +883,6 @@ static int vfio_load_state(QEMUFile *f, void *opaque, = int version_id) return ret; } =20 -static bool vfio_switchover_ack_needed(void *opaque) -{ - VFIODevice *vbasedev =3D opaque; - - return vfio_precopy_supported(vbasedev); -} - static int vfio_switchover_start(void *opaque) { VFIODevice *vbasedev =3D opaque; @@ -903,7 +906,6 @@ static const SaveVMHandlers savevm_vfio_handlers =3D { .load_setup =3D vfio_load_setup, .load_cleanup =3D vfio_load_cleanup, .load_state =3D vfio_load_state, - .switchover_ack_needed =3D vfio_switchover_ack_needed, /* * Multifd support */ diff --git a/migration/migration.c b/migration/migration.c index df8ed3a9fd..957b794e91 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2196,6 +2196,21 @@ void migration_rp_kick(MigrationState *s) qemu_sem_post(&s->rp_state.rp_sem); } =20 +/* This is called only on destination side */ +void migration_request_switchover_ack(const char *requester) +{ + MigrationIncomingState *mis =3D migration_incoming_get_current(); + + if (!migrate_switchover_ack()) { + return; + } + + mis->switchover_ack_pending_num++; + + trace_migration_request_switchover_ack(requester, + mis->switchover_ack_pending_num= ); +} + static struct rp_cmd_args { ssize_t len; /* -1 =3D variable */ const char *name; diff --git a/migration/savevm.c b/migration/savevm.c index fd870345b4..1a60a178af 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2798,23 +2798,6 @@ static int qemu_loadvm_state_header(QEMUFile *f, Err= or **errp) return 0; } =20 -static void qemu_loadvm_state_switchover_ack_needed(MigrationIncomingState= *mis) -{ - SaveStateEntry *se; - - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { - if (!se->ops || !se->ops->switchover_ack_needed) { - continue; - } - - if (se->ops->switchover_ack_needed(se->opaque)) { - mis->switchover_ack_pending_num++; - } - } - - trace_loadvm_state_switchover_ack_needed(mis->switchover_ack_pending_n= um); -} - static int qemu_loadvm_state_setup(QEMUFile *f, Error **errp) { ERRP_GUARD(); @@ -3076,10 +3059,6 @@ int qemu_loadvm_state(QEMUFile *f, Error **errp) return -EINVAL; } =20 - if (migrate_switchover_ack()) { - qemu_loadvm_state_switchover_ack_needed(mis); - } - cpu_synchronize_all_pre_loadvm(); =20 ret =3D qemu_loadvm_state_main(f, mis, errp); diff --git a/migration/trace-events b/migration/trace-events index c0c433744c..5955befcc6 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -8,7 +8,6 @@ qemu_loadvm_state_post_main(int ret) "%d" qemu_loadvm_state_section_startfull(uint32_t section_id, const char *idstr= , uint32_t instance_id, uint32_t version_id) "%u(%s) %u %u" qemu_savevm_send_packaged(void) "" qemu_savevm_query_pending(bool exact, bool final, uint64_t precopy, uint64= _t stopcopy, uint64_t postcopy, uint64_t total) "exact=3D%d, final=3D%d, pr= ecopy=3D%"PRIu64", stopcopy=3D%"PRIu64", postcopy=3D%"PRIu64", total=3D%"PR= Iu64 -loadvm_state_switchover_ack_needed(unsigned int switchover_ack_pending_num= ) "Switchover ack pending num=3D%u" loadvm_state_setup(void) "" loadvm_state_cleanup(void) "" loadvm_handle_cmd_packaged(unsigned int length) "%u" @@ -199,6 +198,7 @@ process_incoming_migration_co_postcopy_end_main(void) "" postcopy_preempt_enabled(bool value) "%d" migration_precopy_complete(void) "" migration_call_notifiers(int type) "type=3D%d" +migration_request_switchover_ack(const char *requester, unsigned int switc= hover_ack_pending_num) "Requester %s, switchover_ack_pending_num %u" =20 # migration-stats migration_transferred_bytes(uint64_t qemu_file, uint64_t multifd, uint64_t= rdma) "qemu_file %" PRIu64 " multifd %" PRIu64 " RDMA %" PRIu64 --=20 2.40.1 From nobody Mon Jun 8 03:21:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1780392499; cv=pass; d=zohomail.com; s=zohoarc; b=nwj10/5AuZAcwN+q3v3DzARyl6MMWAY4OJV/5mn9vHcuKRp/ONPSmx341dwwfLTWZeq0td6YKNHFDIDcfxFUAc7vGTQMe0m9wktIm1CPzZhNy6m7tgWqlwsUdvd3Q6hWvTSSACctbAM8G5TX8VhtbgD+dSc61Ym7+k6VbXIOfBg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780392499; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ull8TSdOFwKcT+HUNpTMGxzloo9jfN+iC2D5GrNwHyw=; b=DfEAJquCYPE86cg0VTWlAR49QNCj8RETFXOuhWCyMzkQewOpz5/4HLPiDrofAnMsALWOhbMYtikfhsTd/lkjtPTCb8nHTiTMx0ScFvpxp4Itr3rF7IwGoS75gGfs9FmEn6uyxXMnH/vre6JOhQx1htWTxmT9hEwFRfqGbEZ3Vgk= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178039249930795.99679086895355; Tue, 2 Jun 2026 02:28:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wULPD-0005tU-Qi; Tue, 02 Jun 2026 05:27:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULPC-0005tM-34 for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:27:26 -0400 Received: from mail-westcentralusazlp170100005.outbound.protection.outlook.com ([2a01:111:f403:c112::5] helo=CY7PR03CU001.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULP9-00047G-Ty for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:27:25 -0400 Received: from CY5PR22CA0062.namprd22.prod.outlook.com (2603:10b6:930:80::7) by CY3PR12MB9631.namprd12.prod.outlook.com (2603:10b6:930:ff::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.17; Tue, 2 Jun 2026 09:27:15 +0000 Received: from CH2PEPF00000141.namprd02.prod.outlook.com (2603:10b6:930:80:cafe::40) by CY5PR22CA0062.outlook.office365.com (2603:10b6:930:80::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.92.7 via Frontend Transport; Tue, 2 Jun 2026 09:27:15 +0000 Received: from mail.nvidia.com (216.228.117.160) by CH2PEPF00000141.mail.protection.outlook.com (10.167.244.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.5 via Frontend Transport; Tue, 2 Jun 2026 09:27:15 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:27:01 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:27:00 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Tue, 2 Jun 2026 02:26:54 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YjdLSTc9oHBQSS/as4Nx6M9YA5lLVZjn/Ckrke+uaD6C+1F00DNIJ7cv47giSnpCG6SJBHMOQ9XEDWnE79hz+KXURtXsgJiDCGF/QtNMedFNrF10rxGaZ1MBPTrzcGpKG9R7qz5UbTk9vHjboAgBW3eJYywwj00Idk2PRIofol9WdeiQ7/VtV/ZhPwhLtoUKPCe3RW6cC+gH9GOvSqYGeFL4WkPmwvE3JVlK9X1joRI1kj7PqW5aSLjVJgJuZ7+PbakD2GxV2GJJMp+U4TLKyv4d7Zm1dlgusxqbSkVKn2Y7Qz5sIVCNmCz9STqE19C075YD5yAAHF8mkGqFtTAxPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ull8TSdOFwKcT+HUNpTMGxzloo9jfN+iC2D5GrNwHyw=; b=OtrjnffcqVe2Y80sNM8zgUFKP8PEzC59eGexlfyxGcUNguTUWy2ugTIfLUAleUvz5kDB3l4tNt3AmfR3Nwrt8Ekj775QQeRUdjpD5f2qAy17V/k3SRYfEpl65IJOviCgIdq5w7Jg5NUyXK1AuRKpjF53KH5SH7pREig1Rd5XFJQihH9njm7eMU6Et1HKWDhtIrpq5T77XJISg/wFeoy80Lu+3XO2KJVLC1ho7FM5VzVjHQKcgKdGTLdWlhPevOPwUJNWOMHzJhIXQPLUZPW843Nl0KA4mBUPb2c8sWuuBsl43gwbXLqgf3i0NDAkpbbuC/p8i2fx3oVohzyn1iiB3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ull8TSdOFwKcT+HUNpTMGxzloo9jfN+iC2D5GrNwHyw=; b=HO4cLQJKbsM4O1ulh84FrLpVSFHRqDvr5+HautSIigabmw81Kmej42ZLIDE4g52tWGtAC6nH2dyDX+f1fsFPXYsIzsdeXsaJ1gnd71sd3hCjRB95XTkLxyOe45jLhjkV8USHW1oPLGjj9e1Bz469HWnCo/H74jIVGzGasPV7w06+NbVxVXLRKYHfe4d0KRiM54gtiyf8mSUCm7kRQQxXel3xlbMPHgcN39uoMSL0pVNpMGVv1bWuyk4cI/wr624a54ShV3jPXRUaE7iahvYE7+KYvlYY7sv1rn/57uSDBOFXxgbkHHJoA1xSiI/GyBNHG55zEMFRxxYxSHZG45m5WQ== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; 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=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Xu , Fabiano Rosas , Pierrick Bouvier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhao Liu , Halil Pasic , "Christian Borntraeger" , Jason Herne , Richard Henderson , Ilya Leoshkevich , David Hildenbrand , Eric Farman , Matthew Rosato , "Cornelia Huck" , Eric Blake , "Vladimir Sementsov-Ogievskiy" , John Snow , Markus Armbruster , Maor Gottlieb , Avihai Horon Subject: [PATCH v2 05/13] migration: Rename switchover-ack code to legacy Date: Tue, 2 Jun 2026 12:26:13 +0300 Message-ID: <20260602092621.382-6-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20260602092621.382-1-avihaih@nvidia.com> References: <20260602092621.382-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000141:EE_|CY3PR12MB9631:EE_ X-MS-Office365-Filtering-Correlation-Id: f81c1fdf-f28a-49d9-7a70-08dec0892269 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|7416014|36860700016|1800799024|376014|18002099003|22082099003|56012099006|11063799006; X-Microsoft-Antispam-Message-Info: IZvE9+sGmi0vI5+aRkyQ5FmTGVNbp2Mpr3syMOcxK1LyqUM/alJLbnASXDRJPks35lBZTFQacEFA+mmjiV9PaZdS6zxSw+6+NPqhhN3AgMsBJAm1WIKAMomZvsv7+ePI4mG8cua34DgmZGRs+jzfN+yOuDMwPTBJd40+vr91UYqfRGgKTym7bXteGd5JbaTuuv6pTwSogzKJRj6kYjPpJdGQW1jQkic9/8jYQhX9NedTmTW7EOML16+7RUOXO2DdMqJYX/65QleVdN8fm9+mvnu4qOzxRhYBjdUfaFLIjY3YsqOyVTb0tatyxIlGqAGPe3IRTAjRg7kM/uzFyObYtOJvNlCmxc0HGpkMe4tuzccboGrSOKkOWtBEHJeEHcfqk1vymGVY5OqfjraiddZew0IyRulf0Wv56s36vQc9INkb+AgOmUUGVyQ2ce41UOT6jaYx8fTCpJUfPePxpaPCPustu/X0+0fyuHCdCnNGWp5TUTFtkgFqpiJKJehJLmvq2LM4T4SO3hzpaGr9g/OqwR2tiUHJI78bEEYLKW/ULaRO7ao4Fo8oyOBrCbxyzHlIwYUuUfotysNI+XTO5/PkqGBIFl4cqEITRoxvoOYl7KQ5HBPtDnUCKXfvGeomm2T6yo8p0BNqb4KM8G44odmX43zLB122mvLaZQRvSPxpuYSJzruXi3k1XPEVwC9zWVs9byARGMcajegZkzzjm08ndUbzJSRnfjMK0dnlE3c4iv8= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(82310400026)(7416014)(36860700016)(1800799024)(376014)(18002099003)(22082099003)(56012099006)(11063799006); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uFQMFW49Z9SjKzUUxdvTCagE2JX1xYO43Ab+v6JwkfkXmoy897t5bRF2N5MYw45/GOfFQ3b7lV+GJX/5uXcB6duGpSCunC0NMtre/52GWeGpEsolIFaFsLRqwggf8ZqliZYK2q6DPq08MILSQBvIRvgQekPVAU92hYQYOZt2FArcqFZZFMfP9j2qam8uzs9/JE/V4+/IZuazhHi/AJXBJPsOxWqPh0PYcxLuYNFrllhfsMwMsHi/jZtbDVWOrts2qB8AO7gXLAF92enCg9MT8XHklO/WAwtca2AYBf22NgFLrvNNL1i7eSX4rFqozz+Y+5ZW0bcDmtk0cNclXeoB+aad5xOyHxZibnaX05DvvafBrFksy6ceGd9HUN8n/qCnUrdQBhnEplycER2tA/32ozY05UJCiIIFjzsUunBxToY1ZQVMTwsB0tfkKYD4SFEB X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2026 09:27:15.1927 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f81c1fdf-f28a-49d9-7a70-08dec0892269 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF00000141.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY3PR12MB9631 Received-SPF: permerror client-ip=2a01:111:f403:c112::5; envelope-from=avihaih@nvidia.com; helo=CY7PR03CU001.outbound.protection.outlook.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FORGED_SPF_HELO=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1780392502250154100 Content-Type: text/plain; charset="utf-8" A new switchover-ack mechanism will be added in the following patches. However, the old mechanism must still be kept for backward compatibility. Rename existing code that will be used only for old switchover-ack mechanism as legacy. This will help to distinguish legacy code from new code and make it more readable and easier for removal later when no longer needed. No functional change intended. Signed-off-by: Avihai Horon Reviewed-by: Peter Xu --- include/migration/misc.h | 2 +- migration/migration.h | 2 +- hw/vfio/migration.c | 6 ++--- migration/migration.c | 8 +++---- migration/savevm.c | 49 +++++++++++++++++++++++++++------------- migration/trace-events | 4 ++-- 6 files changed, 44 insertions(+), 27 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index a2219c981b..4b43413aee 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -156,6 +156,6 @@ bool multifd_device_state_save_thread_should_exit(void); void multifd_abort_device_state_save_threads(void); bool multifd_join_device_state_save_threads(void); =20 -void migration_request_switchover_ack(const char *requester); +void migration_request_switchover_ack_legacy(const char *requester); =20 #endif diff --git a/migration/migration.h b/migration/migration.h index 841f49b215..da45444f7b 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -246,7 +246,7 @@ struct MigrationIncomingState { * zero an ACK that it's OK to do switchover is sent to the source. No= lock * is needed as this field is updated serially. */ - unsigned int switchover_ack_pending_num; + unsigned int switchover_ack_pending_num_legacy; =20 /* Do exit on incoming migration failure */ bool exit_on_error; diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 6303f006a2..d5be135584 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -487,11 +487,11 @@ static bool vfio_precopy_supported(VFIODevice *vbased= ev) return migration->mig_flags & VFIO_MIGRATION_PRE_COPY; } =20 -static void vfio_request_switchover_ack(VFIODevice *vbasedev) +static void vfio_request_switchover_ack_legacy(VFIODevice *vbasedev) { if (vfio_precopy_supported(vbasedev)) { /* Precopy support implies switchover-ack is needed */ - migration_request_switchover_ack(vbasedev->name); + migration_request_switchover_ack_legacy(vbasedev->name); } } =20 @@ -783,7 +783,7 @@ static int vfio_load_setup(QEMUFile *f, void *opaque, E= rror **errp) return ret; } =20 - vfio_request_switchover_ack(vbasedev); + vfio_request_switchover_ack_legacy(vbasedev); =20 return 0; } diff --git a/migration/migration.c b/migration/migration.c index 957b794e91..59aff50d68 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2197,7 +2197,7 @@ void migration_rp_kick(MigrationState *s) } =20 /* This is called only on destination side */ -void migration_request_switchover_ack(const char *requester) +void migration_request_switchover_ack_legacy(const char *requester) { MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 @@ -2205,10 +2205,10 @@ void migration_request_switchover_ack(const char *r= equester) return; } =20 - mis->switchover_ack_pending_num++; + mis->switchover_ack_pending_num_legacy++; =20 - trace_migration_request_switchover_ack(requester, - mis->switchover_ack_pending_num= ); + trace_migration_request_switchover_ack_legacy( + requester, mis->switchover_ack_pending_num_legacy); } =20 static struct rp_cmd_args { diff --git a/migration/savevm.c b/migration/savevm.c index 1a60a178af..fa188dd34f 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2476,6 +2476,31 @@ static int loadvm_postcopy_handle_switchover_start(E= rror **errp) return 0; } =20 +/* + * If legacy switchover-ack is enabled but no device uses it, need to send= an + * ACK to source that it's OK to switchover. + */ +static int loadvm_switchover_ack_no_users_legacy(MigrationIncomingState *m= is, + Error **errp) +{ + int ret; + + if (!migrate_switchover_ack()) { + return 0; + } + + if (!mis->switchover_ack_pending_num_legacy) { + ret =3D migrate_send_rp_switchover_ack(mis); + if (ret) { + error_setg_errno(errp, -ret, + "Could not send switchover ack RP MSG"); + return ret; + } + } + + return 0; +} + /* * Process an incoming 'QEMU_VM_COMMAND' * 0 just a normal return @@ -2525,18 +2550,9 @@ static int loadvm_process_command(QEMUFile *f, Error= **errp) } mis->to_src_file =3D qemu_file_get_return_path(f); =20 - /* - * Switchover ack is enabled but no device uses it, so send an ACK= to - * source that it's OK to switchover. Do it here, after return pat= h has - * been created. - */ - if (migrate_switchover_ack() && !mis->switchover_ack_pending_num) { - ret =3D migrate_send_rp_switchover_ack(mis); - if (ret) { - error_setg_errno(errp, -ret, - "Could not send switchover ack RP MSG"); - return ret; - } + ret =3D loadvm_switchover_ack_no_users_legacy(mis, errp); + if (ret) { + return ret; } return 0; =20 @@ -3155,14 +3171,15 @@ int qemu_loadvm_approve_switchover(const char *appr= over) { MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 - if (!mis->switchover_ack_pending_num) { + if (!mis->switchover_ack_pending_num_legacy) { return -EINVAL; } =20 - mis->switchover_ack_pending_num--; - trace_loadvm_approve_switchover(approver, mis->switchover_ack_pending_= num); + mis->switchover_ack_pending_num_legacy--; + trace_loadvm_approve_switchover_legacy( + approver, mis->switchover_ack_pending_num_legacy); =20 - if (mis->switchover_ack_pending_num) { + if (mis->switchover_ack_pending_num_legacy) { return 0; } =20 diff --git a/migration/trace-events b/migration/trace-events index 5955befcc6..a6b8c31ee1 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -23,7 +23,7 @@ loadvm_postcopy_ram_handle_discard_end(void) "" loadvm_postcopy_ram_handle_discard_header(const char *ramid, uint16_t len)= "%s: %ud" loadvm_process_command(const char *s, uint16_t len) "com=3D%s len=3D%d" loadvm_process_command_ping(uint32_t val) "0x%x" -loadvm_approve_switchover(const char *approver, unsigned int switchover_ac= k_pending_num) "Approver %s, switchover_ack_pending_num %u" +loadvm_approve_switchover_legacy(const char *approver, unsigned int switch= over_ack_pending_num_legacy) "Approver %s, switchover_ack_pending_num_legac= y %u" postcopy_ram_listen_thread_exit(void) "" postcopy_ram_listen_thread_start(void) "" qemu_savevm_send_postcopy_advise(void) "" @@ -198,7 +198,7 @@ process_incoming_migration_co_postcopy_end_main(void) "" postcopy_preempt_enabled(bool value) "%d" migration_precopy_complete(void) "" migration_call_notifiers(int type) "type=3D%d" -migration_request_switchover_ack(const char *requester, unsigned int switc= hover_ack_pending_num) "Requester %s, switchover_ack_pending_num %u" +migration_request_switchover_ack_legacy(const char *requester, unsigned in= t switchover_ack_pending_num_legacy) "Requester %s, switchover_ack_pending_= num_legacy %u" =20 # migration-stats migration_transferred_bytes(uint64_t qemu_file, uint64_t multifd, uint64_t= rdma) "qemu_file %" PRIu64 " multifd %" PRIu64 " RDMA %" PRIu64 --=20 2.40.1 From nobody Mon Jun 8 03:21:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1780392534; cv=pass; d=zohomail.com; s=zohoarc; b=EiTcO76PIfFqZ52oO/V4oPbKavORijb/CVLhc0xIKNwVGZeAxZjLX2EYRSPMpqZAOoJLNhqJROeRfvLhiszHwS5/oj1Gsuq2fT+g9eIb6BYAwSbbRDeUhmX2SeRZbADKfnDTx2eegO/+G8Vf32qMYMYwmQHWRtSHrRQyzAoOBrE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780392534; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jR0UMGIf6yxtp6XQcoIbYZ5eIpS3wafZSUGlyZ/H0VA=; b=m7MblZRjI0bq/AA3eejcwgt0A9XF5kC476JLnCWPg73DqhsVACgMQVXih9GNAh43SLCFJhamXP/yLN3+5WUdFK9z7YPc6v22B+EtYXhL+jX5NZf7xDCojoXk70J7DJXvUATZV2Cqrm4dbC13lH3p8n1MmN6z0B84Fxt8HEd3py8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780392534952277.2758543830697; Tue, 2 Jun 2026 02:28:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wULPR-000615-Si; Tue, 02 Jun 2026 05:27:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULPO-0005y0-5a for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:27:38 -0400 Received: from mail-centralusazlp170110009.outbound.protection.outlook.com ([2a01:111:f403:c111::9] helo=DM5PR21CU001.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULPL-0004CT-FD for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:27:37 -0400 Received: from CH2PR05CA0064.namprd05.prod.outlook.com (2603:10b6:610:38::41) by BY5PR12MB4243.namprd12.prod.outlook.com (2603:10b6:a03:20f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.71.16; Tue, 2 Jun 2026 09:27:27 +0000 Received: from CH2PEPF0000013B.namprd02.prod.outlook.com (2603:10b6:610:38:cafe::67) by CH2PR05CA0064.outlook.office365.com (2603:10b6:610:38::41) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.92.7 via Frontend Transport; Tue, 2 Jun 2026 09:27:26 +0000 Received: from mail.nvidia.com (216.228.117.160) by CH2PEPF0000013B.mail.protection.outlook.com (10.167.244.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.5 via Frontend Transport; Tue, 2 Jun 2026 09:27:26 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:27:07 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:27:07 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Tue, 2 Jun 2026 02:27:01 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=x2in8N/fg7CIb3PFfkPqeewjfPcADruvYiamCnIwR7+gVxyXnW4ibON1O+eJciPGQqdE+w3CbePPIyXn/qUaD/uJ568FaISweZZe4Nc94q44mq9/DFx4fBb4n6WmP/9zLUC+nr+HEl+TOyk50HXClz3PgzeWcdC2SnwaG0VjZpMeZ5CB90iSvBFbVBg9FXcRkobBWRLqYjwDlfXFy35SkhIyWWC0ew9WoVVABndO39WFZaaupWqRwhRwUSHMh5Z9TvW/MEP3aaD6PFBi+f9Y7jiwJWDozu4RmwzJ6hecqvwXU8N5WgfzcjfIm0B47fKguiCpiKMjLtH/a5TCJS27BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jR0UMGIf6yxtp6XQcoIbYZ5eIpS3wafZSUGlyZ/H0VA=; b=MRK0FHA+8KS5ZdMcm/dVe+oKTMDIr+Zr8xy5NA+lqvKOIEK8j/Eng+WtQFZT9q+8njWn8/T5g115iZ9hZa2uRL8lAZo65XLw9yTatXY4RR0tU6grmm29jdscfC+/YI1lnlQDXLAzsMfNi15pnMt0WJw3e0e4wzMGvO3RRMzWRxb+IGyur1hSIU5yTpIHw5CM/QISSS9Mgm+DwfEpWCoKiRanMqzSXPTVYUEm25fMG9YOjDVzZQhD096BRZ73PJGv8ToxfrXA+Ae2qAUtOIqC3I+LG6g/AcncWqcMOPJnEnzAtcmcM8eewZYzFrk+bRapAi4y0MgnI2/mZtW2Nfs4Yw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jR0UMGIf6yxtp6XQcoIbYZ5eIpS3wafZSUGlyZ/H0VA=; b=Gv+m7DOTpphHrZQvH71BFosPB6DbEHMSZi/jsexU8nzwcxMvOd4QBTKZ3VKOM3hgUTpTpHS7IQWT1lrYEw/1OkBYnEU+EzIsfzAd5OSSOCLp5f2mi7k7LEWTLZtOi2oQ6et9WuyqDN8Hlzw3NoADxL+aVQiWu8K3mIYINGQSbevP4d+hwsOTfl5J72eoGckCiCuzLjklZc/GcnPIP3mhgkD+iFBRWlE1lGlweuniIP11CVq8MFmBnAbgRLSjgoAOV+1gYLJ22PGHToyVII1f4QUzvcbQcpGk6iQUGXz1KteLIU1XoWaT4zxaKnpncWjuhpesne/ATEh4EApYV0k+mQ== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; 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=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Xu , Fabiano Rosas , Pierrick Bouvier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhao Liu , Halil Pasic , "Christian Borntraeger" , Jason Herne , Richard Henderson , Ilya Leoshkevich , David Hildenbrand , Eric Farman , Matthew Rosato , "Cornelia Huck" , Eric Blake , "Vladimir Sementsov-Ogievskiy" , John Snow , Markus Armbruster , Maor Gottlieb , Avihai Horon Subject: [PATCH v2 06/13] migration: Make switchover-ack re-usable Date: Tue, 2 Jun 2026 12:26:14 +0300 Message-ID: <20260602092621.382-7-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20260602092621.382-1-avihaih@nvidia.com> References: <20260602092621.382-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF0000013B:EE_|BY5PR12MB4243:EE_ X-MS-Office365-Filtering-Correlation-Id: 60a8e8b8-9fbb-4d69-a9b7-08dec089292d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|1800799024|36860700016|82310400026|11063799006|56012099006|6133799003|18002099003|3023799007|22082099003; X-Microsoft-Antispam-Message-Info: dsMYHVga2a0gqkYSxBoClxEq2V9vnMI6yfi/ShdizQZ2ehAxjI5Tjtu+xRqq3j+03paaB4w06fUekyj/khvIu7u4xkR8XMN2k9nsLcGTCINtUhOM+PcnmCFWqm31hsuvag3AwsEkKgu4XCHvx0byPdsbI07ufM2n/vJicpHB7xtmS8x9OJ7QJw1mFlKhZSqQzqUlW0SRVLxOks//sCbGGsQwVgCmg6MdlrYMG9cRWL0ue4qsNMu1zsS6E+1EGqhHdbazL2OXglmGml9HdyNGMt7CHWOjSLA2A4B/g4kZpN2sYgxJP5roa18l+K6WxuVgq/MfOxxQlAwARym+klknPJnAV+AUwnUjFpyw/6g3tSbN8cJWIe9Sz9/yTKkPPekrgRo/XsYQlF/zB5uWuJwbGwWC0AJel24rjBqx6iQe6hk0sdrf/AQDhaVqoRIv68CHyZt09/NE+9NlmcrfVsXaZuVZ/nf7Lm9Inz/mKqZoxmFi6k1OmPJIP4wG2X4h7vO67Qp7OLUXzHS+oFy2AlfnWMDBC2I3vRUDlfR5mLJDqjZluN3ikZyEY8jKW+NEM3Nd/Bqb1HNBxYLA0M2BvssZV3zhX4UitKjJ3l+2nmOgCb+OZ1U5znvo/MHmvJ5ibpI0JwysQKR2yYjDMWtzfqDDQNjDqZ2ZSZTqgZP2Kr1kgJWz7iZsIF1nBEoGrNcHjVe89HhjjXm1d6PVyfVqTysgQ+TIWwCg1JvgsIC40GRu+Yg= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(36860700016)(82310400026)(11063799006)(56012099006)(6133799003)(18002099003)(3023799007)(22082099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: L0TjuCMcFP5Z0TwCGPcbbP+2g/R0xxj7fbj6mPyRj30rCgfkx3SdBUDGtlRNKzFVdut9Da75ja62G7pOx0EwoqGcTAfuBOvkAJn5BB4iVY/H2WzNc93+dsrjwJvMGCjGaCXf43lgI63FYKpUNWqM+6RCw6k4zIjJ92bbnt0w8mIxjYpETpZxz7JLUgPWPM8FXTuAEDU5vkh77DE9UwkEB9u74DW7qhedAYw/YuYXwG8HT4JtDxhH4L1hIV8mXbNDpLs5fGjP5FslU/fuxRgXGD9lekw48GLx76n8zL2+zBVXgosJKCxH10sA3KG/z275wcScUGcrMInxaxHfedGc4k1FtOFjxCGDStfQ409qyLc3Mffw21HejIIi9JAmJOJHuKlRt4IJFXZL5UYEoxnMObLGDemozJZ+AFvTSisKtszU2wnOdw9q6qbdJAJykqys X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2026 09:27:26.5554 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 60a8e8b8-9fbb-4d69-a9b7-08dec089292d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF0000013B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4243 Received-SPF: permerror client-ip=2a01:111:f403:c111::9; envelope-from=avihaih@nvidia.com; helo=DM5PR21CU001.outbound.protection.outlook.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FORGED_SPF_HELO=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1780392535632158500 Content-Type: text/plain; charset="utf-8" Switchover-ack is a mechanism to synchronize between source and destination QEMU during migration to prevent the source from switching over prematurely. VFIO uses switchover-ack to ensure switchover happens only after destination side has loaded the precopy initial bytes. This is important for VFIO, as otherwise downtime could be impacted and be higher. In its current state, switchover-ack is a one-time mechanism, meaning that switchover is acked only once and past that another ACK cannot be requested again. This was sufficient until now, as VFIO precopy initial bytes was defined to be monotonically decreasing. Thus, when precopy initial bytes reached zero for all VFIO devices, a single ACK would be sent and its validity would hold. However, now the new VFIO_PRECOPY_INFO_REINIT feature allows precopy initial bytes to be re-initialized during precopy. Specifically, it means that initial bytes can grow after reaching zero, which would invalidate a previously sent switchover ACK. To solve this, make switchover-ack reusable and allow devices to request switchover ACKs when needed via the save_query_pending SaveVMHandler. Since now switchover ACK can be requested for a specific device and in different times, make switchover ACK per-device (instead of a single ACK for all devices) and let source side do the pending ACKs accounting. Keep the legacy switchover-ack mechanism for backward compatibility and turn it on by a compatibility property for older machines. Enable the property until VFIO implements the new switchover-ack. Signed-off-by: Avihai Horon --- qapi/migration.json | 16 ++++----- include/migration/client-options.h | 1 + include/migration/register.h | 2 ++ migration/migration.h | 32 ++++++++++++++++-- migration/savevm.h | 6 ++-- hw/core/machine.c | 1 + migration/migration.c | 37 ++++++++++++++------- migration/options.c | 10 ++++++ migration/savevm.c | 53 +++++++++++++++++++++++------- migration/trace-events | 5 +-- 10 files changed, 125 insertions(+), 38 deletions(-) diff --git a/qapi/migration.json b/qapi/migration.json index 27a7970556..550cb77762 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -507,15 +507,13 @@ # and should not affect the correctness of postcopy migration. # (since 7.1) # -# @switchover-ack: If enabled, migration will not stop the source VM -# and complete the migration until an ACK is received from the -# destination that it's OK to do so. Exactly when this ACK is -# sent depends on the migrated devices that use this feature. For -# example, a device can use it to make sure some of its data is -# sent and loaded in the destination before doing switchover. -# This can reduce downtime if devices that support this capability -# are present. 'return-path' capability must be enabled to use -# it. (since 8.1) +# @switchover-ack: If enabled, migration will rely on destination side +# to acknowledge the source's switchover decision. The +# acknowledgement may depend, for example, on some device's data +# being loaded in the destination before doing switchover. This +# can reduce downtime if devices that support this capability are +# present. 'return-path' capability must be enabled to use it. +# (since 8.1) # # @dirty-limit: If enabled, migration will throttle vCPUs as needed to # keep their dirty page rate within @vcpu-dirty-limit. This can diff --git a/include/migration/client-options.h b/include/migration/client-= options.h index 289c9d7762..78b1daa1a6 100644 --- a/include/migration/client-options.h +++ b/include/migration/client-options.h @@ -13,6 +13,7 @@ =20 /* properties */ bool migrate_send_switchover_start(void); +bool migrate_switchover_ack_legacy(void); =20 /* capabilities */ =20 diff --git a/include/migration/register.h b/include/migration/register.h index a61c4236d2..5825eb30cb 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -23,6 +23,8 @@ typedef struct MigPendingData { uint64_t postcopy_bytes; /* Amount of pending bytes can be transferred only in stopcopy */ uint64_t stopcopy_bytes; + /* Number of new pending switchover ACKs */ + uint32_t switchover_ack_pending; /* * Total pending data, modules do not need to update this field, it * will be automatically calculated by migration core API. diff --git a/migration/migration.h b/migration/migration.h index da45444f7b..086eb9a15d 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -494,6 +494,29 @@ struct MigrationState { */ uint8_t clear_bitmap_shift; =20 + /* + * This decides whether to use legacy switchover-ack or new switchover= -ack. + * The main difference between them is that the former allows acknowle= dging + * switchover only once while the latter multiple times. + * + * In legacy, the destination keeps track of a pending ACKs counter. As + * migration progresses, the devices on the destination acknowledge + * switchover, decreasing the counter. When the counter reaches zero, a + * single ACK message is sent to the source via the return path, indic= ating + * that it's OK to switchover. + * + * In new switchover-ack, the source is the one that keeps track of a + * pending ACKs counter. As migration progresses, the destination send= s ACK + * message per-device via the return path, which decrements the source + * counter. When the counter reaches zero, it's OK to switchover. Duri= ng + * precopy, source-side devices may request additional ACKs, which inc= rement + * the counter again. + * + * In both legacy and new schemes, we rely on per-device protocol to r= equest + * switchover ACK from the destination-side counterpart. + */ + bool switchover_ack_legacy; + /* * This save hostname when out-going migration starts */ @@ -503,10 +526,13 @@ struct MigrationState { JSONWriter *vmdesc; =20 /* - * Indicates whether an ACK from the destination that it's OK to do - * switchover has been received. + * Indicates the number of pending ACKs from the destination. The valu= e may + * increase or decrease during precopy as new ACKs are requested or + * received. When zero is reached, it's OK to switchover. In legacy + * switchover-ack, it's initialized to 1 and decreased to zero upon AC= K. */ - bool switchover_acked; + uint32_t switchover_ack_pending_num; + /* Is this a rdma migration */ bool rdma_migration; =20 diff --git a/migration/savevm.h b/migration/savevm.h index 0d732eb0f7..a049d695c9 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -45,8 +45,10 @@ int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy= ); void qemu_savevm_state_cleanup(void); void qemu_savevm_state_complete_postcopy(QEMUFile *f); int qemu_savevm_state_complete_precopy(MigrationState *s); -void qemu_savevm_query_pending_iter(MigPendingData *pending, bool exact); -void qemu_savevm_query_pending_final(MigPendingData *pending); +void qemu_savevm_query_pending_iter(MigrationState *s, MigPendingData *pen= ding, + bool exact); +void qemu_savevm_query_pending_final(MigrationState *s, + MigPendingData *pending); int qemu_savevm_state_complete_precopy_iterable(QEMUFile *f, bool in_postc= opy); bool qemu_savevm_state_postcopy_prepare(QEMUFile *f, Error **errp); void qemu_savevm_state_end(QEMUFile *f); diff --git a/hw/core/machine.c b/hw/core/machine.c index 63baff859f..8a39943d94 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -41,6 +41,7 @@ =20 GlobalProperty hw_compat_11_0[] =3D { { "chardev-vc", "encoding", "cp437" }, + { "migration", "switchover-ack-legacy", "on" }, }; const size_t hw_compat_11_0_len =3D G_N_ELEMENTS(hw_compat_11_0); =20 diff --git a/migration/migration.c b/migration/migration.c index 59aff50d68..4bb649a467 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1707,7 +1707,9 @@ int migrate_init(MigrationState *s, Error **errp) s->vm_old_state =3D -1; s->iteration_initial_bytes =3D 0; s->threshold_size =3D 0; - s->switchover_acked =3D false; + /* Legacy switchover-ack sends a single ACK for all devices */ + qatomic_set(&s->switchover_ack_pending_num, + migrate_switchover_ack_legacy() ? 1 : 0); s->rdma_migration =3D false; =20 /* @@ -2201,7 +2203,7 @@ void migration_request_switchover_ack_legacy(const ch= ar *requester) { MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 - if (!migrate_switchover_ack()) { + if (!migrate_switchover_ack() || !migrate_switchover_ack_legacy()) { return; } =20 @@ -2457,9 +2459,18 @@ static void *source_return_path_thread(void *opaque) break; =20 case MIG_RP_MSG_SWITCHOVER_ACK: - ms->switchover_acked =3D true; - trace_source_return_path_thread_switchover_acked(); + { + uint32_t pending_num; + + pending_num =3D qatomic_dec_fetch(&ms->switchover_ack_pending_= num); + trace_source_return_path_thread_switchover_acked(pending_num); + if (pending_num =3D=3D UINT32_MAX) { + error_setg(&err, "Switchover ack pending num underflowed"); + goto out; + } + break; + } =20 default: break; @@ -2809,7 +2820,7 @@ static bool migration_switchover_start(MigrationState= *s, Error **errp) return false; } =20 - qemu_savevm_query_pending_final(&pending); + qemu_savevm_query_pending_final(s, &pending); =20 /* Inactivate disks except in COLO */ if (!migrate_colo()) { @@ -3259,7 +3270,7 @@ static bool migration_can_switchover(MigrationState *= s) return true; } =20 - return s->switchover_acked; + return qatomic_read(&s->switchover_ack_pending_num) =3D=3D 0; } =20 /* Migration thread iteration status */ @@ -3298,12 +3309,13 @@ static bool migration_iteration_next_ready(Migratio= nState *s, return false; } =20 -static void migration_iteration_go_next(MigPendingData *pending) +static void migration_iteration_go_next(MigrationState *s, + MigPendingData *pending) { /* * Do a slow sync first before boosting the iteration count. */ - qemu_savevm_query_pending_iter(pending, true); + qemu_savevm_query_pending_iter(s, pending, true); =20 /* * Update the dirty information for the whole system for this @@ -3349,12 +3361,12 @@ static MigIterateState migration_iteration_run(Migr= ationState *s) Error *local_err =3D NULL; bool in_postcopy =3D (s->state =3D=3D MIGRATION_STATUS_POSTCOPY_DEVICE= || s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE); - bool can_switchover =3D migration_can_switchover(s); + bool can_switchover; MigPendingData pending =3D { }; bool complete_ready; =20 /* Fast path - get the estimated amount of pending data */ - qemu_savevm_query_pending_iter(&pending, false); + qemu_savevm_query_pending_iter(s, &pending, false); =20 if (in_postcopy) { /* @@ -3395,9 +3407,12 @@ static MigIterateState migration_iteration_run(Migra= tionState *s) * during postcopy phase. */ if (migration_iteration_next_ready(s, &pending)) { - migration_iteration_go_next(&pending); + migration_iteration_go_next(s, &pending); } =20 + /* Check can switchover after qemu_savevm_query_pending() */ + can_switchover =3D migration_can_switchover(s); + /* Should we switch to postcopy now? */ if (can_switchover && postcopy_should_start(s, &pending)) { if (postcopy_start(s, &local_err)) { diff --git a/migration/options.c b/migration/options.c index 5cbfd29099..4c9b25372e 100644 --- a/migration/options.c +++ b/migration/options.c @@ -110,6 +110,9 @@ const Property migration_properties[] =3D { preempt_pre_7_2, false), DEFINE_PROP_BOOL("multifd-clean-tls-termination", MigrationState, multifd_clean_tls_termination, true), + /* Use legacy until VFIO implements new switchover-ack */ + DEFINE_PROP_BOOL("switchover-ack-legacy", MigrationState, + switchover_ack_legacy, true), =20 /* Migration parameters */ DEFINE_PROP_UINT8("x-throttle-trigger-threshold", MigrationState, @@ -467,6 +470,13 @@ bool migrate_rdma(void) return s->rdma_migration; } =20 +bool migrate_switchover_ack_legacy(void) +{ + MigrationState *s =3D migrate_get_current(); + + return s->switchover_ack_legacy; +} + typedef enum WriteTrackingSupport { WT_SUPPORT_UNKNOWN =3D 0, WT_SUPPORT_ABSENT, diff --git a/migration/savevm.c b/migration/savevm.c index fa188dd34f..0e487ea8ab 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1795,7 +1795,8 @@ int qemu_savevm_state_complete_precopy(MigrationState= *s) return qemu_fflush(f); } =20 -static void qemu_savevm_query_pending(MigPendingData *pending, bool exact, +static void qemu_savevm_query_pending(MigrationState *s, + MigPendingData *pending, bool exact, bool final) { SaveStateEntry *se; @@ -1824,22 +1825,35 @@ static void qemu_savevm_query_pending(MigPendingDat= a *pending, bool exact, if (!final) { mig_stats.dirty_bytes_total =3D pending->total_bytes; } - trace_qemu_savevm_query_pending(exact, final, pending->precopy_bytes, - pending->stopcopy_bytes, - pending->postcopy_bytes, - pending->total_bytes); + + if (migrate_switchover_ack() && !migrate_switchover_ack_legacy() && + pending->switchover_ack_pending) { + /* + * NOTE: Currently we rely on per-device protocol to request switc= hover + * ACK from the device on the destination side. + */ + qatomic_add(&s->switchover_ack_pending_num, + pending->switchover_ack_pending); + } + + trace_qemu_savevm_query_pending( + exact, final, pending->precopy_bytes, pending->stopcopy_bytes, + pending->postcopy_bytes, pending->total_bytes, + pending->switchover_ack_pending, + qatomic_read(&s->switchover_ack_pending_num)); } =20 -void qemu_savevm_query_pending_iter(MigPendingData *pending, bool exact) +void qemu_savevm_query_pending_iter(MigrationState *s, MigPendingData *pen= ding, + bool exact) { - qemu_savevm_query_pending(pending, exact, false); + qemu_savevm_query_pending(s, pending, exact, false); } =20 -void qemu_savevm_query_pending_final(MigPendingData *pending) +void qemu_savevm_query_pending_final(MigrationState *s, MigPendingData *pe= nding) { g_assert(bql_locked()); =20 - qemu_savevm_query_pending(pending, true, true); + qemu_savevm_query_pending(s, pending, true, true); } =20 void qemu_savevm_state_cleanup(void) @@ -2485,7 +2499,7 @@ static int loadvm_switchover_ack_no_users_legacy(Migr= ationIncomingState *mis, { int ret; =20 - if (!migrate_switchover_ack()) { + if (!migrate_switchover_ack() || !migrate_switchover_ack_legacy()) { return 0; } =20 @@ -3167,7 +3181,7 @@ int qemu_load_device_state(QEMUFile *f, Error **errp) return 0; } =20 -int qemu_loadvm_approve_switchover(const char *approver) +static int qemu_loadvm_approve_switchover_legacy(const char *approver) { MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 @@ -3186,6 +3200,23 @@ int qemu_loadvm_approve_switchover(const char *appro= ver) return migrate_send_rp_switchover_ack(mis); } =20 +int qemu_loadvm_approve_switchover(const char *approver) +{ + MigrationIncomingState *mis =3D migration_incoming_get_current(); + + if (!migrate_switchover_ack()) { + return 0; + } + + if (migrate_switchover_ack_legacy()) { + return qemu_loadvm_approve_switchover_legacy(approver); + } + + trace_loadvm_approve_switchover(approver); + + return migrate_send_rp_switchover_ack(mis); +} + bool qemu_loadvm_load_state_buffer(const char *idstr, uint32_t instance_id, char *buf, size_t len, Error **errp) { diff --git a/migration/trace-events b/migration/trace-events index a6b8c31ee1..f5339f4193 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -7,7 +7,7 @@ qemu_loadvm_state_section_partend(uint32_t section_id) "%u" qemu_loadvm_state_post_main(int ret) "%d" qemu_loadvm_state_section_startfull(uint32_t section_id, const char *idstr= , uint32_t instance_id, uint32_t version_id) "%u(%s) %u %u" qemu_savevm_send_packaged(void) "" -qemu_savevm_query_pending(bool exact, bool final, uint64_t precopy, uint64= _t stopcopy, uint64_t postcopy, uint64_t total) "exact=3D%d, final=3D%d, pr= ecopy=3D%"PRIu64", stopcopy=3D%"PRIu64", postcopy=3D%"PRIu64", total=3D%"PR= Iu64 +qemu_savevm_query_pending(bool exact, bool final, uint64_t precopy, uint64= _t stopcopy, uint64_t postcopy, uint64_t total, uint32_t switchover_ack_pen= ding, uint32_t total_switchover_ack_pending) "exact=3D%d, final=3D%d, preco= py=3D%"PRIu64", stopcopy=3D%"PRIu64", postcopy=3D%"PRIu64", total=3D%"PRIu6= 4", collected switchover ack pending=3D%"PRIu32", total switchover ack pend= ing=3D%"PRIu32 loadvm_state_setup(void) "" loadvm_state_cleanup(void) "" loadvm_handle_cmd_packaged(unsigned int length) "%u" @@ -24,6 +24,7 @@ loadvm_postcopy_ram_handle_discard_header(const char *ram= id, uint16_t len) "%s: loadvm_process_command(const char *s, uint16_t len) "com=3D%s len=3D%d" loadvm_process_command_ping(uint32_t val) "0x%x" loadvm_approve_switchover_legacy(const char *approver, unsigned int switch= over_ack_pending_num_legacy) "Approver %s, switchover_ack_pending_num_legac= y %u" +loadvm_approve_switchover(const char *approver) "Approver %s" postcopy_ram_listen_thread_exit(void) "" postcopy_ram_listen_thread_start(void) "" qemu_savevm_send_postcopy_advise(void) "" @@ -189,7 +190,7 @@ source_return_path_thread_loop_top(void) "" source_return_path_thread_pong(uint32_t val) "0x%x" source_return_path_thread_shut(uint32_t val) "0x%x" source_return_path_thread_resume_ack(uint32_t v) "%"PRIu32 -source_return_path_thread_switchover_acked(void) "" +source_return_path_thread_switchover_acked(uint32_t pending_num) "switchov= er_ack_pending_num %" PRIu32 source_return_path_thread_postcopy_package_loaded(void) "" migration_thread_low_pending(uint64_t pending) "%" PRIu64 migrate_transferred(uint64_t transferred, uint64_t time_spent, uint64_t ba= ndwidth, uint64_t avail_bw, uint64_t size) "transferred %" PRIu64 " time_sp= ent %" PRIu64 " bandwidth %" PRIu64 " switchover_bw %" PRIu64 " max_size %"= PRId64 --=20 2.40.1 From nobody Mon Jun 8 03:21:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1780392497; cv=pass; d=zohomail.com; s=zohoarc; b=bBOrIvHkQQD7+1nWo+hZTO0LgeeFY6klM0nvpQ20oj2IDhllAAvKLT01ddAaqxQ9obrlDhUonDZFP9MqTV9KDVwVcicL5ywRtLotRgum5fK6tf5KRO3RihOkGU1b0nkJNdbteqqP/8doqlRrbMQtl3fd7mthDvFEkOJjLruaXPM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780392497; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VHGeQLARS16YmZjWWLS7sne17Yf4GC8ShnGAmlbOKV0=; b=ZIfF8vxS/JOsDId6WMYq22sy6T3DJKyOMUc9pRScH5UFwasWic2Fh2yh+oT8aZRCypTxfnUGmP0Lg5qZJHAKUsrY/8XFFjYqT5JjRy4BYtD/KT+K1oww5ZCDglsjAejdjUBUKMp35xeemsmG96yWx2d+lVjU4YebHyxBZIsHZXI= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780392497589669.9991147961813; Tue, 2 Jun 2026 02:28:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wULPR-0005zw-3B; Tue, 02 Jun 2026 05:27:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULPM-0005ue-Tu for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:27:36 -0400 Received: from mail-eastus2azlp170100001.outbound.protection.outlook.com ([2a01:111:f403:c110::1] helo=BN1PR04CU002.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULPK-0004C1-Eo for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:27:36 -0400 Received: from SA0PR11CA0201.namprd11.prod.outlook.com (2603:10b6:806:1bc::26) by IA0PR12MB9012.namprd12.prod.outlook.com (2603:10b6:208:485::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.7; Tue, 2 Jun 2026 09:27:29 +0000 Received: from SN1PEPF0002636E.namprd02.prod.outlook.com (2603:10b6:806:1bc:cafe::82) by SA0PR11CA0201.outlook.office365.com (2603:10b6:806:1bc::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.71.16 via Frontend Transport; Tue, 2 Jun 2026 09:27:29 +0000 Received: from mail.nvidia.com (216.228.117.161) by SN1PEPF0002636E.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.5 via Frontend Transport; Tue, 2 Jun 2026 09:27:29 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:27:14 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:27:13 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Tue, 2 Jun 2026 02:27:07 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PvjiGuzFM8fld5znWyiE16nGw3owFbiyM0opvOZqlqOVzNnDCYXUR8pKWUssnvf8VIPpoeBuvwZaLST0TvOs8O8hXpgCZvPfD+Tv82+Dclqfg6mi5wkNLaVQpU/cQxjnN6zieF7GbLs9RZe2AHUbWFU5eSL4nHw+Uf3PPFC67yC5iTILzKjQhgicv7Q+yVGkvePfNyfmgVxF630TtvlC8z2w664XsyvnrV0WT8q/Jv6RCZzv5L1CXsWudcbjDtXVSrTWmmGPd4udwC6bHf/KxghN0QkGuOWJAGrAsyAnYjoPXSM9QYY6GZbwfSCDpzQe5ZZMJxL2EI2aporPFJKbqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VHGeQLARS16YmZjWWLS7sne17Yf4GC8ShnGAmlbOKV0=; b=VBVjpojbc5TflExGqoL+E6Px50BFLTe9Rl8ZPzyxJ24C297JHzRlt1GxpcazajCnFVinxJvtyKl1/vKOLC6q5+dKPhpizDTreqxjmxFU+Tg0nTLu7tvRmJcsqXm82Rv6w4TIoy2qH50ZgMI7jV+o05EYT7CPs9I8m+aIxMNjSaDABNQ7JUcIe1JWG9AKqqeA39cm7NVdeye2kzRYo6w/W++QY7/9f/yrZ7KRWpYHB2tQkoxR6xJRtpBM88lMzFQc0vB2TSkJ1u1S6akggbD8SFsaSQMuBpecNzjuCLscq2dtEywCOuWghrCXYV/9n4gn+RIcWJuqrle9lhH0+fDqkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VHGeQLARS16YmZjWWLS7sne17Yf4GC8ShnGAmlbOKV0=; b=CDzYJR0G0Hink7PoPs1++0T5/lg9ecM15DXjd0j2shiUvy0chgKWMXkMDei9zPIswhIVtfhlOnVmNCuSHsePSpNtnPLDaMMEfdq1Ra3b1VF3T3C+GNe/t3aYb0aLia5gFvGxFGE/Oomb0pqLt4DXLYsHRs0TL/Kl+vN4PG1dodMrY+ucIi+5vLsq9w83FEeZ8nsG+UltwZf3eBTaEVOdsNFRrkWgFzNIwhKRG3DQmx1N66K/iHsJORcoxse01Nu7q9mrt/r7Dcd9DxlkzsBFy1LtFEpgpj4DLDjTGY5Tmyxfen8Vs2trtVadjVwX+W1LYJsG8+Vtoguu5bLhsR1n1Q== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; 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=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Xu , Fabiano Rosas , Pierrick Bouvier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhao Liu , Halil Pasic , "Christian Borntraeger" , Jason Herne , Richard Henderson , Ilya Leoshkevich , David Hildenbrand , Eric Farman , Matthew Rosato , "Cornelia Huck" , Eric Blake , "Vladimir Sementsov-Ogievskiy" , John Snow , Markus Armbruster , Maor Gottlieb , Avihai Horon Subject: [PATCH v2 07/13] migration: Fail migration if switchover-ack is requested after switchover decision Date: Tue, 2 Jun 2026 12:26:15 +0300 Message-ID: <20260602092621.382-8-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20260602092621.382-1-avihaih@nvidia.com> References: <20260602092621.382-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636E:EE_|IA0PR12MB9012:EE_ X-MS-Office365-Filtering-Correlation-Id: e6529dcb-0fa7-4380-6c64-08dec0892ab0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700016|82310400026|1800799024|7416014|376014|56012099006|11063799006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: 3ZCdjb5Hl9q6da2kx5qly5zxLGSmUbWh4NHh/4PNZUWZ5TzucW83rHxc3uxYnCEEMgDHLj5lfaP7Q7HSKHmDancXosGjstmc5qkt3kQUgzR0OH2zzY+4T/AfHjilQc3/oynaiyN9McWZ+RiZOtj6dBG+GD+M1deYjafB8epV+0m8TdJMBlCXUsQKWWg8OKizvlygJBfdTEU10IDDAdHZ1IqhnKYKuoY2IpX+CIFkbAUvlZdAPMxxQlMluYUo+PDxvA2rNS2DPJnyQP674LIIVmcwVqUvjImfri6jozD9///L0LRB6x+jdwY0q6Dd75YOie/tdhHDDAdCtf7lAvjhldXcUfd0J4j91oFMj+2NddI9NA55KZ+wE9QXNkyWVEwZfmexIRN5wXrQRJ8WPZDwYSuAhXO/M23qtGe9QwirHRtkz4Jen25vhPmAOF+IpcXYhJ73UCVnn0CjFoCV3ZTFxPXh8AFagA5HrEEGdUQ+SKwsVq7pTQfuR49bz+EBmQMV/GDaSBuowzPtHRoJfliAzcOh2s3iX34ZSOIH/rskNoSrOHHQyOoZVnPK8gm1ufEDdL+G9CRw2ayN12XyzrGAak9yi3OLkDFP1SbE3RpQBu/8l7KR8rhnHwTf5oSP//MCHTdvmhq7wpJufbqwzf48FfMW0wamB4/hzrjaPrErOmMByvE/RIr1yNWBr8KZDjESmj5xxn23VSuN8Ak6pqh1KxwA86NZ6LQTsCByC75Rpa4= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230040)(36860700016)(82310400026)(1800799024)(7416014)(376014)(56012099006)(11063799006)(22082099003)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hNX1ip+bkNtWKjL1OssBimqqTpsdeAqDwiNSZGdTEnaWQs/PeRIv+stpbVWeE70vMd0yMB6TmmguEQlcbAFdAOSyE1mvCGOervmIychb53ESfXOfCnNyltHuhP6v+IoNVfvp/RKzaRJLq9SSnCb9vfE1jeoO5DdhQWTocG1yIcF6NA9czmuV+pAqujgGculdCqAtXpjVN1+xP89w2TCRyXQvf8e9OgYjL6mihc2GVmMyNBqfg4LMunRkj7ghEeSM9AXCCS9HrHatCo+D4yhLp24LC6enksiMvtie6aIMb0AVrrZpS403wEgcw8uEOAPdI3G9etlf08UI27vO+GC0pBgnfRw6iZUAFJBOGAyW5tTKwbhsPOui+RGwi/jdYOvTLnN4+7smrzDsSsIdaSAoJJNOf/8ZNSS/fH8d4LHX2aXtxU+epvNZ43zdmhmk3/MB X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2026 09:27:29.1109 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e6529dcb-0fa7-4380-6c64-08dec0892ab0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB9012 Received-SPF: permerror client-ip=2a01:111:f403:c110::1; envelope-from=avihaih@nvidia.com; helo=BN1PR04CU002.outbound.protection.outlook.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FORGED_SPF_HELO=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1780392499379158500 Content-Type: text/plain; charset="utf-8" Switchover ACK is checked only during precopy while the guest is still running. The last migration_can_switchover() decision and guest stop are not atomic, so a device may want to request another switchover ACK in the gap after switchover decision has been made but before the guest is stopped. Migration would then miss that request, which can increase downtime. Cover this case by failing the migration if a switchover-ack was requested during that time. Ideally, precopy iterations should be resumed in this case, however, VFIO doesn't support going back to precopy after being stopped, so implementing such logic would require non-trivial changes to the guest start/stop flow. Given the above and that this case should be rare, failing the migration seems reasonable. Signed-off-by: Avihai Horon Reviewed-by: Peter Xu --- migration/migration.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index 4bb649a467..6ee1c795ff 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2810,6 +2810,27 @@ static bool migration_switchover_prepare(MigrationSt= ate *s) return s->state =3D=3D MIGRATION_STATUS_DEVICE; } =20 +static bool migration_switchover_check_switchover_ack_pending(MigrationSta= te *s, + Error **errp) +{ + uint32_t pending_num; + + if (!migrate_switchover_ack() || migrate_switchover_ack_legacy()) { + return true; + } + + pending_num =3D qatomic_read(&s->switchover_ack_pending_num); + if (pending_num > 0) { + error_setg(errp, + "Switchover ACK was requested by %" PRIu32 + " devices during switchover", + pending_num); + return false; + } + + return true; +} + static bool migration_switchover_start(MigrationState *s, Error **errp) { ERRP_GUARD(); @@ -2822,6 +2843,15 @@ static bool migration_switchover_start(MigrationStat= e *s, Error **errp) =20 qemu_savevm_query_pending_final(s, &pending); =20 + /* + * Switchover-ack requests done after switchover decision, are not all= owed. + * Fail the migration in this case since we currently don't support go= ing + * back to precopy. + */ + if (!migration_switchover_check_switchover_ack_pending(s, errp)) { + return false; + } + /* Inactivate disks except in COLO */ if (!migrate_colo()) { /* --=20 2.40.1 From nobody Mon Jun 8 03:21:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1780392560; cv=pass; d=zohomail.com; s=zohoarc; b=dBxC1Tj/n04J1INr1qg/DI+rubq9Ac/1/bwxrpAW2/7rPqQgHP/864LTOtYYVLn01u6z7NmPSkWy27gaNwCpbsbNFwX7V4wevzT7tjlA0QBMZ2PDnOqK7Otyy6kqc9fyrMe8guTPjAlsygGU95ReMW3u062IMY33Jx91syG9qWc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780392560; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MDvTHtKzWXXY2+Vb/T93yC+5OXzg+igVcKG1Vo97EBg=; b=A7WNwrKdcBuVBGawpgtq3V2V1W5jSo6/CDiRb0kHOl5WHqJHZd7h8nQOBpImDP7JeruseByRyvyyrHy0CI7VBNW7Ev4nEfCm2mMAVmoV3XJhpbhs4rPjshcgYm5dxbdHnFYWKWs9CskK1oLb1Tdz9aECzdpaUi35BbSB7Ur1DVA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780392560758770.3354159350588; Tue, 2 Jun 2026 02:29:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wULPX-00061t-AL; Tue, 02 Jun 2026 05:27:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULPW-00061g-Kl for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:27:46 -0400 Received: from mail-centralusazlp170110009.outbound.protection.outlook.com ([2a01:111:f403:c111::9] helo=DM5PR21CU001.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULPV-0004F1-6Q for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:27:46 -0400 Received: from CH2PR07CA0012.namprd07.prod.outlook.com (2603:10b6:610:20::25) by CH3PR12MB9100.namprd12.prod.outlook.com (2603:10b6:610:1a8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.71.15; Tue, 2 Jun 2026 09:27:33 +0000 Received: from CH2PEPF0000013D.namprd02.prod.outlook.com (2603:10b6:610:20:cafe::3c) by CH2PR07CA0012.outlook.office365.com (2603:10b6:610:20::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.71.16 via Frontend Transport; Tue, 2 Jun 2026 09:27:33 +0000 Received: from mail.nvidia.com (216.228.117.160) by CH2PEPF0000013D.mail.protection.outlook.com (10.167.244.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.5 via Frontend Transport; Tue, 2 Jun 2026 09:27:32 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:27:20 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:27:20 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Tue, 2 Jun 2026 02:27:14 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bbiuus+eaNpA9EUQwasTOV9P3YO72pDmYcSY170YzVPiugV/tu872pK/ctDLOQLSSccJrMieUtIKSZggqWEGAwspWqseqDIbB+7smWfRtD6NkJNoAakH1apd8GK3zG8b8raDHrf+Jyuyb6nFaB0Sk0vqaIEk30zhzRlHN5fO5ESW4K9mgNHGJmM6Tf1P5hlECb3ed0F5CtlwQBM6H23t9feJTU3tcOYsOX7TJECOzb38Ayu6NIUS8tHowdMElWHeBM/pjqflk3J2psIasqbTp8yMxwC12mik4WS7eo28phbR3VhYsOBWhXGi/Q6xlHX1w76zJHBXPWDQPxeRnep+JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MDvTHtKzWXXY2+Vb/T93yC+5OXzg+igVcKG1Vo97EBg=; b=S7d3rkzBA/uohmSM0zXFgEeicqqeibzxnhu5MaLgFcp2gqrOpFdk1958SeiYoFnkpLCttNDCZVEspbolHBKki5g8o5EE4uE4qq2ao6rbfiNyj28C162RUUfWYdlNwYZ7UeWHzf743Hb5iScounX6NKSDJc6q7Zn5rS42q9s1cR20N7Xu3Wa5AofVpC8Yir0DNpAeQeelLAvnSajtjefi9Zfvc+zK8LagpBNwDUacl2vw5zTWAmc1OOP231XLD8NIejVQPvK8nUDwan6ipPKdnex+eROxLfoHPoiMjqFqssf0BkRap+NsUx19R1bGjH1scbZwLR6Gd2p4LMJkttCblw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MDvTHtKzWXXY2+Vb/T93yC+5OXzg+igVcKG1Vo97EBg=; b=URMBQ83yVaOJ88KUJmRIqQLYGlrSWPge/NbzLa5BRI7eLfboFa/eL356HQDIPIqswQ1Q7hsuM6FwDn1C0pRVhSzas0LoPuBVEtQ6ahX+FFGfJ5eKBtJ/OUZhiGDwPuE9xQnztFrNtaIMRUN4ii0jXA+TW48Cp3fY3AbFp1qzTj4frqSCqdKySd/sLJw9gpyvorxVXfgcM21BoSfJyPW5P+2EUdGq8vxiJDpj4TQVFEOweX8I8qPBLUDEFfhmbzzbWTkBjdfoxZhlalgfoeD2L0kbdpZcjfrpapXH5oGgTUiMQfQP6xGVq4lEdgT2G5C076dxCjMmnKZN3D8hFr8JRQ== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; 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=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Xu , Fabiano Rosas , Pierrick Bouvier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhao Liu , Halil Pasic , "Christian Borntraeger" , Jason Herne , Richard Henderson , Ilya Leoshkevich , David Hildenbrand , Eric Farman , Matthew Rosato , "Cornelia Huck" , Eric Blake , "Vladimir Sementsov-Ogievskiy" , John Snow , Markus Armbruster , Maor Gottlieb , Avihai Horon Subject: [PATCH v2 08/13] vfio/migration: Extract VFIO_MIG_FLAG_DEV_INIT_DATA_SENT sending to helper Date: Tue, 2 Jun 2026 12:26:16 +0300 Message-ID: <20260602092621.382-9-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20260602092621.382-1-avihaih@nvidia.com> References: <20260602092621.382-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF0000013D:EE_|CH3PR12MB9100:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ce7183b-f879-4eac-b2e6-08dec0892ced X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|7416014|36860700016|82310400026|22082099003|18002099003|56012099006|11063799006; X-Microsoft-Antispam-Message-Info: ANTAP7CVNNBTVfAxHXxRb8N/LnDIP+UdW5d5PcVy2CSYrOontuyBWRZ41XmUuzvjVF4nC7t5OazeBNt8NQnn04m5B1CfvbjmVBZMR0vgZLw2IQvDvZwaF0rGsG2E0dVe6zj8YfdYxFh4jwB54X2PgxU8+MsXzhmT3eI7GQeKs+fO7Oa+b6Lmxz/SURmtk3AHJF63kvc5h3gbYC/DOlgAUTh/UP5hi6cQ4buZ53VXNW1Ufff+AKuT988/DOGOK3lFI+fCerp/at5QEu3Ttwxuak4V2yA7YUrMaSwoa9VELZBK7TbE63dXTv1cYnVRlX2kZVYzroffHnXjvAeG4aAmFB4sZjkduuuw3yYNdGIZ92dHConFUYQFVDim2Uo6/pTqT7itpkTKTqqGEKWry+mLbh7ApWNNpWeogB4MJo7aOYm+NFACit0SZul9kCTjpiWw5fb5mIdTwAra0hd2Maywd8Sle47d59MceeQc9WimUzkOZwH0Q2rEokKA8WXzs0xFOEBtU7veVBYWf2SVHDJJIYFtttRrRHGgHo7/V2un2vuhQuxotBIPhrzKAnAyHj3GQLzawjYSW274V2xkk94lreBdrnXDXgzbvWm/rBuMb1rv5zJNL+ueYIDIMU9XLBSvf3krAJQczCYGUwkhxfaFEgXEo+yUDBZ7VjYO4kByzfqwmSG9kKpG2WQ6Jw7YcTbGltQzq1b8ymz+psh++giM061I0QKQiFgU02qHmmeKk5g= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(1800799024)(376014)(7416014)(36860700016)(82310400026)(22082099003)(18002099003)(56012099006)(11063799006); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iCOPVV7iF8zHUuOhDay3ht/FMA6EmfFakoczLRU3obfnnsi5TTvr1pxKMAxdzfcCf/Q3cmxVzKOqnMy37Fq3R+yPDyPOfG3lRxFwzrXUdVle+IoF1SZXTT8S6uVY7g0Vpf/zqqw97tfsplIGPc0izHE98oeeBXMcEk3uu7sHsgXRAwR7pTUvROcoR9blJ6rwgDS+GUSuLJtwM0PC4y3r6X1jWzx5XOxTpNNJEIzMpvoQ31tsbUkKSLyJJopAxh0wJwP6K8wf/CLq5Hb57SHWqHV0g7IxU33HtkQUBwBJTffC/8ZWh33Eq9f8g9+J7mQdmWwnb5V6XM0S9D6IhN/vJF2vOrv1TcaYRMUNX2PPEm6nYGBX+fDib/J6R0Fx1kl4uyRSuGcYDSAR+PgCNXaOEnZqL3ylLBRz7tuaLOVA2k7Na/8YPKntbkIy8LoaLYqY X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2026 09:27:32.8667 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ce7183b-f879-4eac-b2e6-08dec0892ced X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF0000013D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9100 Received-SPF: permerror client-ip=2a01:111:f403:c111::9; envelope-from=avihaih@nvidia.com; helo=DM5PR21CU001.outbound.protection.outlook.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FORGED_SPF_HELO=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1780392562851154100 Content-Type: text/plain; charset="utf-8" Extract the VFIO_MIG_FLAG_DEV_INIT_DATA_SENT flag sending logic from vfio_save_iterate() into vfio_send_init_data_flag() for clarity. Also add a trace while at it. Signed-off-by: Avihai Horon Reviewed-by: Peter Xu --- hw/vfio/migration.c | 26 +++++++++++++++++++++----- hw/vfio/trace-events | 1 + 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index d5be135584..a15e877fd3 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -480,6 +480,26 @@ static void vfio_update_estimated_pending_data(VFIOMig= ration *migration, data_size); } =20 +/* Returns true if the init data flag was sent, false otherwise */ +static bool vfio_send_init_data_flag(QEMUFile *f, VFIOMigration *migration) +{ + VFIODevice *vbasedev =3D migration->vbasedev; + + if (!migrate_switchover_ack()) { + return false; + } + + if (migration->precopy_init_size || migration->initial_data_sent) { + return false; + } + + qemu_put_be64(f, VFIO_MIG_FLAG_DEV_INIT_DATA_SENT); + migration->initial_data_sent =3D true; + trace_vfio_send_init_data_flag(vbasedev->name); + + return true; +} + static bool vfio_precopy_supported(VFIODevice *vbasedev) { VFIOMigration *migration =3D vbasedev->migration; @@ -692,11 +712,7 @@ static int vfio_save_iterate(QEMUFile *f, void *opaque) =20 vfio_update_estimated_pending_data(migration, data_size); =20 - if (migrate_switchover_ack() && !migration->precopy_init_size && - !migration->initial_data_sent) { - qemu_put_be64(f, VFIO_MIG_FLAG_DEV_INIT_DATA_SENT); - migration->initial_data_sent =3D true; - } else { + if (!vfio_send_init_data_flag(f, migration)) { qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); } =20 diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 2049159015..e99ee2ee8a 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -175,6 +175,7 @@ vfio_save_device_config_state(const char *name) " (%s)" vfio_save_iterate(const char *name, uint64_t precopy_init_size, uint64_t p= recopy_dirty_size) " (%s) precopy initial size %"PRIu64" precopy dirty size= %"PRIu64 vfio_save_iterate_start(const char *name) " (%s)" vfio_save_setup(const char *name, uint64_t data_buffer_size) " (%s) data b= uffer size %"PRIu64 +vfio_send_init_data_flag(const char *name) " (%s)" vfio_state_pending(const char *name, uint64_t stopcopy_size, uint64_t prec= opy_init_size, uint64_t precopy_dirty_size, bool exact) " (%s) stopcopy siz= e %"PRIu64" precopy initial size %"PRIu64" precopy dirty size %"PRIu64 " ex= act %d" vfio_vmstate_change(const char *name, int running, const char *reason, con= st char *dev_state) " (%s) running %d reason %s device state %s" vfio_vmstate_change_prepare(const char *name, int running, const char *rea= son, const char *dev_state) " (%s) running %d reason %s device state %s" --=20 2.40.1 From nobody Mon Jun 8 03:21:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1780392555; cv=pass; d=zohomail.com; s=zohoarc; b=Pi1X1iWGXvz0re3rLecHKcUIR4VS46xpIh5+hoj1plQD/6uLJExI3uDCUYBEspkKVbkxry78zbvoWAKdlBFlGYgc68x/nCdOieqg2KVFhHhiZOjw9GOy+xcJCIbtVUh1JYeZvk2kwVxOjwMQ4Ayc3p7nCCAAPKdBONkiYxl0sh0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780392555; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qSadcmZWNggkVFRixwLYfj9QC/MBSzVomxP79ut3tV4=; b=Jl7zEcdUpo6BM8/0JeePxo8/2RQ0eR8HCSzMEQpys2BcScMdEHFPRzRRnV2vKM/16SSiewq/TCSAC/dRVOu2hDWHKq4LxjvHTmIn13+lsM1vXWdKgUoI3XnaH1Dt+Sgv+UERBTsEQQ+rZGOlYXQzY+PqQhZsjClCklgeErq/+18= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780392555032182.16163900728873; Tue, 2 Jun 2026 02:29:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wULPb-00062T-9s; Tue, 02 Jun 2026 05:27:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULPZ-00062L-Sz for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:27:49 -0400 Received: from mail-southcentralusazlp170120001.outbound.protection.outlook.com ([2a01:111:f403:c10d::1] helo=SN4PR2101CU001.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULPY-0004J4-G1 for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:27:49 -0400 Received: from BLAPR03CA0048.namprd03.prod.outlook.com (2603:10b6:208:32d::23) by SA1PR12MB6750.namprd12.prod.outlook.com (2603:10b6:806:257::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.71.17; Tue, 2 Jun 2026 09:27:42 +0000 Received: from MN1PEPF0000ECD6.namprd02.prod.outlook.com (2603:10b6:208:32d:cafe::81) by BLAPR03CA0048.outlook.office365.com (2603:10b6:208:32d::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.71.15 via Frontend Transport; Tue, 2 Jun 2026 09:27:42 +0000 Received: from mail.nvidia.com (216.228.117.161) by MN1PEPF0000ECD6.mail.protection.outlook.com (10.167.242.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.5 via Frontend Transport; Tue, 2 Jun 2026 09:27:42 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:27:27 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:27:26 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Tue, 2 Jun 2026 02:27:20 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rTL5oRyMFBzxAJHhmJh7erwa1wBy0rvPebxYo5zS9Cb1IVoIFO0DiSfx9+Kfzf0AUAo5KqpzUGn8qoB30YdSRGa3IChKBsEgj+1jc5GQtN6aSJ8wLgK+V6xR7LpJVNead6ACoMbyO9VvosqOfcBLmbmvUAXLDCylEqDCM1cDpxxaWy7MJwMT1gPYbJw5dY5C0iJl4gvtWuZRS34oefnLRp+bW7gf3s39uMNfaZ8tK/YrHwXoZUCe1DnPh3yv4A21M1FewBrbBz4WjpezOof3YSfp3cLPsMkbZ12EKo+R1X/RI39f9gs9VWse/LxAwnOmt3gZo/pQGynfZtTpYkMkXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qSadcmZWNggkVFRixwLYfj9QC/MBSzVomxP79ut3tV4=; b=sdep4mSctic1VTHRpQviAqxGSDgvZbz+bETNHNaTEOMhCF+P4AvN0X7BgS0RfliwxJn/zLIlcI1rCW8b8flwUdyHzk3dUQuq01b55yRaarvXQgo5sqVVx0zOGRgw079wnet4pBttvHp4OF+w56skTIpZohoz6oclW3Z29i+pqOMFL0UKHvmR7N47JW2oPKPNdeemR74tKwM+gJJ62bOy2JEs0Hil0l0pwHwEevHBOEe76thu020RqHL55Ol2T7OTewlUp5m2l63d3FuP6/lU75CENmDEdM5Kn0WxYgnQU3njUv83KyTwLhT/Ei2NlZQce/ELagT2WcQ9H3dx7BgTnA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qSadcmZWNggkVFRixwLYfj9QC/MBSzVomxP79ut3tV4=; b=S3jc22udRCiref0Q5Kj90ALkBwkbEuJgoUqBQBLZFhptJ6wFN/w/lhjx6VRcnSs/efJgnOFJtSNnYi2lTM79vaGrtfbDvHsuOEetDdu2lYsA97LgWY+6FG7Oa2S2dbyP/z/wis7QzOB7xvx72EeRrHQfhdCgXHg/WKiTSFEw/dxnFKOzECRkKKpLcNahyioQRvp6cV90b9iUoZ5dNarOc31Iy8gyLwlAeoIYm1L3QTQtjQyI4chGd/NhpU9zT1LhJaxY4pY0Apgf8QQyGRga6FlxgWM571UmvITA8zErQKrikVpZAmhsG5Yinmczr/3lrk+PyLyfn4Chuh0NkSATHg== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; 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=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Xu , Fabiano Rosas , Pierrick Bouvier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhao Liu , Halil Pasic , "Christian Borntraeger" , Jason Herne , Richard Henderson , Ilya Leoshkevich , David Hildenbrand , Eric Farman , Matthew Rosato , "Cornelia Huck" , Eric Blake , "Vladimir Sementsov-Ogievskiy" , John Snow , Markus Armbruster , Maor Gottlieb , Avihai Horon Subject: [PATCH v2 09/13] vfio/migration: Add Error ** parameter to vfio_migration_init() Date: Tue, 2 Jun 2026 12:26:17 +0300 Message-ID: <20260602092621.382-10-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20260602092621.382-1-avihaih@nvidia.com> References: <20260602092621.382-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD6:EE_|SA1PR12MB6750:EE_ X-MS-Office365-Filtering-Correlation-Id: e1714fac-dca4-4b9c-bc31-08dec089326c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700016|1800799024|82310400026|376014|7416014|22082099003|18002099003|56012099006|11063799006; X-Microsoft-Antispam-Message-Info: Vrbxu9VT98zK+SFf1NisVDeazf30RBbFrRuN6Pf6JdK+hFQ6pOaEhKc3GrTsmVhez0FdaTxYMzMs5sPCWfU6/pJFzfSGJPuFlRDZbCjtQ6I4m5Zdckfg6o/JAtb7W5vERrdQ21b9llDIqR4zuxrghpYQZVI8qYjcJddtbOOAr3e89lLb5OJ7W3e1Yjvee/MH/CyxEa6VXCC+PnsVDy3CVX8AWPXYnenhUjjPjyUT1kwSfFNThRIn21jWkkBGVCnmoWk4710RIp7X7QQMWvEFqg3O0+Dh/t9N2L2wK5F+gnLiFL8ekFtwT+Sfrjl566X0DOS6XwvuI50iAsqyaaEKue55Iv9oY8QZmGGT3hHz0LeKHjpZoWQJdlodSh5rFhQ5Q96UV1yq/PWzKaf1UE1D85lI2dAlL/MmiG+RWK0a5AiMsdMYcEp/wMXVUffhjUEkcOYU76Mj/rfuzHFDTCByp/a5pB67d3zX5ou6a8mVEHbASS3DjNjgv4POJut3MxvJFjhL0spuFkxblKa2wsmYIgBmzHaugP1Ij4y/oVnjIE8Du4K3QrrDkArLtb9QiX+gEyvjOw8V1mMV3YB+3TrLUK/juY/YbwCsAkh6QntHv8hbhnAlmY+7u1Wl8f14jQB6sA9Ih6FxZxtWELaXpq3WBszzpyXz3XIAXcxOXOaE25zQJjwUYi1I/f11EKQ3YX73+jxC8lS+KLi8l9qxoWEfyJ5k1K5Nl5yW5t9VAGRRJWk= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230040)(36860700016)(1800799024)(82310400026)(376014)(7416014)(22082099003)(18002099003)(56012099006)(11063799006); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KfuuJx7C7TcaaQhpAwVzJhm06mkLjD8my8esp6Fc9cFkBeURuURxKf5Rbr29ly6WGzI/DpZN/XXfudKgpwCKBC4NSqSAt6kC5cHlzS45I/nJmiMWLS6mPdjT5HJjvc2xxYWYEIKHYbvMEEDWK2JdZBOtoNmjv/F0+KAqZaAy401WxnskOp/E9+b8SDQfogI2V7OGEeL1PpMki4wNu0hwbNBbT3D7eCv/DFSKFOZmQPmDaP3uHXtFXIpccs2ajs2AYOY3BBK1tsAm7iPoEd1N0nSdnXlUvS9n4LMDBQQMggTrmsRUgv/UNfuvktggZA8/KD2x0wfQrXTA0W0TqqZ4Bn2ux4ss1jKezFe2Acy0/BtoeMREt7hY2QB1za0d+dOIekWCNvB85m+wC9DtQ7AzoXmGbCZa/V9cZOEB7PVope0za36c5Uy/8ha/TSEDrgEV X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2026 09:27:42.0215 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1714fac-dca4-4b9c-bc31-08dec089326c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000ECD6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6750 Received-SPF: permerror client-ip=2a01:111:f403:c10d::1; envelope-from=avihaih@nvidia.com; helo=SN4PR2101CU001.outbound.protection.outlook.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FORGED_SPF_HELO=1, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1780392556783154100 Content-Type: text/plain; charset="utf-8" vfio_migration_init() already has many failure points and a new one will be added in next patch. Add Error ** parameter to vfio_migration_init() to report a detailed error message through it. Signed-off-by: Avihai Horon --- hw/vfio/migration.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index a15e877fd3..02ef216712 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -1055,7 +1055,7 @@ static bool vfio_dma_logging_supported(VFIODevice *vb= asedev) return !ioctl(vbasedev->fd, VFIO_DEVICE_FEATURE, feature); } =20 -static int vfio_migration_init(VFIODevice *vbasedev) +static int vfio_migration_init(VFIODevice *vbasedev, Error **errp) { int ret; Object *obj; @@ -1066,21 +1066,31 @@ static int vfio_migration_init(VFIODevice *vbasedev) VMChangeStateHandler *prepare_cb; =20 if (!vbasedev->ops->vfio_get_object) { + error_setg(errp, "no vfio_get_object handler"); return -EINVAL; } =20 obj =3D vbasedev->ops->vfio_get_object(vbasedev); if (!obj) { + error_setg(errp, "failed to get object"); return -EINVAL; } =20 ret =3D vfio_migration_query_flags(vbasedev, &mig_flags); if (ret) { + if (ret =3D=3D -ENOTTY) { + error_setg_errno(errp, -ret, + "migration is not supported in kernel"); + } else { + error_setg_errno(errp, -ret, "failed to query migration flags"= ); + } + return ret; } =20 /* Basic migration functionality must be supported */ if (!(mig_flags & VFIO_MIGRATION_STOP_COPY)) { + error_setg(errp, "VFIO_MIGRATION_STOP_COPY is not supported"); return -EOPNOTSUPP; } =20 @@ -1278,18 +1288,9 @@ bool vfio_migration_realize(VFIODevice *vbasedev, Er= ror **errp) return !vfio_block_migration(vbasedev, err, errp); } =20 - ret =3D vfio_migration_init(vbasedev); + ret =3D vfio_migration_init(vbasedev, &err); if (ret) { - if (ret =3D=3D -ENOTTY) { - error_setg(&err, "%s: VFIO migration is not supported in kerne= l", - vbasedev->name); - } else { - error_setg(&err, - "%s: Migration couldn't be initialized for VFIO dev= ice, " - "err: %d (%s)", - vbasedev->name, ret, strerror(-ret)); - } - + error_prepend(&err, "%s: VFIO migration init failed: ", vbasedev->= name); return !vfio_block_migration(vbasedev, err, errp); } =20 --=20 2.40.1 From nobody Mon Jun 8 03:21:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1780392486; cv=pass; d=zohomail.com; s=zohoarc; b=HRQmB2MzyqILjNWlIclLMwAg+QeS6XG8WcAS+rt20pVVf0ZV9/EWHGqiGOlJZu2KkdBWIOwqN6mCIkYwtTLIaDwM4BCbr+VClN/jHR/XpMQ7RVOvdB8ENPx7oM6huIL+zxf3SqO2ajv9CUiS/46kJUabssyqPVGMEpeCgMNgk10= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780392486; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0JcaI2x2sVYxUmtliF5hyiKKznS+5+xzDS1hhrISoWM=; b=PaVyOWy/m8ZUBIKegf1OqdOR1USmhS+/WrcKu5EG2LcimI7RhNV1Dg6dFkqbCWKJiiPphJ1kmqXQzL3fmqVJmpTTgEuPWW7n8DmEewA5fiIRBckVmc6vakzUtB6grQLG8KdKaYWmfhbqRdLtMyd6cG09tS0LlRSgDbgiG/yAud8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780392486027514.7357182239651; Tue, 2 Jun 2026 02:28:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wULPf-000639-B7; Tue, 02 Jun 2026 05:27:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULPd-00062m-6c for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:27:53 -0400 Received: from mail-westus3azlp170110003.outbound.protection.outlook.com ([2a01:111:f403:c107::3] helo=PH0PR06CU001.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULPb-0004Jf-Ib for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:27:52 -0400 Received: from CH2PR18CA0021.namprd18.prod.outlook.com (2603:10b6:610:4f::31) by SJ2PR12MB8691.namprd12.prod.outlook.com (2603:10b6:a03:541::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.71.14; Tue, 2 Jun 2026 09:27:45 +0000 Received: from CH2PEPF0000013F.namprd02.prod.outlook.com (2603:10b6:610:4f:cafe::36) by CH2PR18CA0021.outlook.office365.com (2603:10b6:610:4f::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.71.16 via Frontend Transport; Tue, 2 Jun 2026 09:27:45 +0000 Received: from mail.nvidia.com (216.228.117.160) by CH2PEPF0000013F.mail.protection.outlook.com (10.167.244.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.5 via Frontend Transport; Tue, 2 Jun 2026 09:27:45 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:27:33 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:27:33 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Tue, 2 Jun 2026 02:27:27 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=igxxitUq138Kd/mdMR+apLbmivKCLx5TT+9I6CD1gZO82lWCc74//U7UAa+GSXURcXZ7RaVI4pshMidU9ajg9yqBfLGdQuTtzWbm9VIPTO7SkosxVIO8jFPbW4+Lkn3X96C5Yrv5SG+Qq0vNCllK+G9FVgeV7R2NP2EJocx6ehl7s2oaIRA2WF0FifyjGjgIoKLpkuNWzCkPRXt5ruN+fxFGXXGnx6yegwwjuJoUvcN7ZxSsqbQ0Y0oWS1pNnoNJiyTL5wbQpIsgIyUhxIQTCtxAThBDCPbouEPW1M/asNdaMDvWqPewRur/bBojS+vdFKwVSTUQPrg15XlBi6YrRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0JcaI2x2sVYxUmtliF5hyiKKznS+5+xzDS1hhrISoWM=; b=y6RyFJWcPwvAA1cPdSTpGdNjBdHXmCuSf93z3BjY7Gx4HhqM8xk2vBOPKEqZYQt9AsUDV2EMABP21RfYjYmLENhbJUH3lRskQUuQITnkHXrDhoXO00K+jTiuyX6xlNysY3irY/mmVFxJyCJSVQbUzkJAxSn/TkNzvJ220xrouRIrfzZzU2QVMuPxQwddVN4JKcwdlf8SW+J7jgPtG+BVXcDv93rqCJNP1ZIdCOm6dCMDWsNyXzsyOcDIeQiNB7rVrEWfJ/hSHmEirr3nxEK/Q+WzVRkP7gqcxbaunie3aDDgkFvnkqCwq+o5lL7C2g/MnJw7K8qsvpNPclj4HQxYog== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0JcaI2x2sVYxUmtliF5hyiKKznS+5+xzDS1hhrISoWM=; b=C8Qf8p/RLFZmEZozdbOi4n/3Nh8wda3zasRsz7+ZB5PDNK53jU9hF61bF71l6rJHqVkoOPqSj+GJIaZw099u4+a72EXAzC9BSMu3cHgkT5QR0aOaV+pbouu9UPYvSPzmP1CxYD8KUrpP2r0gsujRalhqWZ27QHygy+4L+9YWU7dedXfMcRn7Vmlxavq0jct20CpXYzugoKcguvX07jz41UMaaowG4ma8VAa42fDuRQDFst1wO4yfATxc3OyIjNhotkrFD1tO3mQJ9MKq0Mc45jx/jd94XPEO89wI0rTtzM4qMBZv24FzQBm0lzRu9f1quJPDbvkgtQUDEtJnCfIJfw== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; 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=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Xu , Fabiano Rosas , Pierrick Bouvier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhao Liu , Halil Pasic , "Christian Borntraeger" , Jason Herne , Richard Henderson , Ilya Leoshkevich , David Hildenbrand , Eric Farman , Matthew Rosato , "Cornelia Huck" , Eric Blake , "Vladimir Sementsov-Ogievskiy" , John Snow , Markus Armbruster , Maor Gottlieb , Avihai Horon Subject: [PATCH v2 10/13] vfio/migration: Add new switchover-ack mechanism Date: Tue, 2 Jun 2026 12:26:18 +0300 Message-ID: <20260602092621.382-11-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20260602092621.382-1-avihaih@nvidia.com> References: <20260602092621.382-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF0000013F:EE_|SJ2PR12MB8691:EE_ X-MS-Office365-Filtering-Correlation-Id: 2eaf5279-a41d-4527-d217-08dec089346b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|82310400026|36860700016|1800799024|18002099003|22082099003|56012099006|11063799006; X-Microsoft-Antispam-Message-Info: Vv6cWI8DzYvDpzd/+lb6ftYz4JtMQJSdgQHESF766AIJRXBSbRYGHG6h+r2+4qWs5XQbkFrT2wuFWbgjEMGdAFlPCArPkutBXP4wTY5qLsACKrey4hUPbxpj5fcka/92lLgtzxuWx/JLGj7JfSdRAPH6NP+GHnXxcd1TxPrYo9c/8KRt/XAaCV4UmJOc33xaoP/JuFclg/IrtY/BHhSkQj+3IGqKrzmhQ5PiqjNvP6UupCpahNfR6i7rrbQXws0E4VFoAhrubS7y51z4C1P0F59jAAhe6NuRFNNdaaCM8ny/HXQ4PsjbEW1wBUC8S5RjtZnbs6JYRkhyCR3KJMp2Ik383Gve8+Y04zKIQUcQHWg3X9oH8An4BLredVuLnQcmm3QBrNXbwElxJ7Kx54BgJUsWUMap0B3wlGw9ICb9i1ra5t8Y7MIwl0cGEyihv59moDPwC1jActEsFnhOXOc0wCwtGQq5X664jTy6NGnYWpKw1uOKgeMfGyGQYSLsKKswZZoHKWE4dym3ysucY3u8GW31vzT6sgM8D8W4vxXapyvFV2/MF2HDV5ArnygHGZXlJr2Xrv9p6hanf+l2FzvYVOKdYt5qPFv34MsGCRjqWqOfpmaqfKso92EoSYEaahCiwYIH3nrdjxeX8Z4mKJoDb77HUHRh6m+VKQxKdp3Hb7oLu/vdHpQ3kqy7SPwgAVrkSyuK8z56cNwXtntQo9oeS/3PlKz7/XVW3HbFF8LXdDw= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(376014)(7416014)(82310400026)(36860700016)(1800799024)(18002099003)(22082099003)(56012099006)(11063799006); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 60aUeOTjufmb0sEY31y9z7t4zt4KlRZcZgMcoXzVuPiuMR5tnb1b18G3p+jAMs4wfbJBo/ISxlKtnQGJ2IEDtgWPA+uyWlbiNvuHRsObWXiOmsDiA97+JZYKk94a7M1UzZMTS1vDJZ44+Ot5yy72NjzCybaQHt4Oz1FdK0vDHgmRMeFiZhqIGTxcnP1V0dxBcPC4DJKax2T1bogskdc4vbtbbqBYgNDROWlRsKKQZEWE6jw7qgefKXt3qBuaKbItVnumqmaeRzgZseNY2OvZk92dZYGdu6GH2QHYwjKoFsoz57AGQ5M4bfc/M79e2yOuzHxzPQXYP34lJX5ZzoNs+WxNmzFAyBbMTu067qN+kJYWHvBQG7fw9zFZhNf5MDYsG7D6YvqYr1RJS5DAd/YwhEGW27D4th8bmAnp6dtXaVT7s+9kpWrnH5fIIJaaB4sP X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2026 09:27:45.4049 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2eaf5279-a41d-4527-d217-08dec089346b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF0000013F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8691 Received-SPF: permerror client-ip=2a01:111:f403:c107::3; envelope-from=avihaih@nvidia.com; helo=PH0PR06CU001.outbound.protection.outlook.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1780392487640158500 Content-Type: text/plain; charset="utf-8" Add support for the new switchover-ack mechanism. This includes requesting a switchover ACK on the first save_query_pending call (with exact=3Dfalse) if VFIO precopy is supported. This achieves the same functionality of legacy switchover-ack but with the new switchover-ack mechanism. Keep legacy switchover-ack functionality for backward compatibility. Signed-off-by: Avihai Horon Reviewed-by: Peter Xu --- hw/vfio/vfio-migration-internal.h | 1 + hw/vfio/migration.c | 13 ++++++++++++- hw/vfio/trace-events | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/hw/vfio/vfio-migration-internal.h b/hw/vfio/vfio-migration-int= ernal.h index a15fc74703..dc741e5142 100644 --- a/hw/vfio/vfio-migration-internal.h +++ b/hw/vfio/vfio-migration-internal.h @@ -58,6 +58,7 @@ typedef struct VFIOMigration { bool multifd_transfer; VFIOMultifd *multifd; bool initial_data_sent; + bool request_switchover_ack; =20 bool event_save_iterate_started; bool event_precopy_empty_hit; diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 02ef216712..2296d0d44b 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -582,6 +582,9 @@ static int vfio_save_setup(QEMUFile *f, void *opaque, E= rror **errp) } =20 vfio_query_precopy_size(migration); + if (migrate_switchover_ack() && !migrate_switchover_ack_legacy= ()) { + migration->request_switchover_ack =3D true; + } =20 break; case VFIO_DEVICE_STATE_STOP: @@ -634,6 +637,7 @@ static void vfio_save_cleanup(void *opaque) migration->precopy_init_size =3D 0; migration->precopy_dirty_size =3D 0; migration->initial_data_sent =3D false; + migration->request_switchover_ack =3D false; vfio_migration_cleanup(vbasedev); trace_vfio_save_cleanup(vbasedev->name); } @@ -655,6 +659,7 @@ static void vfio_state_pending(void *opaque, MigPending= Data *pending, VFIODevice *vbasedev =3D opaque; VFIOMigration *migration =3D vbasedev->migration; uint64_t precopy_size, stopcopy_size; + bool request_switchover_ack =3D false; =20 if (final) { return; @@ -675,10 +680,16 @@ static void vfio_state_pending(void *opaque, MigPendi= ngData *pending, =20 pending->precopy_bytes +=3D precopy_size; pending->stopcopy_bytes +=3D stopcopy_size; + if (migration->request_switchover_ack) { + pending->switchover_ack_pending++; + request_switchover_ack =3D true; + migration->request_switchover_ack =3D false; + } =20 trace_vfio_state_pending(vbasedev->name, migration->stopcopy_size, migration->precopy_init_size, - migration->precopy_dirty_size, exact); + migration->precopy_dirty_size, + request_switchover_ack, exact); } =20 static bool vfio_is_active_iterate(void *opaque) diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index e99ee2ee8a..50722eb717 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -176,7 +176,7 @@ vfio_save_iterate(const char *name, uint64_t precopy_in= it_size, uint64_t precopy vfio_save_iterate_start(const char *name) " (%s)" vfio_save_setup(const char *name, uint64_t data_buffer_size) " (%s) data b= uffer size %"PRIu64 vfio_send_init_data_flag(const char *name) " (%s)" -vfio_state_pending(const char *name, uint64_t stopcopy_size, uint64_t prec= opy_init_size, uint64_t precopy_dirty_size, bool exact) " (%s) stopcopy siz= e %"PRIu64" precopy initial size %"PRIu64" precopy dirty size %"PRIu64 " ex= act %d" +vfio_state_pending(const char *name, uint64_t stopcopy_size, uint64_t prec= opy_init_size, uint64_t precopy_dirty_size, bool request_switchover_ack, bo= ol exact) " (%s) stopcopy size %"PRIu64", precopy initial size %"PRIu64", p= recopy dirty size %"PRIu64 ", request switchover ack %d, exact %d" vfio_vmstate_change(const char *name, int running, const char *reason, con= st char *dev_state) " (%s) running %d reason %s device state %s" vfio_vmstate_change_prepare(const char *name, int running, const char *rea= son, const char *dev_state) " (%s) running %d reason %s device state %s" =20 --=20 2.40.1 From nobody Mon Jun 8 03:21:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1780392560; cv=pass; d=zohomail.com; s=zohoarc; b=eyLA0cLrZMekKXUaay0dG3GbJz/3pqsIhnKzBIQyt1asCs7mWryF3PqAGeVloELlM5P1C6MpjEFJYk6X/QR1H/AfS6spsnV3drcGpisxF2GDxioPX5DR5YtLljVgoWlHhvhlEEBbDE8IAjzzV3NCgzMNp2GVivgEY+rVu4eA6ws= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780392560; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fsYTiKUMByKP7I84GXZwW9hlEJjiVa5uNAfDYfEJ21E=; b=D07wwNznaW4hvEZqYuhIA5v+u7GTk9DDLXm2Uy7Xru3K5uz3ZggrozefCXArba+by4QvwSSQ6C+pt484mc6f5BnyqUlZoIO/FQZ9AJj13VMbXvnNKGWKrcyadpbUk5NnmpauAScN+kDKJXR6jbsX7YwUYvOJHL61XB7n5tnNFp0= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780392560846221.24996793528226; Tue, 2 Jun 2026 02:29:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wULQF-0006mK-7d; Tue, 02 Jun 2026 05:28:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULPs-0006Qw-3b for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:28:13 -0400 Received: from mail-westus2azlp170100005.outbound.protection.outlook.com ([2a01:111:f403:c005::5] helo=CO1PR03CU002.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULPm-0004KZ-Q0 for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:28:06 -0400 Received: from CH5PR05CA0021.namprd05.prod.outlook.com (2603:10b6:610:1f0::18) by SJ2PR12MB9115.namprd12.prod.outlook.com (2603:10b6:a03:55c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.7; Tue, 2 Jun 2026 09:27:53 +0000 Received: from CY4PEPF0000FCC5.namprd03.prod.outlook.com (2603:10b6:610:1f0:cafe::2a) by CH5PR05CA0021.outlook.office365.com (2603:10b6:610:1f0::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.92.7 via Frontend Transport; Tue, 2 Jun 2026 09:27:53 +0000 Received: from mail.nvidia.com (216.228.117.161) by CY4PEPF0000FCC5.mail.protection.outlook.com (10.167.242.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.5 via Frontend Transport; Tue, 2 Jun 2026 09:27:53 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:27:40 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:27:39 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Tue, 2 Jun 2026 02:27:33 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cOzPe0HMu1hVwfRCUJm8FPuG5ztkKtgOfYMa+BrYbWmURwFxvZUAEBNg+KV0cUCxejaKgqFRT0BHEgr0V+gTIsypdVy1quRbL5YRZYevNqBJmEqSTk9WNTILBHVfFCWZ72ixKPuhhWLVeqlQCPChnFd+SQiml0Oqg4FEBq5zq0qt14znImGdBnTjLmM3W/IrtjoeuDNf3W/gdNBKiStCXwN34psVf8qN97nWFYxIHfg9Hkml4U9SPIjC24DHrAzPuF/k7kEBHOcGBU3vvCcKM9dbAzW/YHXQNsp8CWj9vveA/w6oaqC++Cv74sKoSb5aqq55rHn/R5N5yB3xeHBTUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fsYTiKUMByKP7I84GXZwW9hlEJjiVa5uNAfDYfEJ21E=; b=ENyT0M+IOsfIcKPUigsL7yuSf9JzAasPMZiPs+aC5pfZtT9SdPAtgNsal/FYqDEHT3n56lXBiOFmvfAY3mZHga6mDZloolqtUEQdGCTvVzdjws+S8pJEpBSjvhYzRf/WnbiY6vJIcfI0JIkyK/WU9xiCxdMHiuw5rMMyNrtLwH4dStDnj/SY9dBwm4kusNHiFKjL6AkxzVLJ4deZCrz6YDyhxq4p/nVt0yd2zD8X9g8+qhswCxWNM/Jg3DIt7h2Yeg1jwdGUmC8Ya+Hto5jQ8aWI7zy5F8JomdD+vWGTXUy+W916z97rXm0SkYV/e3M8+Th5JUfqEAXPfPkTT3Qz7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fsYTiKUMByKP7I84GXZwW9hlEJjiVa5uNAfDYfEJ21E=; b=LyuJIFxZUCRREgLwiEsMrV5d2CWteMozubfm9JRh4nkVrecalY/EGWK9bU8KqFUN5b+T5uJTXsWrmNBLousu+yFMGIr4DV+eT0NJhmO7AdVE5sld74ghOUrpC8uK1ah7HAF40RSDHqBZdfltCv5DaG576pC1ua4LIrIME+4pa0LH775ok6YeZSSVJqowksijpgmi12/KP2+7uvKMYsI+sqa7RVi5idVigmTevdjPrWvT4klj7KS/hqAT0kop+EgiWQcm1Qx9u7DkamFqEdb1nmZyIuautc/3d2d/0jYek59dKMp+dAgMx77eWXrANMXnz1dFv3hxms9ixhN6LG6k/w== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; 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=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Xu , Fabiano Rosas , Pierrick Bouvier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhao Liu , Halil Pasic , "Christian Borntraeger" , Jason Herne , Richard Henderson , Ilya Leoshkevich , David Hildenbrand , Eric Farman , Matthew Rosato , "Cornelia Huck" , Eric Blake , "Vladimir Sementsov-Ogievskiy" , John Snow , Markus Armbruster , Maor Gottlieb , Avihai Horon Subject: [PATCH v2 11/13] vfio/migration: Implement VFIO_PRECOPY_INFO_REINIT feature Date: Tue, 2 Jun 2026 12:26:19 +0300 Message-ID: <20260602092621.382-12-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20260602092621.382-1-avihaih@nvidia.com> References: <20260602092621.382-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC5:EE_|SJ2PR12MB9115:EE_ X-MS-Office365-Filtering-Correlation-Id: a028bf4b-e420-498f-2eb3-08dec0893920 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700016|376014|7416014|1800799024|6133799003|22082099003|18002099003|56012099006|11063799006; X-Microsoft-Antispam-Message-Info: D51MwbyVMKtukMXxeSU+yjmc6niQfgVbWKS/hs8XQceeWEM2rUt0gdWGJS4q5HWEEsNeIN8jO+6Gld3TAj8Aj2Q0nMhYlr6d73rPu6b8R8dVnc4OivBAezDFurn+x4UNUS6KEAfOvq/JZ4d03mKyh2bycMtDPm48cZD3oU8gHJwZ8W+E6+IwyASfWayqA0k0keV1rgZ0+Ty6fFKccrCP/aR5G1Td67zgbShXDIBlhioAkPCIZ7+E6q/rgmk8SSCQ3OSATklbaFKBzs92KnEGcEILPRi4V2UtSGLq2seWCTCiIhnKQ9peGZOEhyyDcLsxBuMALftYU+BlkL+RcqCH1WU2MvgmsEAc8QXnxmMWAllV9nR6M4SmGwqCt7nE/tOuc6rtEYAq/o40F0Mx1HTKf1gx3crFEc1IL2NYKxg5yQiDS95XCyW5xMIGLuhdSGnoc3mObfetU82XOA5Ngi1E7ogRU70cCFwltZPETdutjxgVv5GTQePKOtpzt6kg22hw5/DBwATzmmXo9Shb1rT+ZZoGyZoOFHX+vo0owMet/8NmPe2IV64NoUjeojYqUxWPLi8rkeWcKtZWg33ba2/xNZ8kI5EbV8g+8jWdxVxHOyrA1nks4bCqG3H+nDKXQ8N+xS+R4ctzlQ2skION17ZxGkz168uSDSvZgCtJr9iHAbOyNawX5CoPEpxpUcQIU4cpNG5F86TpXh56BcIKpvACVDQUBvkOdh3k1cnoVOe/nIs= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230040)(82310400026)(36860700016)(376014)(7416014)(1800799024)(6133799003)(22082099003)(18002099003)(56012099006)(11063799006); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dkcQu4bolzQgBBAp8aQwxRVPcbkYDBs+OIizJVSaZH+x9r8pOzx14smEqrIZs0idslV5Avrk/8EEIAFBbPb4FJIaB2Icd/pAFDVlnZwQZ4WtgvINK/tpDuISd0e0ONP7fXnJ1eS2ZkrqxtiE2/OxpVYH8APzS9jmuPZPZw2sFfSrHkk3nA3bGBCaHgfHiJPP5+DshreQip4rvnAo6f/mZ8H6k/N+QORKpextoourYfHN6mlfs8U08RCjCQIQRwVPrPwRd8xggsM8LaMNvW9aZyOS4Bpm1NA7JinfXe5I0YOUs9L+yGcBMzKIZ1Qmn7lbey4sQHC1fttgyi8uaFKnTH9/u1YEu1UWWo1XL1ixvI4q5ZTpv9wLEbOkIvJxrKozueKZu2/Sx+Rf+3RZg2TqkXy8/QzgvPk6Dw+cciLhIwvvxOkTPEPbOsbO0b8wht4J X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2026 09:27:53.3495 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a028bf4b-e420-498f-2eb3-08dec0893920 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCC5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9115 Received-SPF: permerror client-ip=2a01:111:f403:c005::5; envelope-from=avihaih@nvidia.com; helo=CO1PR03CU002.outbound.protection.outlook.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FORGED_SPF_HELO=1, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1780392562989154100 Content-Type: text/plain; charset="utf-8" According to VFIO uAPI, precopy initial_bytes is considered as critical data that should be transferred and loaded prior to moving to STOP_COPY state to ensure precopy phase would be effective. As currently defined, initial_bytes can only decrease as it's being read from the data fd. However, there are cases where a new chunk of initial_bytes should be transferred during precopy. The new VFIO_PRECOPY_INFO_REINIT feature addresses this and allows reporting a new value for initial_bytes regardless of any previously reported values. Implement VFIO_PRECOPY_INFO_REINIT feature: 1. Opt-in for VFIO_DEVICE_FEATURE_MIG_PRECOPY_INFOv2 to make VFIO_PRECOPY_INFO_REINIT available. 2. Request a new switchover ACK if initial_bytes increases post of a previous switchover ACK. This ensures the device is not moved to STOP_COPY before initial_bytes has reached zero again. Signed-off-by: Avihai Horon Acked-by: Peter Xu --- docs/devel/migration/vfio.rst | 14 +++++++ hw/vfio/vfio-migration-internal.h | 1 + hw/vfio/migration.c | 68 ++++++++++++++++++++++++++++--- hw/vfio/trace-events | 4 +- 4 files changed, 80 insertions(+), 7 deletions(-) diff --git a/docs/devel/migration/vfio.rst b/docs/devel/migration/vfio.rst index 854277b11c..f235c2d4f9 100644 --- a/docs/devel/migration/vfio.rst +++ b/docs/devel/migration/vfio.rst @@ -23,6 +23,20 @@ and recommends that the initial bytes are sent and loade= d in the destination before stopping the source VM. Enabling this migration capability will guarantee that and thus, can potentially reduce downtime even further. =20 +For example, in mlx5 devices, the initial bytes hold metadata used for time +consuming pre-allocations of resources on the destination. Although init b= ytes +may be small in size and sending them may take little time, loading them i= n the +destination can take a significant amount of time. Switchover-ack guarante= es +that this pre-allocation doesn't happen during downtime. + +Initial bytes was originally defined to be monotonically decreasing, howev= er +there are cases where a new chunk of initial bytes should be transferred d= uring +precopy, e.g., due to a device reconfiguration, etc. The +VFIO_PRECOPY_INFO_REINIT feature addresses this and when supported, allows= to +report a new initial bytes value regardless of any previously reported val= ues. +In this case, a new switchover ACK will be requested to make sure the new +initial bytes are loaded in the destination before switching over. + To support migration of multiple devices that might do P2P transactions be= tween themselves, VFIO migration uAPI defines an intermediate P2P quiescent stat= e. While in the P2P quiescent state, P2P DMA transactions cannot be initiated= by diff --git a/hw/vfio/vfio-migration-internal.h b/hw/vfio/vfio-migration-int= ernal.h index dc741e5142..a1c58b1126 100644 --- a/hw/vfio/vfio-migration-internal.h +++ b/hw/vfio/vfio-migration-internal.h @@ -45,6 +45,7 @@ typedef struct VFIOMigration { void *data_buffer; size_t data_buffer_size; uint64_t mig_flags; + bool precopy_info_v2_used; /* * NOTE: all three sizes cached are reported from VFIO's uAPI, which * are defined as estimate only. QEMU should not trust these values diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 2296d0d44b..caf4d5e19f 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -373,9 +373,11 @@ static int vfio_query_stop_copy_size(VFIODevice *vbase= dev) =20 static int vfio_query_precopy_size(VFIOMigration *migration) { + VFIODevice *vbasedev =3D migration->vbasedev; struct vfio_precopy_info precopy =3D { .argsz =3D sizeof(precopy), }; + bool reinit =3D false; int ret =3D 0; =20 if (ioctl(migration->data_fd, VFIO_MIG_GET_PRECOPY_INFO, &precopy)) { @@ -383,25 +385,43 @@ static int vfio_query_precopy_size(VFIOMigration *mig= ration) migration->precopy_dirty_size =3D 0; ret =3D -errno; warn_report_once("VFIO device %s ioctl(VFIO_MIG_GET_PRECOPY_INFO) " - "failed (%d)", migration->vbasedev->name, ret); + "failed (%d)", vbasedev->name, ret); } else { bool overflow; =20 migration->precopy_init_size =3D precopy.initial_bytes; migration->precopy_dirty_size =3D precopy.dirty_bytes; + /* + * struct vfio_precopy_info.flags is valid only if + * VFIO_DEVICE_FEATURE_MIG_PRECOPY_INFOv2 is used. + */ + if (migration->precopy_info_v2_used) { + reinit =3D precopy.flags & VFIO_PRECOPY_INFO_REINIT; + } =20 - overflow =3D vfio_migration_check_overflow(migration->vbasedev, + overflow =3D vfio_migration_check_overflow(vbasedev, migration->precopy_init_size, "precopy init size= "); - overflow |=3D vfio_migration_check_overflow(migration->vbasedev, + overflow |=3D vfio_migration_check_overflow(vbasedev, migration->precopy_dirty_size, "precopy dirty siz= e"); if (overflow) { ret =3D -ERANGE; } } =20 - trace_vfio_query_precopy_size(migration->vbasedev->name, - migration->precopy_init_size, - migration->precopy_dirty_size, ret); + trace_vfio_query_precopy_size(vbasedev->name, migration->precopy_init_= size, + migration->precopy_dirty_size, reinit, r= et); + + /* + * If we got new initial_bytes after previous initial_bytes were + * transferred, request a new switchover ACK. Don't request if legacy + * switchover-ack is used. + */ + if (reinit && migration->initial_data_sent && + !migrate_switchover_ack_legacy()) { + migration->initial_data_sent =3D false; + migration->request_switchover_ack =3D true; + trace_vfio_query_precopy_size_request_switchover_ack(vbasedev->nam= e); + } =20 return ret; } @@ -1053,6 +1073,27 @@ static int vfio_migration_query_flags(VFIODevice *vb= asedev, uint64_t *mig_flags) return 0; } =20 +/* Returns 1 on success, 0 if not supported and negative errno on failure = */ +static int vfio_migration_set_precopy_info_v2(VFIODevice *vbasedev) +{ + uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature), + sizeof(uint64_t))] =3D {}; + struct vfio_device_feature *feature =3D (struct vfio_device_feature *)= buf; + + feature->argsz =3D sizeof(buf); + feature->flags =3D + VFIO_DEVICE_FEATURE_SET | VFIO_DEVICE_FEATURE_MIG_PRECOPY_INFOv2; + if (ioctl(vbasedev->fd, VFIO_DEVICE_FEATURE, feature)) { + if (errno =3D=3D ENOTTY) { + return 0; + } + + return -errno; + } + + return 1; +} + static bool vfio_dma_logging_supported(VFIODevice *vbasedev) { uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature), @@ -1074,6 +1115,7 @@ static int vfio_migration_init(VFIODevice *vbasedev, = Error **errp) char id[256] =3D ""; g_autofree char *path =3D NULL, *oid =3D NULL; uint64_t mig_flags =3D 0; + bool precopy_info_v2_used =3D false; VMChangeStateHandler *prepare_cb; =20 if (!vbasedev->ops->vfio_get_object) { @@ -1105,12 +1147,22 @@ static int vfio_migration_init(VFIODevice *vbasedev= , Error **errp) return -EOPNOTSUPP; } =20 + if (mig_flags & VFIO_MIGRATION_PRE_COPY) { + ret =3D vfio_migration_set_precopy_info_v2(vbasedev); + if (ret < 0) { + error_setg_errno(errp, -ret, "failed to set precopy info v2"); + return ret; + } + precopy_info_v2_used =3D ret; + } + vbasedev->migration =3D g_new0(VFIOMigration, 1); migration =3D vbasedev->migration; migration->vbasedev =3D vbasedev; migration->device_state =3D VFIO_DEVICE_STATE_RUNNING; migration->data_fd =3D -1; migration->mig_flags =3D mig_flags; + migration->precopy_info_v2_used =3D precopy_info_v2_used; =20 vbasedev->dirty_pages_supported =3D vfio_dma_logging_supported(vbasede= v); =20 @@ -1133,6 +1185,10 @@ static int vfio_migration_init(VFIODevice *vbasedev,= Error **errp) migration_add_notifier(&migration->migration_state, vfio_migration_state_notifier); =20 + trace_vfio_migration_init(vbasedev->name, migration->mig_flags, + migration->precopy_info_v2_used, + vbasedev->dirty_pages_supported); + return 0; } =20 diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 50722eb717..464c28c860 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -158,11 +158,13 @@ vfio_load_state_device_buffer_starved(const char *nam= e, uint32_t idx) " (%s) idx vfio_load_state_device_buffer_load_start(const char *name, uint32_t idx) "= (%s) idx %"PRIu32 vfio_load_state_device_buffer_load_end(const char *name, uint32_t idx) " (= %s) idx %"PRIu32 vfio_load_state_device_buffer_end(const char *name) " (%s)" +vfio_migration_init(const char *name, uint64_t mig_flags, bool precopy_inf= o_v2_used, bool dirty_pages_supported) " (%s) mig_flags 0x%"PRIx64", precop= y_info_v2_used %d, dirty_pages_supported %d" vfio_migration_realize(const char *name) " (%s)" vfio_migration_set_device_state(const char *name, const char *state) " (%s= ) state %s" vfio_migration_set_state(const char *name, const char *new_state, const ch= ar *recover_state) " (%s) new state %s, recover state %s" vfio_migration_state_notifier(const char *name, int state) " (%s) state %d" -vfio_query_precopy_size(const char *name, uint64_t init_size, uint64_t dir= ty_size, int ret) " (%s) init %"PRIu64" dirty %"PRIu64" ret %d" +vfio_query_precopy_size(const char *name, uint64_t init_size, uint64_t dir= ty_size, bool reinit, int ret) " (%s) init %"PRIu64", dirty %"PRIu64", rein= it %d, ret %d" +vfio_query_precopy_size_request_switchover_ack(const char *name) " (%s)" vfio_query_stop_copy_size(const char *name, uint64_t size, int ret) " (%s)= stopcopy size %"PRIu64" ret %d" vfio_save_block(const char *name, int data_size) " (%s) data_size %d" vfio_save_block_precopy_empty_hit(const char *name) " (%s)" --=20 2.40.1 From nobody Mon Jun 8 03:21:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1780392529; cv=pass; d=zohomail.com; s=zohoarc; b=GYlXtCHrjVfMnJ7nKa0eCy7uzGrzQXbBME+9vUmoDg3CNUlM06A9vWiexPNoGvOPA/6PeONMxrR9ywh0QcOQKKVvrfmtyEkWJA6/GVPWMwY+bBJc6C3j4G6F+NsNaPg56L7ZgabMhb5XP4zDRTw46f1Q/pRRdDMa4QhvKzOWm9M= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780392529; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Qu93yVOgC35sG2E8DqzOlMYk43cCrBS+gVFG0Fr2HIs=; b=ZbOahyi6SakqoBRK0QD1gOg0ywM+yx/6NTxCKt8qAIuOiAGSxClBuaPgnyHv6c7TVDccH+6hbxhAv1rWBagvpckmj95deOXaF6Jt1v01T3zp4MbUvx7eHPCFtLTmvDPxxmLKoS+VKS8i/Nhgq4ZwxdTtvlZ9ULvI8bI46ZniiZI= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17803925294251007.918186816925; Tue, 2 Jun 2026 02:28:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wULQC-0006dE-Ru; Tue, 02 Jun 2026 05:28:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULPs-0006Qv-3e for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:28:13 -0400 Received: from mail-eastusazlp170120007.outbound.protection.outlook.com ([2a01:111:f403:c101::7] helo=BL0PR03CU003.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULPo-0004Kj-MQ for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:28:07 -0400 Received: from CH0PR03CA0449.namprd03.prod.outlook.com (2603:10b6:610:10e::25) by SA0PR12MB7004.namprd12.prod.outlook.com (2603:10b6:806:2c0::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.71.16; Tue, 2 Jun 2026 09:27:58 +0000 Received: from CH2PEPF00000140.namprd02.prod.outlook.com (2603:10b6:610:10e:cafe::a0) by CH0PR03CA0449.outlook.office365.com (2603:10b6:610:10e::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.71.17 via Frontend Transport; Tue, 2 Jun 2026 09:27:58 +0000 Received: from mail.nvidia.com (216.228.117.160) by CH2PEPF00000140.mail.protection.outlook.com (10.167.244.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.5 via Frontend Transport; Tue, 2 Jun 2026 09:27:58 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:27:46 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:27:45 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Tue, 2 Jun 2026 02:27:40 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JELrmkWevqrCKUANEEQ8KEHqvznXNwaNMwGUR3VjWAISNA/oAtbLmwKTXv70aw4NaqEmcRunh4pKBOgBvh6y/IPYvDFGnMGelRySjZcIMJpAsD1/CvOEU+t5drBZrCWKeH172Msy8jwUxGBzrtnDA14Q8nbPe5VtMe6ot56tZ+Z54fxgKNCRk8fXUV1dEWWldZoNcaOmfS45wdGWnq83RljUUzpfQP1yC87OSmZTwSJpni9uuzJwgi6VF5+gtUPS3/P7IshyTgdGxkq/nMu81G/LjjeQ085JA0JUn9VH1mcF0/GxTj6YQbXF6boo2OaWb/tUYGj8KG6reTTxfuVY/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Qu93yVOgC35sG2E8DqzOlMYk43cCrBS+gVFG0Fr2HIs=; b=xZLfVdyLT7cWWoluE0kSUya8nJRNX7fEgEb9u6c2UuSkXDuZQcFVLzPswnO7atdKhdTlTXr5EepjSkHmzfMIG9KRsHBNUd0QaV9yIcZM0s6kqNSM8msVbq/aPalWgtG0T9h1H25aRckAOMQxi6BJg7TvXUrbut9jpoScXMtzk0nNdQnm0UmmoCi9UNVr57iSejkT1FjE8XDY3HMkdZWlWmBqqsA7M0uPpB2eA1Gc5cqG6cPNVVkl/YzEdh/5P8BdXR9nRiJjohLNrMpfn5YedXps5WWkxT0zGpyLuLFD+gQQZK6bo3VXn/B4szKwSz6yQGZgc3+PuQAVSXjDUjvCSg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Qu93yVOgC35sG2E8DqzOlMYk43cCrBS+gVFG0Fr2HIs=; b=n7y1KRNIUEAv7ZalY8RuZzRgmaIJ10RVVea5wi7TWoPm72ikpsG+daCjujULPUueydv0ph6t9a/7NM/FHkeW7TIhVh05UD0Tf5DC7aI1Fh+3jVzwWMQ7+lGkfdGAoxrZbQH/U268KvGzmRzi/lxXRLkJlYwlDQGBe+ZUmC5pfeXmn+ecmKp9dpVjdtIzlO1QGUE1Qdtulm8QZHUjiuvpnqJQcO/LNgMvUCCnKQl8uaXk+nh9T441grT50pmuZsxK/BxYJ+iSuKg803OCh9nzAOrKT1v1Ms/73j8Set99st8LO8B+hIAshZRtPqiEQDaqNMc6EB+tOFmcba7yIWr7GQ== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; 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=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Xu , Fabiano Rosas , Pierrick Bouvier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhao Liu , Halil Pasic , "Christian Borntraeger" , Jason Herne , Richard Henderson , Ilya Leoshkevich , David Hildenbrand , Eric Farman , Matthew Rosato , "Cornelia Huck" , Eric Blake , "Vladimir Sementsov-Ogievskiy" , John Snow , Markus Armbruster , Maor Gottlieb , Avihai Horon Subject: [PATCH v2 12/13] vfio/migration: Check VFIO_PRECOPY_INFO_REINIT during switchover Date: Tue, 2 Jun 2026 12:26:20 +0300 Message-ID: <20260602092621.382-13-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20260602092621.382-1-avihaih@nvidia.com> References: <20260602092621.382-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000140:EE_|SA0PR12MB7004:EE_ X-MS-Office365-Filtering-Correlation-Id: 37b97361-a5ed-4a0a-7e1c-08dec0893c08 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700016|82310400026|376014|7416014|1800799024|18002099003|22082099003|56012099006|11063799006; X-Microsoft-Antispam-Message-Info: CjhfiIl94IwPKcI/qnzGXHQqifKccRDiDS6fR1x5Mb8M7o1CVcCUA8wvmAarH4BPMoGrVoIvqAM+Fu0qymnP1tn48gSlYHfviG7jeXEU1jcCuTasPTurbke7JrF2aVHRryAEEkhHFgYZNzHmWI0hTSA8ZvDz990EaUnC4Lq+g9udDiRr8I9gDf/SQdApQqaEuD4ndC2VqKCUzwu9R4EsuGVeh6mi30uG1xJN1/otRdN8Ilnb41uwI9fJYufGrCUfjHDLYjetFw8PwZDh+duVX7brKucbYMXUe2GoYShv9F8+vH/+JeAlIRGHWaAb+qrgQWER5CmProoS2hxR/lR1WA/6ltvN4hUHtDTCqSw5/fvm9J7dgIVJeuhcdzy9B4wLtvJrTY0AtiTjGCJTAZUPtp6brb4cENbL5p38+1DJkZ3X4s6nMK0kkMaAY3rMyHhCwPP2lUXWkUWVuSuaeXS9eHUheTSX9UhGVLAuLdR3WuNkDOxz4C/Vasf50gAoBb0ZczC7OjqG0N1QxlOvB7gSqpmkDYgfodxzQJxs5qdcRZqHfN6rX4n/SIQNCCNu6s8MSiER7MZPeKRINR5/Slx/o/SDQABaVokSXpDUPxCjJx9NhngdxNDWwYj5RF3JOSbQlURH6bmuJzzdEOUbG0nR2I9134pmTYg1XdtyyuwWcLYbmWmCZEUXRU402WSIvwOSacs0yn1MS/VcQHlVNPkrOIVlcOBoqbPnn6FVaTob4/E= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(36860700016)(82310400026)(376014)(7416014)(1800799024)(18002099003)(22082099003)(56012099006)(11063799006); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RGqygJM/FWxyQsZFJ7EMznTiCf+z+aoWjv5GA8PVf0RjHUHi384LL1W5VempjTzZjpJBskNKnjkG4oIZ6nWJXGmBiiBwqj73veRSi2ZUiD/n2EjE0ghQ+KrLNxoF8+2VscRdJKzzI95/XVGCOoDEEFLAQa5upDmqlIvbSr0Jl1rtHhzs1BGZpSTeQOtrjstWZ745U0qMpp7HmkBwT9Z4VfyWquKxkLepWp4keEBA3soH3e7R9GqIM9Dd68v4ipj9TuikYdFU74ryf8sEgDTAePaY/Q6YsdvBHxl5MoAgGgMDncwuhDRi0rmXuq0Jp24Wr8T5Eiyla3FbPuAZa7TZnV/sLHseebU9jS0cmEAAswRACDL9SxNYFcBuJolqGeeEUvob667SPMmeI6a1LC28URYlgll1XHvbnMerwJGDtwyHiAXUITSGttHLshbsfsqJ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2026 09:27:58.1917 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 37b97361-a5ed-4a0a-7e1c-08dec0893c08 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF00000140.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB7004 Received-SPF: permerror client-ip=2a01:111:f403:c101::7; envelope-from=avihaih@nvidia.com; helo=BL0PR03CU003.outbound.protection.outlook.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1780392532465154100 Content-Type: text/plain; charset="utf-8" VFIO_REPCOPY_INFO_REINIT is checked only during precopy, before the switchover decision. However, the switchover decision and guest stop are not atomic, so a VFIO device may want to set VFIO_PRECOPY_INFO_REINIT and request another switchover ACK in the gap after switchover decision has been made but before the guest is stopped. This would be missed and may increase downtime. Solve this by checking if VFIO_PRECOPY_INFO_REINIT was set during that gap, and request a new switchover-ack in the final save_state_pending call. Query precopy info after vCPUs are stopped but before transitioning from PRE_COPY state, when its valid to call the ioctl. Signed-off-by: Avihai Horon --- hw/vfio/migration.c | 41 +++++++++++++++++++++++++++++++++++------ hw/vfio/trace-events | 2 +- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index caf4d5e19f..f1480fc4cc 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -681,11 +681,11 @@ static void vfio_state_pending(void *opaque, MigPendi= ngData *pending, uint64_t precopy_size, stopcopy_size; bool request_switchover_ack =3D false; =20 - if (final) { - return; - } - - if (exact) { + /* + * Skip sync in final query as sync for precopy (which is needed for + * switchover-ack) was already done during guest stop. + */ + if (exact && !final) { vfio_state_pending_sync(vbasedev); } =20 @@ -709,7 +709,7 @@ static void vfio_state_pending(void *opaque, MigPending= Data *pending, trace_vfio_state_pending(vbasedev->name, migration->stopcopy_size, migration->precopy_init_size, migration->precopy_dirty_size, - request_switchover_ack, exact); + request_switchover_ack, exact, final); } =20 static bool vfio_is_active_iterate(void *opaque) @@ -963,6 +963,26 @@ static const SaveVMHandlers savevm_vfio_handlers =3D { =20 /* ---------------------------------------------------------------------- = */ =20 +static void vfio_final_precopy_reinit_check(VFIODevice *vbasedev) +{ + VFIOMigration *migration =3D vbasedev->migration; + int ret; + + if (!migration->precopy_info_v2_used || !migrate_switchover_ack() || + migrate_switchover_ack_legacy()) { + return; + } + + ret =3D vfio_query_precopy_size(migration); + if (ret) { + error_report("%s: Final precopy reinit check failed (err: %d)", + vbasedev->name, ret); + /* If query failed, assume reinit and request switchover-ack */ + migration->request_switchover_ack =3D true; + migration->initial_data_sent =3D false; + } +} + static void vfio_vmstate_change_prepare(void *opaque, bool running, RunState state) { @@ -976,6 +996,15 @@ static void vfio_vmstate_change_prepare(void *opaque, = bool running, VFIO_DEVICE_STATE_PRE_COPY_P2P : VFIO_DEVICE_STATE_RUNNING_P2P; =20 + if (migration->device_state =3D=3D VFIO_DEVICE_STATE_PRE_COPY) { + /* + * Now that vCPUs are stopped, check if new init_bytes are availab= le + * since switchover decision, to be reported in the final + * save_query_pending. + */ + vfio_final_precopy_reinit_check(vbasedev); + } + ret =3D vfio_migration_set_state_or_reset(vbasedev, new_state, &local_= err); if (ret) { /* diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 464c28c860..3fbc32cb3a 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -178,7 +178,7 @@ vfio_save_iterate(const char *name, uint64_t precopy_in= it_size, uint64_t precopy vfio_save_iterate_start(const char *name) " (%s)" vfio_save_setup(const char *name, uint64_t data_buffer_size) " (%s) data b= uffer size %"PRIu64 vfio_send_init_data_flag(const char *name) " (%s)" -vfio_state_pending(const char *name, uint64_t stopcopy_size, uint64_t prec= opy_init_size, uint64_t precopy_dirty_size, bool request_switchover_ack, bo= ol exact) " (%s) stopcopy size %"PRIu64", precopy initial size %"PRIu64", p= recopy dirty size %"PRIu64 ", request switchover ack %d, exact %d" +vfio_state_pending(const char *name, uint64_t stopcopy_size, uint64_t prec= opy_init_size, uint64_t precopy_dirty_size, bool request_switchover_ack, bo= ol exact, bool final) " (%s) stopcopy size %"PRIu64", precopy initial size = %"PRIu64", precopy dirty size %"PRIu64 ", request switchover ack %d, exact = %d, final %d" vfio_vmstate_change(const char *name, int running, const char *reason, con= st char *dev_state) " (%s) running %d reason %s device state %s" vfio_vmstate_change_prepare(const char *name, int running, const char *rea= son, const char *dev_state) " (%s) running %d reason %s device state %s" =20 --=20 2.40.1 From nobody Mon Jun 8 03:21:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1780392519; cv=pass; d=zohomail.com; s=zohoarc; b=bKHqCrgz/DsC3pJenpTRYwFyltFzKi7nugYAEITduFWl6rJm8pb2MEXxzjqOnIS5Z0XMeZYBNTz6R/EWlM0zB6UZ2/nG7d7U7+FCEJKcWYBC07q1uUtesqJgMhxkNAiEg2rNBxNck6ZsZlyoMMWPD2c3TzMACJayQwN/lAmxt10= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780392519; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IAPf6ypRI91bWzxqxMgh6cVCnam81mpqg/BkfFaWtas=; b=YmSAVI3acfgzLNwFvYMAdVpNCk8l7ffFDx//tg8RK94g0G2MfpfWFo/fluRaFeAXfjXACRvu03+ssZVOLwtVzX3Sy7kDSbXeD+LLDILfNPCovvsXQkVVWRo+28M+GKolFpCNvZmIpvFa3dkTXeMyK4IH80FIGITfh/T/s8edbA4= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780392519869322.3266551980315; Tue, 2 Jun 2026 02:28:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wULQJ-0006sU-AJ; Tue, 02 Jun 2026 05:28:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULQ7-0006cy-DH for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:28:25 -0400 Received: from mail-northcentralusazlp170130007.outbound.protection.outlook.com ([2a01:111:f403:c105::7] helo=CH4PR04CU002.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wULQ0-0004Lt-A5 for qemu-devel@nongnu.org; Tue, 02 Jun 2026 05:28:21 -0400 Received: from CH0PR03CA0271.namprd03.prod.outlook.com (2603:10b6:610:e6::6) by LV2PR12MB5896.namprd12.prod.outlook.com (2603:10b6:408:172::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.7; Tue, 2 Jun 2026 09:28:09 +0000 Received: from CH2PEPF0000013E.namprd02.prod.outlook.com (2603:10b6:610:e6:cafe::54) by CH0PR03CA0271.outlook.office365.com (2603:10b6:610:e6::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.92.7 via Frontend Transport; Tue, 2 Jun 2026 09:28:08 +0000 Received: from mail.nvidia.com (216.228.117.160) by CH2PEPF0000013E.mail.protection.outlook.com (10.167.244.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.5 via Frontend Transport; Tue, 2 Jun 2026 09:28:08 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:27:52 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 2 Jun 2026 02:27:52 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Tue, 2 Jun 2026 02:27:46 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=abu+1dFF7Hw3Y/SX1ULKrZDTuz7Ihl/L4A/58avsDmZhndWFU2zVC7DTnh0HR/Vmji+34CvxkMX63F5C6hyagukDOB6hzrZ7FCL9q3Hhnei2KI4lYKsc65mVcAcbjuZXqV0jrSeyYoP12nyfKWODlyrk3lvX52Fe1Uz7AYdP8IhEs2M8JmX1cAjPdphx3+LJUMRSnLBqa5A7rT56cpfueaWm/QE4lcxJguftza5l0A1UD1vN7ypC83S1ci/Pw6PgPilcH8LQYsM5a941L6JWU2kTTf8tcGQqk+pezP2TbwenEDijf5PbEOfy7UGPCBOAL6hObKRH7ek4VxJIisNxQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IAPf6ypRI91bWzxqxMgh6cVCnam81mpqg/BkfFaWtas=; b=x+imQyjgVZmbbEH4ZQlNDiRfYw9CiQyg+7hlU+MV1IrWx1GhlWse93coVoUERXg7QDTXSzOJmcAt3DMKbj8Iuu93bU0Y1RKW+8RTMQ3+9Id3jrcASvhMGux+4zXmFtwXLe+xPq5wkszRAcSUkP8B5ptdWsht1DrthS715we4h3J/ZNQc960Vjcj0cdPnbt3DbhuNV+dXcycaz5tWvnLmYwcHcImja6WHovh+Ktw2AOuOtu+AGEfEQfnz6sMIfaAvVs+fgbQgnP2I/s5fWw6iSaK6fj27QHB7KRcwmrBAq++Ag69+0nNwd2HLqzoswKMDC9DzHkwvqf3+oVl8JUE9Eg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IAPf6ypRI91bWzxqxMgh6cVCnam81mpqg/BkfFaWtas=; b=PYru4trsxyc2OL3WQXGD6S9MR8iglRgTDV09WrNKPgUCFdxsaPeDLObyGn2v/P5Tt1c9rbZjPYZc/0cNKZom+gMgpV+P1w7AkswEvxUiMRVyHkyalerTV95o7By/d/IUP5qrP5tClbnLUP7BWP7fGiKYrsJGeJzaB8vnet7yww+AFxFxoV6l0EgdAQD0mFESQY70R6eFt1kIVWHMzO161337MvKzOJcrwJQB/6U7Kx4KN/3B0mmbcwaBzel0bng69TLPavgkyU11FsgzGtQjSFx2yxYcU8BaIignkm5KSTFzy06Iq3dJ9ADkIssjvkNVO8HjDZ4TG7JrsLoDbhotHg== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; 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=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Xu , Fabiano Rosas , Pierrick Bouvier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhao Liu , Halil Pasic , "Christian Borntraeger" , Jason Herne , Richard Henderson , Ilya Leoshkevich , David Hildenbrand , Eric Farman , Matthew Rosato , "Cornelia Huck" , Eric Blake , "Vladimir Sementsov-Ogievskiy" , John Snow , Markus Armbruster , Maor Gottlieb , Avihai Horon Subject: [PATCH v2 13/13] migration: Enable new switchover-ack Date: Tue, 2 Jun 2026 12:26:21 +0300 Message-ID: <20260602092621.382-14-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20260602092621.382-1-avihaih@nvidia.com> References: <20260602092621.382-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF0000013E:EE_|LV2PR12MB5896:EE_ X-MS-Office365-Filtering-Correlation-Id: 7b9a00ce-51e8-44d9-6b1c-08dec089423a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|36860700016|82310400026|1800799024|56012099006|11063799006|3023799007|22082099003|18002099003|6133799003; X-Microsoft-Antispam-Message-Info: wCo9XQg+Pkk0Urzsx8rClsIbpuzKaVQIas1YYXiBTSFhwEs/WMlxv31p3ehgsVxR+Vqu4Cc8XhYoI705VSFVHIfImEcluQxW3rTKlSc++Jn4Na8tT2J5r0a5uVATCcW06BTxb2h+rBX/Qzq8ZaXADCTxqhdj/hMrcu9VApe7nqrhbdyavp6iE1aa4mqkf9DgcBG9iZuuRcRJ1Y3kdV0oLtwWX297x223ByRNNQIK3N5Df2Fm2wvCLi/ZKYEyTi2Zb1d++bfW/JjjunhRMMC9LWOFIokyV9qrOEurj0jkugNx1ZSr57oLCKz0On9QqhoBEjLODP1yLQZPt7xrQ7s2O9G55GHAm2uk7rx98AdUKT7FqruUM6K/QhcxPPHCsEmUs4du5Lg80i4ZABN1ibDLn32wl6VVyjekGAfzP/YicEI1MY/tLWXKg9NCVD0GrDEvWOJ2aY1f0RMqXwaMWBdhyAj5XtPdjGJi1HrEbdZ6GRm4WOllKjUxcOwKLbxSxTJQkhhtpLvOJCmi7/YC8EnhGktNktvrh7BqAHxMHrRjpkqUncBg4veau/YoJZFUQOWbpVVllVp6agASFogRy7nVWHk8VUSdHGBEqXhUb+8B4PBQo1QFNcbJWYYPzHYVZ30ef4OnM2WavAbHH+td2DNEmN1ffZite2Iv3/smzmDmezxOW8dWjG7X9IbILS3y/1ESq1Fl3vNpO2WoueQnUWWXlMu8UqIW/Aw8Bt1HMfKleUA= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(376014)(7416014)(36860700016)(82310400026)(1800799024)(56012099006)(11063799006)(3023799007)(22082099003)(18002099003)(6133799003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TayJ5pG8ipoDmF1TZ94wWOzPkZpJz4j4nmb/obEU+5KliDh0iJk/QF/sNZSY44Hnp2C48r9Z4ggXJFW1X73TBCunby9/advneShExJ7FIpyzY/ZyQmUUGomHDbT4GkLjek+yWmxvIK4/FYZ5pUN/vq8/m2ZS4PvxFv7rccL/iBRzXVL+229I0UPdwy3ofZBVpPNAwbhCw+JtLgW4oHhY37mAI0OJPrpR8RsM0lLr7RQixboaaJ8fUGvcb7jgVBLS64S+LNiVUSqcDRGkCQ0HWPQQead0JLQXf1b8SSYfswesyijlGOEVhbaFyAkLJVs+s06mE+ajs/QJPB4Wg8JitWujjczgApRiG6UHfVo53Gtgh+xkLFEw2UnDDbzzWvBs7UlStoJqHq8ttzRv89dB5o1tAJ8pSGpK9B4634vhQep9GzW6ND9A+uTOIYoMp8uY X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2026 09:28:08.5811 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7b9a00ce-51e8-44d9-6b1c-08dec089423a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF0000013E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5896 Received-SPF: permerror client-ip=2a01:111:f403:c105::7; envelope-from=avihaih@nvidia.com; helo=CH4PR04CU002.outbound.protection.outlook.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FORGED_SPF_HELO=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1780392522333154100 Content-Type: text/plain; charset="utf-8" Now that VFIO has implemented new switchover-ack, enable it. Signed-off-by: Avihai Horon --- migration/options.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/migration/options.c b/migration/options.c index 4c9b25372e..dfce19405d 100644 --- a/migration/options.c +++ b/migration/options.c @@ -110,9 +110,8 @@ const Property migration_properties[] =3D { preempt_pre_7_2, false), DEFINE_PROP_BOOL("multifd-clean-tls-termination", MigrationState, multifd_clean_tls_termination, true), - /* Use legacy until VFIO implements new switchover-ack */ DEFINE_PROP_BOOL("switchover-ack-legacy", MigrationState, - switchover_ack_legacy, true), + switchover_ack_legacy, false), =20 /* Migration parameters */ DEFINE_PROP_UINT8("x-throttle-trigger-threshold", MigrationState, --=20 2.40.1