From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <010701a169c434ae-b27b9d0c-d701-48ba-928a-22999bce39e8-000000@eu-central-1.amazonses.com> Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11021122.outbound.protection.outlook.com [52.101.65.122]) by lore.virtuozzo.com (Postfix) with ESMTPS id 356A08045D for ; Fri, 23 Oct 2026 17:17:12 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DKqnkQMpbjZKe/whjaNGzV0OwM+8xj5OKoth3elz2KwL6vVOXoHov2tBT4eT42tOXvMvn6Xw5xgMXQstOPfdUPuB9po6ZU9sRWoZO6n4CwsU0ER2vuDyzd9T12b9nnQxUEccpYJu7kK8d5i3WgJcCR26tQZY4rH715mDvgmZJ0MZt5+lP7HwJfqbX0kL4vcEPkmf5WytcOqZvELyQ2xpqEvbNplhnha/UGn3m4uct2SLNdLtRC0wsgcVZaqmKnVYRLtWalFOzGpiD+DW9Bbb0ATSGsT5KJXlnwirSAJ3hpvYS/golZDyASbTazCc/mDUcVNSXt0pCIDgw0wktb3shA== 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=ZLLyx0FCzi2fojQzhXHrJsmO04RFTysK5aFqPoA+Q5Y=; b=JrlI7VC+aeZS9MPQFB87asc1qqxV8HXlrPM/ck6Iozks4lOxDWrq0Mt09m8xfCBVDfkpvx3IGO3bY5IPaWNfuI7XJMkcl+Lxwn06to7TYdADiavQ2VjaiTbRK9nlWkfEM0i4vDmvufEZMbCWg37YD8zTG5mZ6UvrmMp4KSGqzasjttkgM/B2NUribBKYaPc4erSPSfO2pxTiD1Ix4kLOTmY3I5QR/wmleJPqoFU8r6jJ5lzVxJqx9wmVw7cVBLUcxnSaxBrRPjtZRKSxgyyeRKko4rZWeJPHVsmUB2JEu1apfDif5h1rDraZkve+mOs0yX0MR9uK/NGyBNrdwudGEA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 69.169.224.5) 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=ZLLyx0FCzi2fojQzhXHrJsmO04RFTysK5aFqPoA+Q5Y=; b=JjqJygffvIn6lpVyb1e1liO1t104RgmTV4qQlc4leoqS+S7VsULy8F6txsOuBBxZfQn1toRpC+BaumaPmlZ5H/VUIw+Xf8uTNLck7eDXBt/0470hQ7y71tNOD/+ELV8SF+fmeh04mbDhcX4xkd8kYv4ULu+Ikvwk1p49r0NLl4s= Received: from PA7P264CA0332.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:39a::10) by AM6PPFAF1314C73.eurprd08.prod.outlook.com (2603:10a6:20f:fff1::b13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.546.16; Fri, 23 Oct 2026 17:17:09 +0000 Received: from MI3PEPF0000848A.eurprd02.prod.outlook.com (2603:10a6:102:39a:cafe::41) by PA7P264CA0332.outlook.office365.com (2603:10a6:102:39a::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.546.19 via Frontend Transport; Fri, 23 Oct 2026 17:17:09 +0000 Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 69.169.224.5) 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.5 as permitted sender) receiver=protection.outlook.com; client-ip=69.169.224.5; helo=b224-5.smtp-out.eu-central-1.amazonses.com; pr=C Received: from b224-5.smtp-out.eu-central-1.amazonses.com (69.169.224.5) by MI3PEPF0000848A.mail.protection.outlook.com (10.167.240.137) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.569.4 via Frontend Transport; Fri, 23 Oct 2026 17:17:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=23yjbh4k34hwzfubhuiim7m4inbd3ick; d=sashiko.virtuozzo.com; t=1792775828; h=Message-ID:From:Subject:To:In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=y77fOBTAopaDEJZ0DWOELJGRlkMyqGzLEzhmg0mQS2M=; b=AX/IpD7GbnOLq5Kh6SVpSjjPP1oQYCfOGna+H+n5ps0x8bGFXfp2nt7fXgKRYfL+ E04E7OgukpNJkae20efz6F7yB4vrry6irEA+pnaIzwVg9WM81kivCOYyA2nzpErkhBD BQI6GPFjxGZLUKRF1bQDVMfp/c2YDUve+fUu8GrY+3N9kCf8aUm147Nw1TydtlmJGdS yskmvPthQdSowOj0trDj6xoN6lSPUNBdEHGjbOCEnJBy+X1yMWpAnUKYlf2gdc+0N/D IiMrCpdeTm9gBBeJzLFeOOgFKJyTHXI/NGcwFsbrt3oqL0qPxZgCsnlzU5bIZA5bYXb 0zwgLxUvlw== DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=qftdzk2dqsatjnlrq4r5brjbihpfcrsh; d=amazonses.com; t=1792775828; h=Message-ID:From:Subject:To:In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date:Feedback-ID; bh=y77fOBTAopaDEJZ0DWOELJGRlkMyqGzLEzhmg0mQS2M=; b=Qzoul5W2EPhlGNZwNCkvTWQEVADQsdxKfONaO9BQhbotXUeWfycwVslAUL/oCL89 1HA8IpVlWVfFJa0ckWQ6t6rDUmGztjBoxAboV0tdV8qak76oH03i6eAZ6J1mrqnpAQ2 5GipObmW3YHdQMo+22QsN2VTAC4ZdAhgNftjOydc= Message-ID: <010701a169c434ae-b27b9d0c-d701-48ba-928a-22999bce39e8-000000@eu-central-1.amazonses.com> From: no-reply@sashiko.virtuozzo.com Subject: Re: [PATCH QEMU HCI-8.1 v5 21/36] migration: Fix crash on second migration when cancel early To: svt-core@virtuozzo.com, Andrey Drobyshev In-Reply-To: <20261023-vfio_v1-v5-21-ba0bf3c6d122@virtuozzo.com> References: <20261023-vfio_v1-v5-0-ba0bf3c6d122@virtuozzo.com> <20261023-vfio_v1-v5-21-ba0bf3c6d122@virtuozzo.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 23 Oct 2026 17:17:08 +0000 Feedback-ID: ::1.eu-central-1.2wRQJBpg9g1fGRYexx3dUuYGS25Bux+2TEOx72/m6U4=:AmazonSES X-SES-Outgoing: 2026.10.23-69.169.224.5 X-EOPAttributedMessage: 0 X-EOPTenantAttributedMessage: 0bc7f26d-0264-416e-a6fc-8352af79c58f:0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MI3PEPF0000848A:EE_|AM6PPFAF1314C73:EE_ MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 11537a80-4ac8-4685-7aac-08df3129784d 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|48200799018|61400799027|32142699015|376014|9140799003|261021121427099003|261022105027099003|261022075727099003|5063699009|56012099006|4143699003|261009223027099003|10067099003|16102099003|18002099003|22082099003|55112099003|10063799003|4113699003|5113699003|13003099007|3023799007; X-Microsoft-Antispam-Message-Info: XUXiHqhuCykqIL2DX01c/ruZrEphowtRIKpZOkFZKwmET00ENSoK9poBt9DZ5LiybXj+5yGf71wam+y54LVfb3klyyyO++4mnG1g3JawopEHyYkFRov3mR5T22Z0y8rs0yABsEAzrk3dUHVi16/Euxs5IvGCoV3zn8JrA608ove6IdsDWx93X2k1o2HprqlQlUdY4G1pyKGAnsQBRbWUU+GbjoLAGWoluF/+aPah29p9MzSnU5PUdp7lOlmbPZ2Fw5Eji7yCZAV22odyIoqccdlSv4p3JsD2t2vRm7XDOXeRJGi2WzZiCMB0+YtB9UiS1N/c3YEwzWdGr3WeEbStDTTmy8jaQn7Nl2sWwF9RyaABTghNSAcwa9ke0TS2iMRjwuC0Ha5hWfSF9n1qi2FKgTsQXw4d8i9c5Oa6BB5skctBNd1SCCnnYqLNzOkYV+mOutEGeZ41jdVsCAgJCVFWqHWDZwIhTGgJIndmVbALDCtnR2sFgiSxrqLdd/aMPUATNt0gcOMFTRAbfCdZg4zPH/pnRjNu8nDqPhaifeUFp5VRcmmzfYrGQWp8TJkKzEPG8TKo5BAie0QPTfXTfPrk7Nr6/EVMkuQpXEdeU0UsKLuosST/QM8RJFcdJmCEVyhPsSCTk/1Lw9IhyMydt+WKJ1z7xvlXRgtjfIPdpTv9O8TASqnHA2iiLPlLvsdpVzk6Zd822GTobSRB8APxb7f09oSBizMhQrsR1XIOAh1fzQy8AbXZv9dBD8Vc9BeX+U4VYbyh078QJh2auaixnve3P00OuDsBPKw73zN+2GOLoVWInCmb+cPx27U29SKKawqNIYfpOCqAUOfqUGxYzBKnm3Lj7frCd2JOvHd1THByVJDG4YbEKxn6eVydWnzA7R+7OQhG+Y+pgUzJz1oufpwv33ayBxrndtlgveqJ324usSE= X-Forefront-Antispam-Report: CIP:69.169.224.5;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:b224-5.smtp-out.eu-central-1.amazonses.com;PTR:b224-5.smtp-out.eu-central-1.amazonses.com;CAT:NONE;SFS:(13230040)(704161411799003)(48200799018)(61400799027)(32142699015)(376014)(9140799003)(261021121427099003)(261022105027099003)(261022075727099003)(5063699009)(56012099006)(4143699003)(261009223027099003)(10067099003)(16102099003)(18002099003)(22082099003)(55112099003)(10063799003)(4113699003)(5113699003)(13003099007)(3023799007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ohmq2mekUR/6vJhLujOQcnYWiEyJLYOZZzZsWI/mFZcKC++mSkdurxDqvgabuxPkP4WKZMXl7QBuaEEig7BIK2abzUne+gMhoan8EIRtaaYirQ5jbMQc2nd3MFfVoEwzOaqHIaKRrrNYdgE/6l0ap4U3ntEtMesmX5PEizCe4U2I/dOg0nNSpAjLdDUl+VWHc7Q9AaQ6BG5w4SQJ2hkS/ftxBeCFSPv20whAzs0B7oEnz6TdJaRviCbTPqFLBAys9/sez72Ns0dS+8jXoMhCzUCTB9WojqExx+bJjhduxesfkx18t2bY/gAUfXZn/s5oz534EUE2kEwDVcoamBiPfO3hIaJDgCslnAUmbyrrApf7imaycBwKkL0noTfsATrfjBWD3h4uGZ1cbhX11QhH2FOllw5/hfdhxSeS3oUT/8bpqtRmidgjUbmlDXmk03OB X-ExternalRecipientOutboundConnectors: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2026 17:17:09.0979 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 11537a80-4ac8-4685-7aac-08df3129784d X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-AuthSource: MI3PEPF0000848A.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PPFAF1314C73 Thank you for your contribution! Sashiko AI review found 1 potential issue(= s) to consider: - [Medium] migration: migration_cancel() asserts migrate_mode()=3D=3DCPR_TR= ANSFER, but mode is mutable -- commit d8e2c80dd170f3a8f2343c0a4b7abbebb7c94fc5 Author: Peter Xu migration: Fix crash on second migration when cancel early This patch makes migration_cancel() call migration_cleanup() when the cpr-transfer HUP gsource is still armed. Before, it used a special case that checked setup && !s->to_dst_file. It also makes qmp_migrate_finish_cb() detach the HUP gsource on entry, and it adds several assertions. Link: https://lore.kernel.org/r/20260417184742.293061-1-marcandre.lureau@re= dhat.com Link: https://lore.kernel.org/r/20260421175820.302795-1-peterx@redhat.com > diff --git a/migration/migration.c b/migration/migration.c > --- a/migration/migration.c > +++ b/migration/migration.c [ ... ] > @@ -1661,14 +1661,19 @@ void migration_cancel(void) > } > =20 > /* > - * If qmp_migrate_finish has not been called, then there is no path = that > - * will complete the cancellation. Do it now. > + * This is cpr-transfer specific processing. > + * > + * If this is true, it means cpr-transfer migration is waiting for t= he > + * destination to send HUP event on CPR channel to continue the next > + * phase. If so, do the cleanup proactively to avoid get stuck in > + * CANCELLING state. > */ > - if (setup && !s->to_dst_file) { > - migrate_set_state(&s->state, MIGRATION_STATUS_CANCELLING, > - MIGRATION_STATUS_CANCELLED); > - cpr_state_close(); > - cpr_transfer_source_destroy(s); > + if (cpr_transfer_source_active(s)) { > + assert(migrate_mode() =3D=3D MIG_MODE_CPR_TRANSFER); [Severity: Medium] Can this assert abort QEMU on a legitimate cancel? assert() is g_assert() here, and migrate_mode() reads s->parameters.mode, which can be changed while the migration is running. migrate_params_apply() writes s->parameters.mode whenever has_mode is set. Neither qmp_migrate_set_parameters() nor migrate_params_check() rejects that while a migration is running. The hup_source is armed in qmp_migrate() while migrate_mode() is MIG_MODE_CPR_TRANSFER, and the mode is not latched at that point: if (migrate_mode() =3D=3D MIG_MODE_CPR_TRANSFER) { cpr_transfer_add_hup_watch(s, qmp_migrate_finish_cb, addr); } A possible sequence is: migrate (mode=3Dcpr-transfer) -> hup_source armed, state is SETUP migrate-set-parameters mode=3Dnormal (or cpr-exec) migrate_cancel -> migration_cancel() migration_cancel() sees cpr_transfer_source_active(s) true, but migrate_mode() no longer returns MIG_MODE_CPR_TRANSFER, so the assert fails. The same assert would also run from migration_shutdown() at QEMU exit, and from the ram.c resize-during-precopy path, if the mode was changed in the window. The window lasts until the destination closes the CPR channel. The old check was only setup && !s->to_dst_file. The new check makes the cancel path depend on a user-mutable parameter. Would it be better to drop this assert, or to record the mode when hup_source is armed and check that instead? > + assert(setup && !s->to_dst_file); > + migration_cleanup(s); > + /* Now all things should have been released */ > + assert(!cpr_transfer_source_active(s)); > } > } --=20 Sashiko AI review =C2=B7 https://sashiko.vzint.dev/#/patchset/20261023-vfio= _v1-v5-0-ba0bf3c6d122@virtuozzo.com?part=3D21