From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <010701a15a2d5173-d2e7feff-3bf6-4bbf-9d26-a4466df9c9b2-000000@eu-central-1.amazonses.com> Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11020102.outbound.protection.outlook.com [52.101.84.102]) by lore.virtuozzo.com (Postfix) with ESMTPS id 50DDA8045D for ; Tue, 20 Oct 2026 16:38:05 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MldxlJeP3bEh1jSShyr2XH7+43rJ16gCNxoiT7L/wNXxOsc/9cngxxTfH58BZlOvH9x/L+Bk/wjuK5dbYg17FUCSl4P26Hs7rvtac7YUTKUwz7Wo/VgVaFLG7Ttw69oKjp0h7Ix4FArnXvs33nddFb75SrgIVGVHHWl9C9X2A70TzKL2ZqtYjSS4ByyS9B6qV78joM7ludJp3gosTxhqTDWB1sTwpr9iazJL1iFtoU8RXVqWpQidXuvbmuljos35md8iu7d7nttJ7KhoXDruI9rvzEeZtRwAV0TmfjVmqiHS1hlmxYOuYMA2sZc9tfsYVGR0KeR+kMb4rHVmlgNO9A== 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=xzewjp/de+Ym3uRqhQA2+ikPwdVnfeNtyPxTfF+dISg=; b=D0pLZMLCX3So4tNhHGS5FCTW+yRcJt0IpKRcSJ2D0SoaPnL8todKuE42WiYjnyaXgrmMkhUquBpUyj9LS00pdvA8f2z+UuHKm+YIFJVCqNaMuDOW5HAo47k0uOnVueozTT+5E9yJiQi1dAGgjPTZ1JKeUTboUrbfjE1nilJkLht9wVubPBx8+1li8uPLyz5lH9eW562hvBicfZUJJ+v3loB69k8jDXcWiOjYRcFicLIPwTNr25/lFwP1dGcmAX6gtm5OkDD+pToIqDYXUc0QVLoREJyNgNVW2l5rDAb+E36n9yQs7DI790XWnhphbkpHgtC3hzcTO+jjApx0jilwxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 69.169.224.2) 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=xzewjp/de+Ym3uRqhQA2+ikPwdVnfeNtyPxTfF+dISg=; b=PNbl0YWC9dSVlcXFpL9W0vDhyeQXewyGIE6Ei8L1eeaqnaKx5gb/CYBwSVXKFbGhOhLR/NNjz+psTuqAwVJHJIDkkOwnfs8QCStjeQemUG2Wusc3bxrRJgBFs+bPouZUApqtQsctmUBroBCiOi/L1YtugnKbd66uNkg9RDqMEKc= Received: from AS8P189CA0030.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:31f::35) by DBBPR08MB5897.eurprd08.prod.outlook.com (2603:10a6:10:203::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.546.15; Tue, 20 Oct 2026 16:38:02 +0000 Received: from AMS1EPF0000009D.eurprd02.prod.outlook.com (2603:10a6:20b:31f:cafe::47) by AS8P189CA0030.outlook.office365.com (2603:10a6:20b:31f::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.522.19 via Frontend Transport; Tue, 20 Oct 2026 16:38:02 +0000 Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 69.169.224.2) 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.2 as permitted sender) receiver=protection.outlook.com; client-ip=69.169.224.2; helo=b224-2.smtp-out.eu-central-1.amazonses.com; pr=C Received: from b224-2.smtp-out.eu-central-1.amazonses.com (69.169.224.2) by AMS1EPF0000009D.mail.protection.outlook.com (10.167.242.74) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.546.15 via Frontend Transport; Tue, 20 Oct 2026 16:38:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=23yjbh4k34hwzfubhuiim7m4inbd3ick; d=sashiko.virtuozzo.com; t=1792514282; h=Message-ID:From:Subject:To:In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=ycq2HIRy3tAL9Lel3i85SAHoxOcqPPToMR4/qAWbvyc=; b=KUt9QmpD+GIY1Gf2Cg2VSdQP4SEUezRAZ5dRravEjzqC0nHfUkxWt/vFhVIuvqOk QnSRsi6l03UhGKfqRAWYzk0aT5hJItMxVKoFoebVmpvYshCOupChw+v2PlZPcDuHcn2 gon677Imc8E3prrUcy5uoccN1NFYwBPkJ9yFkBPAWSYhlKcpAt/JAedQB7A+aNNJyry ZQ1T8L0IbIHjBUq3G6Hnpovu/sFVOuW8ADBl+K3IJ3IN+v7eE68pO01oXNKxw2XvdkF KGVCTysnX4xMLqZDxdzOiSU9oK3P+5efB4Z4BsIFqgh29tyV1/IBWSBgZQegj0XYpBk c84bkF8R/w== DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=qftdzk2dqsatjnlrq4r5brjbihpfcrsh; d=amazonses.com; t=1792514282; h=Message-ID:From:Subject:To:In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date:Feedback-ID; bh=ycq2HIRy3tAL9Lel3i85SAHoxOcqPPToMR4/qAWbvyc=; b=LCDq8iQFqXoLoDOlcC0m6m5nobGtAlQ51JA6lc9+yy+GQ/VSIDeB0c8wNhcQcobW FUrFLLlPrCX7WjqhoK7OYBLmX1EYs4dHyZWB6EqU+0361BBiQEyuSFQFYeYIJZgVtmr PHPIK471EXCkaL0JaS7rktDZgSBhIuaVdFqZMH9Y= Message-ID: <010701a15a2d5173-d2e7feff-3bf6-4bbf-9d26-a4466df9c9b2-000000@eu-central-1.amazonses.com> From: no-reply@sashiko.virtuozzo.com Subject: Re: [PATCH QEMU HCI-8.1 v4 05/31] migration: close the CPR state if the outgoing channel fails to open To: svt-core@virtuozzo.com, Andrey Drobyshev In-Reply-To: <20261020-vfio_v1-v4-5-83a5668230e5@virtuozzo.com> References: <20261020-vfio_v1-v4-0-83a5668230e5@virtuozzo.com> <20261020-vfio_v1-v4-5-83a5668230e5@virtuozzo.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 20 Oct 2026 16:38:01 +0000 Feedback-ID: ::1.eu-central-1.2wRQJBpg9g1fGRYexx3dUuYGS25Bux+2TEOx72/m6U4=:AmazonSES X-SES-Outgoing: 2026.10.20-69.169.224.2 X-EOPAttributedMessage: 0 X-EOPTenantAttributedMessage: 0bc7f26d-0264-416e-a6fc-8352af79c58f:0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS1EPF0000009D:EE_|DBBPR08MB5897:EE_ MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 0e25eba6-fe6b-4e2a-f253-08df2ec88239 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|32142699015|9140799003|376014|48200799018|61400799027|55112099003|5113699003|13003099007|4113699003|18002099003|16102099003|22082099003|10067099003|56012099006|5023799004|4143699003|5063699009|261009223027099003; X-Microsoft-Antispam-Message-Info: IuNrUxNMkyOHzKT/Kyw5SJymhMuKM6NdTPB/N9HkVB3Lf/XnuRM2KcUPcsuRVg4fJAKS3HAcJS61Z4RwTwhQroEeVU6j1TBSZEFEMBX/GWEWnB2lWVnvmLshGa+7reCaEeA67Q2bYO/wiBIz6jSBNnydyXDjefmGszsUexEBgRRlPI1lGlrsgomzaHrGLvFDzTSySMQLiz9kx3gTS4veeHTsBGi5t/X8oXAK6BmBOlJEp7sPmCRxZd/tmIfZwTjaLyO4U2yYo9VJcC2Kyhj3VXZHgHLBXiZ8T2GiI4jJ8q3kxeTKBoSEEYc3jO+36V/IIbFS5JvUqGemdHYFBywTMboqO9x4mRc5/IJpJsDf1PG8JagCyYPILRwXupDw2LwBfuMEFvn2vRlkP0od6yYQripnCCx6v+koMiE9Ts0EdeMt211WgF/vqnVD4ZbXpfBP6ifnGYYRrRlYilFmJroUpWnZx1PJSGts8oRtZUlJi7SvPxabG0kGS8+vgdedUfQxdIViXxrnPC7etAT7Qx2MkPEqKzPVCtgXhNKTRgD140XuAG8bS8IwsSIsPCi3GPcJpWvXj2S1zlMxRPXO1mDpx4khjS47dee6TdJ1rrPq8uviklU4p6osxqhqFw5I1xYm3rqrZb5FrgKN0JpkuQFO6JcicTduT3RYZ1hWxFdP7R0ylK2nIse9GBrehCUweKIuZJ2u8f8KG94GqT70yGfTNa1dz+NA7x0cxFOw7P/H+4BX7o05GiPZlF9UPyoZx8EHQrhLUFruIliHiaDRXbXKg366oKE7GllzIoeq/iyWfSZLQdfGG0DiKUY8H05XcCaP19SLmSb3hmYWotD4j8je1bT59SBhNISch/7feUh/9BCtzx4i/T6WG53YnNYagugIlo7PYKHh9LCJ2Tz3xwiT3OBYNRodrzFiLVpdJc6ttOM= X-Forefront-Antispam-Report: CIP:69.169.224.2;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:b224-2.smtp-out.eu-central-1.amazonses.com;PTR:b224-2.smtp-out.eu-central-1.amazonses.com;CAT:NONE;SFS:(13230040)(704161411799003)(32142699015)(9140799003)(376014)(48200799018)(61400799027)(55112099003)(5113699003)(13003099007)(4113699003)(18002099003)(16102099003)(22082099003)(10067099003)(56012099006)(5023799004)(4143699003)(5063699009)(261009223027099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hcE/V3IVhzlMuaQguF5QyQ4i16K60ThWJZz6N+XiMx6+5zKrvjeiwrgJ/RFFZoFtSATWw47Rm1Tfzdx04qydKvIShLD5w0RlsLSaqX8uD5hib1VOFsQAwDExbYQOxL97OQNdhec/c1TlUDIxgZdpVBLbGoJmDmeGLLfrB3Xg0UpmEFu7JYExN9F/Y7VvXXCpD3ge/8uC7KBh+/FK7X2fsCnWJ2utDymLgIFkN01xn/Hak+vVh8uXfVzeDSfZlOzmgHakrCEkIWvAYwScanJjMR3KITwzG7zElIwksX8lVhTY0Ek2EMYkSULJT0sKYj7dK9fh6ZKefku79ehiTgw/e49GSnKTcC1fOMievH9Fi6nt2hmjii6jasWAMFiwV+8zzUnnnTAT0z1F8Ahu4S8dWPDpAlrAYyaVH+xNMmzaYrjSJGrH527UuSeAgrWlYNsq X-ExternalRecipientOutboundConnectors: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2026 16:38:02.2502 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0e25eba6-fe6b-4e2a-f253-08df2ec88239 X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-AuthSource: AMS1EPF0000009D.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB5897 Thank you for your contribution! Sashiko AI review found 1 potential issue(= s) to consider: - [Medium] migration: cpr-exec dup'd memfd and env var leak when channel op= en fails -- commit 50d6efeaa5d85c80481be5ee50b6cbe211d76382 Author: Andrey Drobyshev migration: close the CPR state if the outgoing channel fails to open This patch adds a cpr_state_close() call to qmp_migrate_finish(). The call runs when the outgoing channel (file or exec) fails to open. Its purpose is to release the CPR state that qmp_migrate() saved earlier. > diff --git a/migration/migration.c b/migration/migration.c > --- a/migration/migration.c > +++ b/migration/migration.c [ ... ] > @@ -2412,6 +2412,7 @@ static void qmp_migrate_finish(MigrationAddress *ad= dr, bool resume_requested, > if (!resume_requested) { > yank_unregister_instance(MIGRATION_YANK_INSTANCE); > } > + cpr_state_close(); > migration_connect_set_error(s, local_err); > error_propagate(errp, local_err); > return; [Severity: Medium] The commit message says that without this change "the CPR state stays open: the memfd for cpr-exec, the state file for cpr-transfer". Does this call close everything for cpr-exec? cpr_state_close() only does qemu_fclose(cpr_state_file). That closes the original memfd. In cpr-exec mode, cpr_state_save() calls cpr_exec_persist_state(). That function creates a second reference to the memfd and sets an environment variable: migration/cpr-exec.c:cpr_exec_persist_state() { int mfd =3D dup(fioc->fd); ... qemu_clear_cloexec(mfd); ... g_setenv(CPR_EXEC_STATE_NAME, val, 1) } Nothing on this error path releases the dup'd fd or unsets QEMU_CPR_EXEC_STATE. Only cpr_exec_unpersist_state() does that: migration/cpr-exec.c:cpr_exec_unpersist_state() { g_unsetenv(CPR_EXEC_STATE_NAME); ... close(mfd); } It is called only from cpr_exec_notifier() on MIG_EVENT_PRECOPY_FAILED. This event is raised from migration_cleanup(), from the postcopy failure path, and from cpr_exec_cb() after a failed exec. None of these runs when qmp_migrate_finish() fails to open the channel, because migration_cleanup() doesn't run. migration_connect_set_error() only sets the state and the erro= r. Can a cpr-exec migrate to an exec: or file: URI that fails to open leak the dup'd memfd? Each retry would leak one more fd, with CLOEXEC already cleare= d. It would also leave a stale QEMU_CPR_EXEC_STATE variable pointing at that f= d. cpr_exec_has_state() would then keep returning true. Should this path also call cpr_exec_unpersist_state(), or raise MIG_EVENT_PRECOPY_FAILED, so the cpr-exec cleanup runs? --=20 Sashiko AI review =C2=B7 https://sashiko.vzint.dev/#/patchset/20261020-vfio= _v1-v4-0-83a5668230e5@virtuozzo.com?part=3D5