From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <010701a12148c89d-69f1afc1-10cb-447f-a877-7247b26b9b35-000000@eu-central-1.amazonses.com> Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11020086.outbound.protection.outlook.com [52.101.84.86]) by lore.virtuozzo.com (Postfix) with ESMTPS id 363A88017D for ; Fri, 9 Oct 2026 15:29:44 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TYmKuoCTRBWEoYi6APDQ7SjyIOGUVtrXXzRCR3H2mlJMOivVNmKqrb1hxNR9hPDHQr3HNXEzzfj5Ole7vOmP+VnNpzPho/D5dm54DpaB82ltW9ZeEDxxVDppInubjBfDKzYywn6ADhSZLylqrRpivNjDYgPcQm1klFu2h+u/KqafsGLQhmRun8Gm3hq8dYILnITh1fDxIAxrTPetkGitU+6Z/vSVp1kpV0AMthtTAbiNsfwc8LtMKsVc6kHO6FqQZTFG8jkhR8ZSRvFYmVsAqajkfbgJUtl8I1fYVtAzNL4N+fvebaY7MgfwpqEvkGqSAAwo828Dt62Um9vZLbEKFg== 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=UD+L+ElEgO49WQMUESXvxwV3+R8/dmSvzG80lOl7oEE=; b=BdzeqHQgCRfQyuiJg/k2Zp0G7yMhI2H+u4kK/QvUimuJIeO1+yhMHLKlAixEEanu8DA8jlm9jsZZ2Z06ZyURXCK9MYD3uu4oskEp1u93pAXiVGhtzuabnE+xhpXfzH04D+hsQ/8+zXe8n4CCVtYFI8DaTJU3GrncazxpOxwNllDGoHjiITAIPAY0X4nxbrhWp/9kTlHE7HycvOgU8gAsMtUo1H/oXSgwlYc+jD95BUfEQx7l4wG/CqYA47CgEtTdhRAMEXuVBYQtfZjIEH3wfHvkYuq4rEOIOMkbOSf+zD9+Fs2VErbpFgfYJ56NFI/kBYu3ZT89aPLr5XjKmMBn8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 69.169.224.6) smtp.rcpttodomain=virtuozzo.com smtp.mailfrom=eu-central-1.amazonses.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=sashiko.virtuozzo.com; dkim=pass (signature was verified) header.d=sashiko.virtuozzo.com; dkim=pass (signature was verified) header.d=amazonses.com; arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.onmicrosoft.com; s=selector2-virtuozzo-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UD+L+ElEgO49WQMUESXvxwV3+R8/dmSvzG80lOl7oEE=; b=MQ5+QO3RCgkWrjG17bSuYHf480Q3TuM9TO8uUM9aopCNhGLHuRgmOoUWnXWLpcvKH12d65gGb8BZrWK3N+LyLXOD3l3WYl2H1+H2kyG8jogCXLixJe7nPLbHNFOiiUK925dbv/PHGxDC06DDSSVEOCOu6Hdui4jSMFsHCr8ifMA= Received: from AM0PR10CA0025.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::35) by AM0PR08MB11754.eurprd08.prod.outlook.com (2603:10a6:20b:743::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.522.6; Fri, 9 Oct 2026 15:29:41 +0000 Received: from AM7PEPF00000055.EURPRD83.prod.outlook.com (2603:10a6:208:17c:cafe::6e) by AM0PR10CA0025.outlook.office365.com (2603:10a6:208:17c::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.472.20 via Frontend Transport; Fri, 9 Oct 2026 15:29:40 +0000 Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 69.169.224.6) smtp.mailfrom=eu-central-1.amazonses.com; dkim=pass (signature was verified) header.d=sashiko.virtuozzo.com;dkim=pass (signature was verified) header.d=amazonses.com;dmarc=pass action=none header.from=sashiko.virtuozzo.com; Received-SPF: Pass (protection.outlook.com: domain of eu-central-1.amazonses.com designates 69.169.224.6 as permitted sender) receiver=protection.outlook.com; client-ip=69.169.224.6; helo=b224-6.smtp-out.eu-central-1.amazonses.com; pr=C Received: from b224-6.smtp-out.eu-central-1.amazonses.com (69.169.224.6) by AM7PEPF00000055.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.522.3 via Frontend Transport; Fri, 9 Oct 2026 15:29:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=23yjbh4k34hwzfubhuiim7m4inbd3ick; d=sashiko.virtuozzo.com; t=1791559780; h=Message-ID:From:Subject:To:In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=LJIRwPqJtW1WMa5BFeFKfWjuBybZOwpeYTVYiT8CS30=; b=SIVd3ov39rpk03026ZlGBRTgrmYTbTQ4RmudszMh/jgnmF3+Z9K/shU4vtNDM2VH /4EY1E7a3PK3yyGTrywjjuJI08OfcT7l43o27HUDXOveNy6JAhRjNyAcdhXzuIETF1O ZP1gzHW6ykexS9jcr3BI3AQFNVYFrj5RmCcFbZYzmySAMxAU5BWRysY7OZWWfgb8GPs zXqnXxwmCZ49qzzwStLUpJc2IXdsFZFh8WiRj0zzdRTjbX9bm3r1N0H+OidoFghg7Ea Dh4nsp5OseKt+yaG6OQ1PZY2p2rkZ7/ig+Vv2yOQSjubDlaR3vAaOeLsH9npFv7qlOD oYqWo856sA== DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=qftdzk2dqsatjnlrq4r5brjbihpfcrsh; d=amazonses.com; t=1791559780; h=Message-ID:From:Subject:To:In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date:Feedback-ID; bh=LJIRwPqJtW1WMa5BFeFKfWjuBybZOwpeYTVYiT8CS30=; b=bSpN1C+zsmyuVZw8z4XwpJ6fkX//w0k12v5tpUYY1fSebzFd6ISq6FP/1+sWREZ7 3rZ5YaGLh3Lq57MeqaNykzakvCOjtsKoEYv9S4OOvJE/2/uyckilq21oIGDVjxY2B4H Ugt15mxBBWiSRXK2xKCEGKNSblkWqTfcpPWN0oqM= Message-ID: <010701a12148c89d-69f1afc1-10cb-447f-a877-7247b26b9b35-000000@eu-central-1.amazonses.com> From: no-reply@sashiko.virtuozzo.com Subject: Re: [PATCH QEMU HCI-8.1 16/21] vfio/migration: don't migrate device state during CPR To: Andrey Drobyshev , svt-core@virtuozzo.com In-Reply-To: <20261009-vfio_v1-v1-16-2ae91d5b8048@virtuozzo.com> References: <20261009-vfio_v1-v1-0-2ae91d5b8048@virtuozzo.com> <20261009-vfio_v1-v1-16-2ae91d5b8048@virtuozzo.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 9 Oct 2026 15:29:40 +0000 Feedback-ID: ::1.eu-central-1.2wRQJBpg9g1fGRYexx3dUuYGS25Bux+2TEOx72/m6U4=:AmazonSES X-SES-Outgoing: 2026.10.09-69.169.224.6 X-EOPAttributedMessage: 0 X-EOPTenantAttributedMessage: 0bc7f26d-0264-416e-a6fc-8352af79c58f:0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM7PEPF00000055:EE_|AM0PR08MB11754:EE_ MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: eac07265-d736-4ba3-890a-08df261a230f X-LD-Processed: 0bc7f26d-0264-416e-a6fc-8352af79c58f,ExtAddr X-MS-Exchange-AtpMessageProperties: SA List-Id: svt-core@virtuozzo.com X-MS-Exchange-Transport-Rules-Loop: 1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|704161411799003|9140799003|376014|32142699015|48200799018|61400799027|4113699003|5113699003|55112099003|18002099003|22082099003|16102099003|3023799007|13003099007|5063699009|4143699003|10067099003|56012099006; X-Microsoft-Antispam-Message-Info: 004FpOkA2j6bMgBc9P3z3OtYRtxiN9W4jPZjHD4KLrQO8g1GFcyy9xCjg7y46jcN7jCsn0hZAXTUM59Ot8kbissIfU+ppV006Mq+m0ZeL6SPwMHSETFQnLoIQlqn3BDLBM0p3M691+qP99WNZZ6aAwcXyClhYL2y75xMO84TFQKqvNxFbeybzNBgeTsqJ0xPu6yNTyimzcqRezfxJ5IPqXAXzEbfHan/b8+4JyEqhda1wqeiVmF+NP3IxdXsbAVGNXI6aYnf17GbMsq0u6w2aEFtnTEUVpDdYeNwKYsNdzzfGGuJCD9cORKbMQksrcOX0NgGRrulR8F34B+zB/hlxWYpOZvNah7wT2i3bKEa8FymTOf57HrF8w/1IJHglDEceSJYH3u1z9Ky+iUboYxkw2SQiAzMdxhvffnsy1Io3NNk2TjNUOKxIYix1kg0EOnVgZ2l4O8oMhIg3h8UzNsMByuREP4bDmiCf33pdQdn8AzCuaJI/NnB/ZTMPQeDkkOTbyXY5Lk4FFSQRNyRKiBxQvTT+sXQO1DDVtl76zCxNL+GmgmF6h5RGcp1k2WViVMaUUqOMJ50ZI2CMKMk4S3wDmOymKRXN+yt79NPq/CUxTd1GxEMeWPPAQBS8ODIt/GT82cRsjK05XvNPzw1DPkVDI4QPQXH/MVHwzrqifZq2aGzkRWJZWhGAyapV0rUvwoyHhPAcGqU3qIz+xbBoNlJlzDa7PpbB4ZQTwgpe89DTh0HIl4NA3SleN4ESZ4Dju9qvy6VEylcIgl52u2hOXj6jG9D1WG38apU5hIKSw4wKk6OaRD/201o4A+aMVC82GbR X-Forefront-Antispam-Report: CIP:69.169.224.6;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:b224-6.smtp-out.eu-central-1.amazonses.com;PTR:b224-6.smtp-out.eu-central-1.amazonses.com;CAT:NONE;SFS:(13230040)(704161411799003)(9140799003)(376014)(32142699015)(48200799018)(61400799027)(4113699003)(5113699003)(55112099003)(18002099003)(22082099003)(16102099003)(3023799007)(13003099007)(5063699009)(4143699003)(10067099003)(56012099006);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /13YoYiU8dwwd6qWDF8HpiDWb1Fc7Y9txabPmL1nWD1ua+kaO21MOdA7PVOfV6iFr2lCvLbtEb60vuGZwFPixc59thBSU9SZQIpdUvAo8GnAe7mk3qz9QbEo+W3VJ1wL8RH1gxnXowlI2V6wfG21hZemOErZpJxiU+qhgJJBXnAUejPDx2JG/angS99U8eEkPIH2b79QqaF3ZsCPGAxFw7FTlN5ob7FshQu1HOyRGTMpQRu0iXusr3IpALerjCwoFgp0m6Qvq7XMPrQucfLvJ1jYR+BXTwdFxR55WWJ88yjBCATHFlP0WeukEaH797NdxPQsb7ASQTnhmlLdlgld3BdV9ALgswjfxBBr3JufeOHV+svtil/iPHOcfZgURmES4YtHS7iPbmc/Yo7pE79OWyjeeaqtCu7S07JeZR46eGbKEGxydeCFPDRyJ3X0dZrO X-ExternalRecipientOutboundConnectors: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2026 15:29:40.8568 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eac07265-d736-4ba3-890a-08df261a230f X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-AuthSource: AM7PEPF00000055.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB11754 Thank you for your contribution! Sashiko AI review found 1 potential issue(= s) to consider: - [Medium] vfio/migration: CPR gating via cpr_incoming_needed() reads persi= stent parameters.mode -- commit 1d6b3550509ad85a9b9898cb0af982dc9b67382f Author: Andrey Drobyshev vfio/migration: don't migrate device state during CPR This patch skips VFIO device state migration when the migration mode is cpr-transfer or cpr-exec. It gates the save_state handler, adds an is_active callback, and returns early from the two vmstate-change handlers, all using cpr_incoming_needed(). > diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c > --- a/hw/vfio/migration.c > +++ b/hw/vfio/migration.c [ ... ] > @@ -857,6 +880,10 @@ static void vfio_vmstate_change_prepare(void *opaque= , bool running, > Error *local_err =3D NULL; > int ret; > =20 > + if (cpr_incoming_needed(NULL)) { > + return; > + } > + > new_state =3D migration->device_state =3D=3D VFIO_DEVICE_STATE_PRE_C= OPY ? > VFIO_DEVICE_STATE_PRE_COPY_P2P : > VFIO_DEVICE_STATE_RUNNING_P2P; [Severity: Medium] Can this early return skip the P2P quiesce step outside of an in-flight CPR? cpr_incoming_needed() only checks the configured mode: migration/cpr.c:cpr_incoming_needed() { MigMode mode =3D migrate_mode(); return mode =3D=3D MIG_MODE_CPR_TRANSFER || mode =3D=3D MIG_MODE_CPR_EX= EC; } migrate_mode() uses the incoming mode when set, and otherwise falls back to the persistent parameters.mode: migration/options.c:migrate_mode() { MigMode mode =3D cpr_get_incoming_mode(); if (mode =3D=3D MIG_MODE_NONE) { mode =3D migrate_get_current()->parameters.mode; } ... } On the destination, vm_start() runs in process_incoming_migration_bh() before migration_incoming_state_destroy() calls cpr_set_incoming_mode(MIG_MODE_NONE). After that, only parameters.mode is seen, and it stays cpr-transfer or cpr-exec. A later plain stop or cont on the destination would then return early here and in vfio_vmstate_change(). In that case the device is never moved to STOP and could keep running, and possibly DMAing, while the guest is paused. The same applies if the mode is changed between a stop and the matching start. It also applies if a normal migration is started while the VM is already stopped, where the device would never be moved to STOP_COPY. The gate works in the intended CPR flow. On the source the mode is set before the migrate command, and on the destination incoming_mode is still set during vm_start(). The concern is that these handlers run on every stop and cont, not only during a CPR. > @@ -882,6 +909,10 @@ static void vfio_vmstate_change(void *opaque, bool r= unning, RunState state) > Error *local_err =3D NULL; > int ret; > =20 > + if (cpr_incoming_needed(NULL)) { > + return; > + } > + > if (running) { > new_state =3D VFIO_DEVICE_STATE_RUNNING; > } else { [Severity: Medium] Does this early return leave the tracked migration->device_state out of sync with the VM runstate? The same persistent parameters.mode dependence applies here as in vfio_vmstate_change_prepare(). A stop or cont while parameters.mode is still cpr-transfer or cpr-exec would skip the RUNNING/STOP transition. Is there a per-migration indicator that could be used instead of cpr_incoming_needed()? The commit message says "Use cpr_incoming_needed(), which tells exactly when the device is preserved by CPR, both on the old and the new QEMU side." Is this accurate? cpr_incoming_needed() is used elsewhere for vmstate .needed callbacks, which are evaluated only during a CPR save or load. Here it is used in handlers that run on every stop and cont. The series-final state (patches 17 to 21) leaves these gating sites unchanged: hw/vfio/migration.c in vfio_save_state(), vfio_is_active(), vfio_vmstate_change_prepare() and vfio_vmstate_change(). --=20 Sashiko AI review =C2=B7 https://sashiko.vzint.dev/#/patchset/20261009-vfio= _v1-v1-0-2ae91d5b8048@virtuozzo.com?part=3D16