From nobody Sun Dec 14 06:36:31 2025 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; dmarc=pass(p=quarantine dis=none) header.from=akamai.com ARC-Seal: i=1; a=rsa-sha256; t=1764787501; cv=none; d=zohomail.com; s=zohoarc; b=BRJHHAnTlUT0b8QDqJ5HHDu5beDfMNPUM+T7Ga4mUkwOMY0uW24LW3nN4XVah+4AD8Ag64lzESCgoYG0UsxTPqKJmzy791sQxuzcNEONOSJNadhP77z2JqxPKEeMt8vhyPjXW0vtAE3rOKLDMBCbfrkIIKLjSCh1Yy97ZcG1VKM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764787501; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=SCJJjeHJL3zvQFZyNH6s4ysT7NMl476yKiQWW9PF388=; b=kGDWnWyKQF0XLDx32N3/jpB0DmkiCsLFju0bL4yNdGPHwOxrwsMZfr1IRszvvkXraA5KmiBCFBcV+Pvzqq2zgO7oyqvquALhDZPJUqfogBqVyvh2h82YcircgJjntzzRjFhpe5F36O4MfTqvoRHKJM2Q3DJnSwuyrRWCBUG3OTc= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1764787501745662.5461905703804; Wed, 3 Dec 2025 10:45:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQrpR-0001jS-Ji; Wed, 03 Dec 2025 13:43:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQrpK-0001h5-AE for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:43:46 -0500 Received: from mx0a-00190b01.pphosted.com ([67.231.149.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQrpH-0005hN-8R for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:43:46 -0500 Received: from pps.filterd (m0409409.ppops.net [127.0.0.1]) by m0409409.ppops.net-00190b01. (8.18.1.11/8.18.1.11) with ESMTP id 5B3CtocL3416317 for ; Wed, 3 Dec 2025 18:43:39 GMT Received: from prod-mail-ppoint6 (prod-mail-ppoint6.akamai.com [184.51.33.61]) by m0409409.ppops.net-00190b01. (PPS) with ESMTPS id 4at0bcqqsh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 03 Dec 2025 18:43:39 +0000 (GMT) Received: from pps.filterd (prod-mail-ppoint6.akamai.com [127.0.0.1]) by prod-mail-ppoint6.akamai.com (8.18.1.2/8.18.1.2) with ESMTP id 5B3GNRsp018041 for ; Wed, 3 Dec 2025 13:43:38 -0500 Received: from prod-mail-relay02.akamai.com ([172.27.118.35]) by prod-mail-ppoint6.akamai.com (PPS) with ESMTP id 4aqw21kx8c-1 for ; Wed, 03 Dec 2025 13:43:38 -0500 Received: from bos-lhvkhf.bos01.corp.akamai.com (bos-lhvkhf.bos01.corp.akamai.com [172.28.40.75]) by prod-mail-relay02.akamai.com (Postfix) with ESMTP id 44CC48A for ; Wed, 3 Dec 2025 18:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=jan2016.eng; bh=SCJJjeHJL3zvQFZyNH6s4ysT7NMl476yKiQWW9PF388=; b=XTOaEPR/ST5p aJZZ2KEHWrxqsSH7xA0a5gjsU9dXb43J3eBjVP5J+Cu30bICvsX2fi5rdjF7jC8N 07SZurv9pZQ2LpLi0qAuLWuiWroLqiaNAWITRxYOYBJ5iwEGxbF16BgWjkym2jEf SP+bwMoT1LJhRK6eUpodUYpTkJazItiWeMEH4DptxKFSWQKoAgRtRUAY1fxItRWr ZgvR2Dx6Yxk0V7Fp7mP0CbLSyaCP7YX6hzk7tcLORgjZnLn5JGGZ1mN/NuHO2bkj 6+fsZY18MiseaGM9UyO+SE8+SIUya8l8T7kvkvSbViuFfQbsppUT0Xb2jlpnr12J 6EwAf4pmuQ== From: Ben Chaney Date: Wed, 03 Dec 2025 13:43:22 -0500 Subject: [PATCH v3 1/8] migration: stop vm earlier for cpr MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251203-cpr-tap-v3-1-3cc89e9b19e4@akamai.com> References: <20251203-cpr-tap-v3-0-3cc89e9b19e4@akamai.com> In-Reply-To: <20251203-cpr-tap-v3-0-3cc89e9b19e4@akamai.com> To: qemu-devel@nongnu.org X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764787418; l=4737; i=bchaney@akamai.com; s=20251203; h=from:subject:message-id; bh=6VO5q5TE5yuukYkhY6LLyhvDeAXk7NNxQPT3gWn7Grw=; b=8s3CgnMjKTslbm0GkP5MEP9sCJvcavRPPRjxQ0HKVJR5nOBevRTcvNrAmPjlHLabIUkQVUv4/ 0VVUHz3mLjCDxK9J8i7JyBhRx0LF5MgiyicAlNdpdtEJkpgWa9Ctt8V X-Developer-Key: i=bchaney@akamai.com; a=ed25519; pk=6+w9cse5QEeVdy3tjqFxs/4rAaRdQ2/fkTxVFq+lWy4= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-03_02,2025-12-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2510240000 definitions=main-2512030146 X-Authority-Analysis: v=2.4 cv=AvfjHe9P c=1 sm=1 tr=0 ts=693084db cx=c_pps a=WPLAOKU3JHlOa4eSsQmUFQ==:117 a=WPLAOKU3JHlOa4eSsQmUFQ==:17 a=IkcTkHD0fZMA:10 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=yPCof4ZbAAAA:8 a=X7Ea-ya5AAAA:8 a=Q2gaB0lLyM3LBXvKuXcA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjAzMDE0NyBTYWx0ZWRfXwM/GYrc21IJ8 3uHS2p55kBxtPp8+TLmLU+2mn9uDeYhZnsucPL0nIbEWb1HdcdGcSZGq8oC2UMSrf1pG7cNH3IV 4mcxXNhBWclnyjxGK1tJSnkWfxig8SBcBJxu0VcTnHPoximOZKJ5sxTNjqprdKRVq+EgtXIFQdE EOOOPqby7DrADwwQU93RvPNqlJnPN7koWkrwPwTVB4A9sE24LbcawES44JCkmVBIjMPI8wgQFxy MAjDZf/3bj6fL/QeNP9yVMIDskYB/bLBeNqLm/4syJN+rACQkerRTaGx2W7A1Vwed6Cpg+n2hl/ j/hD17QTOAgA4cXRfdytpeOEALm4fu+wkbOiyNaDjP3gxYJnzGh+/ewzhDvGNhdZsOSUSFUj5BV kzLeF8QmolfNWsrcF1d6PvaWPs4ADA== X-Proofpoint-ORIG-GUID: 98VtIq2peLnV0gnEB5GFMRTi-cTdBb1p X-Proofpoint-GUID: 98VtIq2peLnV0gnEB5GFMRTi-cTdBb1p X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-03_02,2025-12-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 impostorscore=0 phishscore=0 bulkscore=0 priorityscore=1501 spamscore=0 lowpriorityscore=0 adultscore=0 malwarescore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512030147 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=67.231.149.131; envelope-from=bchaney@akamai.com; helo=mx0a-00190b01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @akamai.com) X-ZM-MESSAGEID: 1764787502680019200 From: Steve Sistare Stop the vm earlier for cpr, before cpr_save_state which causes new QEMU to proceed and initialize devices. We must guarantee devices are stopped in old QEMU, and all source notifiers called, before they are initialized in new QEMU. Signed-off-by: Steve Sistare Signed-off-by: Ben Chaney --- migration/migration.c | 57 +++++++++++++++++++++++++++++++++++++++++++----= ---- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index c2daab6bdd..6d40697767 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1657,6 +1657,7 @@ void migration_cancel(void) MIGRATION_STATUS_CANCELLED); cpr_state_close(); migrate_hup_delete(s); + vm_resume(s->vm_old_state); } } =20 @@ -2216,6 +2217,7 @@ void qmp_migrate(const char *uri, bool has_channels, MigrationAddress *addr =3D NULL; MigrationChannel *channelv[MIGRATION_CHANNEL_TYPE__MAX] =3D { NULL }; MigrationChannel *cpr_channel =3D NULL; + bool stopped =3D false; =20 /* * Having preliminary checks for uri and channel @@ -2268,6 +2270,46 @@ void qmp_migrate(const char *uri, bool has_channels, return; } =20 + /* + * CPR-transfer ordering: + * + * SOURCE TARGET + * ------ ------ + * cpr_state_load() blocks + * | | + * | 1. migration_stop_vm() | + * | VM stopped, devices quiesced | + * | | Waiting for + * | 2. notifiers (PRECOPY_SETUP) | FDs from source + * | vhost_reset_owner() releases | + * | device ownership | + * | | + * | 3. cpr_state_save() ---- FDs -------> | + * | | + * v v + * postmigrate Device init begins + * - cpr_find_fd() + * - vhost_dev_init() + * - VHOST_SET_OWNER + * + * Step 3 is the synchronization/cut-over point. Target proceeds immed= iately + * upon receiving FDs, so steps 1-2 must complete otherwise: + * - Target's VHOST_SET_OWNER fails with -EBUSY (source still owns) + * - Race between source I/O and target device init + * + * We stop the VM early (before FD transfer) to prevent this race. + * Unlike regular migration, CPR-transfer passes memory via FD (memfd) + * rather than copying RAM, so early VM stop should have minimal down= time. + */ + if (migrate_mode_is_cpr(s)) { + int ret =3D migration_stop_vm(s, RUN_STATE_FINISH_MIGRATE); + if (ret < 0) { + error_setg(&local_err, "migration_stop_vm failed, error %d", -= ret); + goto out; + } + stopped =3D true; + } + if (!cpr_state_save(cpr_channel, &local_err)) { goto out; } @@ -2294,6 +2336,9 @@ out: if (local_err) { migration_connect_set_error(s, local_err); error_propagate(errp, local_err); + if (stopped) { + vm_resume(s->vm_old_state); + } } } =20 @@ -2339,6 +2384,9 @@ static void qmp_migrate_finish(MigrationAddress *addr= , bool resume_requested, } migration_connect_set_error(s, local_err); error_propagate(errp, local_err); + if (migrate_mode_is_cpr(s)) { + vm_resume(s->vm_old_state); + } return; } } @@ -4028,7 +4076,6 @@ void migration_connect(MigrationState *s, Error *erro= r_in) Error *local_err =3D NULL; uint64_t rate_limit; bool resume =3D (s->state =3D=3D MIGRATION_STATUS_POSTCOPY_RECOVER_SET= UP); - int ret; =20 /* * If there's a previous error, free it and prepare for another one. @@ -4099,14 +4146,6 @@ void migration_connect(MigrationState *s, Error *err= or_in) return; } =20 - if (migrate_mode_is_cpr(s)) { - ret =3D migration_stop_vm(s, RUN_STATE_FINISH_MIGRATE); - if (ret < 0) { - error_setg(&local_err, "migration_stop_vm failed, error %d", -= ret); - goto fail; - } - } - /* * Take a refcount to make sure the migration object won't get freed by * the main thread already in migration_shutdown(). --=20 2.34.1 From nobody Sun Dec 14 06:36:31 2025 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; dmarc=pass(p=quarantine dis=none) header.from=akamai.com ARC-Seal: i=1; a=rsa-sha256; t=1764787481; cv=none; d=zohomail.com; s=zohoarc; b=IfVdZPwcPhneLFBjmywHUfDCl3phStdTPgzXm/fTktxSzDztxtN7TNVvgpXG6BSBaXQbBpYXDibu8axvg7azHfoijmpRMwW+q2Deb+1G7dAh6YSbdve850Bb4zpWOQaIUX/JBf2Gd4srB7lVJSbZ9iLBhpYqGu+VGrFonPesbCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764787481; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=t/8WC/8W9FdsPsEYza0XQgEda9PqZPLJMpsz9vEOBB8=; b=FhK4C+WQrlxevPt6Ntf9UcLAkIxdyyvrA/WbGtB8OmP79EHlew1AQ+h/JDKU0ux0Zb3niC0zUSFgj4zOjwCIapwT9Z4ALfDvn50oMFkqqixBg7YnUrCuL1BB94UhnpcDjupFCuXdWTMSTSmz/HNIMqgfaqVbEvSpa+sdkIalMwE= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176478748123258.530392349035424; Wed, 3 Dec 2025 10:44:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQrpN-0001iB-4C; Wed, 03 Dec 2025 13:43:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQrpJ-0001gW-RC for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:43:45 -0500 Received: from mx0b-00190b01.pphosted.com ([2620:100:9005:57f::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQrpH-0005hA-9U for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:43:45 -0500 Received: from pps.filterd (m0122330.ppops.net [127.0.0.1]) by mx0b-00190b01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5B37fSXA3673740 for ; Wed, 3 Dec 2025 18:43:39 GMT Received: from prod-mail-ppoint6 (prod-mail-ppoint6.akamai.com [184.51.33.61]) by mx0b-00190b01.pphosted.com (PPS) with ESMTPS id 4aspcaad57-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 03 Dec 2025 18:43:39 +0000 (GMT) Received: from pps.filterd (prod-mail-ppoint6.akamai.com [127.0.0.1]) by prod-mail-ppoint6.akamai.com (8.18.1.2/8.18.1.2) with ESMTP id 5B3FSw26013454 for ; Wed, 3 Dec 2025 13:43:38 -0500 Received: from prod-mail-relay02.akamai.com ([172.27.118.35]) by prod-mail-ppoint6.akamai.com (PPS) with ESMTP id 4aqw21kx8b-1 for ; Wed, 03 Dec 2025 13:43:38 -0500 Received: from bos-lhvkhf.bos01.corp.akamai.com (bos-lhvkhf.bos01.corp.akamai.com [172.28.40.75]) by prod-mail-relay02.akamai.com (Postfix) with ESMTP id 45AC58D for ; Wed, 3 Dec 2025 18:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=jan2016.eng; bh=t/8WC/8W9FdsPsEYza0XQgEda9PqZPLJMpsz9vEOBB8=; b=WVvptEtL54I/ vLvzHbpp5NiMKV0LShf91PxC9uUA0QlIvT6wo2sRq5Q47aqf8jVLv5Etghrsn35w 0dVYIA0oFBVG4P1Erp6bxYlY7PMHjxFGjRy2DKUdByz4QhStxMeKjp8NVO4bXs0C 6oh4ZK2biy0btPjJbfMNHcPSmFQ/AbUYegXy/zGvIjt74i3ThqzrjIxwiUjJiR7b e3qsQx8zVZyVyNZv1UpUyI4thnYfPVvzyMurs+ZY/oQArSJOj9dIRbrIbHIMVS3T xtrKdqE7zwi6zx5hOpUoE38BO+/yWNmKcKYzxPPER+yt2wwp6ZwHOGwuyjNA28GK pRGVlBDYnA== From: Ben Chaney Date: Wed, 03 Dec 2025 13:43:23 -0500 Subject: [PATCH v3 2/8] migration: cpr setup notifier MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251203-cpr-tap-v3-2-3cc89e9b19e4@akamai.com> References: <20251203-cpr-tap-v3-0-3cc89e9b19e4@akamai.com> In-Reply-To: <20251203-cpr-tap-v3-0-3cc89e9b19e4@akamai.com> To: qemu-devel@nongnu.org X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764787418; l=1432; i=bchaney@akamai.com; s=20251203; h=from:subject:message-id; bh=ybfQKPvFeL2sBlrQktra1uae8irgJMED5+q0/d3iGMY=; b=KuATHJ0YFwA02lTa7GWr7HmQr+gItBDTjCuH49zROVE3uVANH5DQWZG2SQlCL9F4vY7KEBeW/ CJx+PgxkTpDAIfr7eAq73ZHNaAkHMj2b/JPqt+2FRNt9XGV+uidiWy1 X-Developer-Key: i=bchaney@akamai.com; a=ed25519; pk=6+w9cse5QEeVdy3tjqFxs/4rAaRdQ2/fkTxVFq+lWy4= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-03_02,2025-12-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2510240000 definitions=main-2512030146 X-Proofpoint-GUID: Zr2Pak1savmau43Wu4QDNH2i3n8SwpiG X-Authority-Analysis: v=2.4 cv=c5umgB9l c=1 sm=1 tr=0 ts=693084db cx=c_pps a=WPLAOKU3JHlOa4eSsQmUFQ==:117 a=WPLAOKU3JHlOa4eSsQmUFQ==:17 a=IkcTkHD0fZMA:10 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=yPCof4ZbAAAA:8 a=X7Ea-ya5AAAA:8 a=9e0HOU0VQPgVKZhTx6MA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: Zr2Pak1savmau43Wu4QDNH2i3n8SwpiG X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjAzMDE0NyBTYWx0ZWRfX3RVyKgFpUhmW QD47CDxtjKIifP+QrSfnvp9WKxsJ3waqMSoM2xBNLwMoSfB8E3Wa23j8bhfxoHwhXgA4MjOpjgk rm4wk6ZiLgoECCiHH9HyD0eRtbOQMpiCxSTGxWc37VC6/QRwWPZuf8rW39u3Eae9QyIxJN3lTn6 TtOOl/HXC72lEb2LfS/LK6QeGU+M0jEusjR6lQ+zA0y2Tlo/zMIUdtqHaCQ3IEWsjVlcUpjx2Wh S+uWRqzawHsjCPk0zoPPWf0JvTfCGRNs1ZtgdVTzAhm+O8oOvJYYBjxu6vrahZm3QSElkdvBfQ/ DXN3BT0jDa9tuKl8Z6vXC/OXj1rny0T9NYwy5MWzrMeFIzf2URY9yhOf/cfjBn2t6U8YALru6PB 1uvuMDP/Kw/Q+efgI1jMt9JIoawfHQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-03_02,2025-12-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512030147 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2620:100:9005:57f::1; envelope-from=bchaney@akamai.com; helo=mx0b-00190b01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @akamai.com) X-ZM-MESSAGEID: 1764787482617019200 From: Steve Sistare Call MIG_EVENT_PRECOPY_SETUP earlier, before CPR starts. An early notifier is needed for resetting vhost devices, as explained in the next patch. Signed-off-by: Steve Sistare Signed-off-by: Ben Chaney --- migration/migration.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 6d40697767..60850c232e 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2310,7 +2310,14 @@ void qmp_migrate(const char *uri, bool has_channels, stopped =3D true; } =20 + /* Notify before starting migration thread, and before starting cpr */ + if (!resume_requested && + migration_call_notifiers(s, MIG_EVENT_PRECOPY_SETUP, &local_err)) { + goto out; + } + if (!cpr_state_save(cpr_channel, &local_err)) { + migration_call_notifiers(s, MIG_EVENT_PRECOPY_FAILED, NULL); goto out; } =20 @@ -4108,11 +4115,6 @@ void migration_connect(MigrationState *s, Error *err= or_in) } else { /* This is a fresh new migration */ rate_limit =3D migrate_max_bandwidth(); - - /* Notify before starting migration thread */ - if (migration_call_notifiers(s, MIG_EVENT_PRECOPY_SETUP, &local_er= r)) { - goto fail; - } } =20 migration_rate_set(rate_limit); --=20 2.34.1 From nobody Sun Dec 14 06:36:31 2025 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; dmarc=pass(p=quarantine dis=none) header.from=akamai.com ARC-Seal: i=1; a=rsa-sha256; t=1764787514; cv=none; d=zohomail.com; s=zohoarc; b=NdrRY+R8ck7nwwJ78wGcqXy882yvBtNlp5v48RgpsWugKWwzR1e1lqWQgI+/ydfTqQ4q8esQw93/wYaQhOBZXmVqaH7m7s9QXVET5X/79iaaZNolkEiBVXgErfCBvYQ5At6ABWdt3iCjclqq1wh/TFP46WGaTIuATKt4YOxI2Ks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764787514; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=ljRmB77NnqAdrgPEzQrr268ITHscsnHq1PoRVyI/Pzk=; b=gUifjCeOY5Qk/pdY4Np8gpG1Gf96SyeTOvjhQTeg7FENiTN49yXUTVHMyjrKIiciZizVgxPaq0CRQTrI+kt50b66W7Gqp7YL8KH7wELaMTDd9i0bHYIl2Z484X6lzsn0WBU1Fo9422jaHyFpqd1/wmCMJwnHpM+wSlmftnwPG9A= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17647875148762.8303501719743736; Wed, 3 Dec 2025 10:45:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQrpS-0001kq-6E; Wed, 03 Dec 2025 13:43:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQrpL-0001hX-C7 for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:43:47 -0500 Received: from mx0b-00190b01.pphosted.com ([2620:100:9005:57f::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQrpH-0005hF-8S for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:43:47 -0500 Received: from pps.filterd (m0122330.ppops.net [127.0.0.1]) by mx0b-00190b01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5B37jcJg3681167 for ; Wed, 3 Dec 2025 18:43:39 GMT Received: from prod-mail-ppoint5 (prod-mail-ppoint5.akamai.com [184.51.33.60]) by mx0b-00190b01.pphosted.com (PPS) with ESMTPS id 4aspcaad58-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 03 Dec 2025 18:43:39 +0000 (GMT) Received: from pps.filterd (prod-mail-ppoint5.akamai.com [127.0.0.1]) by prod-mail-ppoint5.akamai.com (8.18.1.2/8.18.1.2) with ESMTP id 5B3H7Opb026170 for ; Wed, 3 Dec 2025 10:43:38 -0800 Received: from prod-mail-relay02.akamai.com ([172.27.118.35]) by prod-mail-ppoint5.akamai.com (PPS) with ESMTP id 4aqypdkkhh-1 for ; Wed, 03 Dec 2025 10:43:38 -0800 Received: from bos-lhvkhf.bos01.corp.akamai.com (bos-lhvkhf.bos01.corp.akamai.com [172.28.40.75]) by prod-mail-relay02.akamai.com (Postfix) with ESMTP id 4688991 for ; Wed, 3 Dec 2025 18:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=jan2016.eng; bh=ljRmB77NnqAdrgPEzQrr268ITHscsnHq1PoRVyI/Pzk=; b=hK8n4/ZC00oi SFxAiPYs5KJoMpdv9WluV7rCZDyeqOc6hVWPVDX4IBEHJ8WCByQSXO4XYcRCZsk7 m8On+C47YmknOOHq9c8YmQAa2PcSghtbGLM+QSoCXtfcHLSmxih6Pcvm08pD2cCm S5W+JMXDuA59xnyn4O3G95EZ6dE4l0NhSzn3P7cJ3EMyjSF8I6OgYwzjUw+vYIZD lQVEZIinapRGEhH0hoylRDtfqZihVqeSlDgx373crIGHSxEQA7/1cV6yCnOPEQmI 5f6UXWSJqQa9WWbOu3U3QwhmLPYqmJK9A345ErLx+MM6EpXh2tanKvPxHv3dbwjA tForBXnXXw== From: Ben Chaney Date: Wed, 03 Dec 2025 13:43:24 -0500 Subject: [PATCH v3 3/8] vhost: reset vhost devices for cpr MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251203-cpr-tap-v3-3-3cc89e9b19e4@akamai.com> References: <20251203-cpr-tap-v3-0-3cc89e9b19e4@akamai.com> In-Reply-To: <20251203-cpr-tap-v3-0-3cc89e9b19e4@akamai.com> To: qemu-devel@nongnu.org X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764787418; l=5230; i=bchaney@akamai.com; s=20251203; h=from:subject:message-id; bh=6kTSGt3ELi899SPi+eJ4MTXel5sLxi3unzD950w6j/M=; b=0bWH3EO1Cx4DWscjdZmjpeJr1HCYRu8t5o6qI/Hv35EyJ+xmOzGWw5IVwbR+Q9FcjUGdWHuMK bbpIG0ni2GcCdoDFjF1v8l1veAwVPYr6hvVyGJQXIiLQ93tTtKCWswN X-Developer-Key: i=bchaney@akamai.com; a=ed25519; pk=6+w9cse5QEeVdy3tjqFxs/4rAaRdQ2/fkTxVFq+lWy4= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-03_02,2025-12-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2510240000 definitions=main-2512030146 X-Proofpoint-GUID: KrrkERjg2KXTyIGX2tFgZR_qOs-fHCZp X-Authority-Analysis: v=2.4 cv=c5umgB9l c=1 sm=1 tr=0 ts=693084db cx=c_pps a=NpDlK6FjLPvvy7XAFEyJFw==:117 a=NpDlK6FjLPvvy7XAFEyJFw==:17 a=IkcTkHD0fZMA:10 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=yPCof4ZbAAAA:8 a=X7Ea-ya5AAAA:8 a=6lTwf2g7YyX0f-ifu7AA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: KrrkERjg2KXTyIGX2tFgZR_qOs-fHCZp X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjAzMDE0NyBTYWx0ZWRfXyx0u8m9JxNZ7 MrCN/hbmcmRTmPICZqCJn9iJXkCQlRkNAxjGpFYhC7ExITZgxiTQGMmFarh4TvOLvfWcwJF66Gm Nl6ooX57+5sHzCFX5M1/Qx0+eN+TUkZmB16ilVcV8DY2fvKND1+Wwm5sw1x+7p2VPDebjq9KLnT DkStbsvJDzebJBWYsue+hBbpZ73UTTLPMANJAWE5beMCsoIYw65g5ufQUR/i3OC1105qcEYa4Od 6Gr2cGjKxPLr+u2EwOtWT3aVK78X0tKrKClzHDq+RWQ+UUm/tof2Ka/iBjIfzr4WZGxKkKWgdZt mNsi5+xkYXUcEF73VXWQVVOn9sx1PGRQC2tqKggbOrIwb6NXtfdki0JN9f3ywqNqZnhJWlnmbHC rmzOIQCxNq5mXYMpO2dt2NHuD8cI0A== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-03_02,2025-12-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512030147 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2620:100:9005:57f::1; envelope-from=bchaney@akamai.com; helo=mx0b-00190b01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @akamai.com) X-ZM-MESSAGEID: 1764787516808019200 From: Steve Sistare When preserving a vhost fd using CPR, call VHOST_RESET_OWNER prior to CPR in old QEMU. Otherwise, new QEMU will fail when it calls VHOST_SET_OWNER during vhost_dev_init. Signed-off-by: Mark Kanda Signed-off-by: Steve Sistare Signed-off-by: Ben Chaney --- hw/virtio/vhost-backend.c | 6 ++++++ hw/virtio/vhost.c | 32 ++++++++++++++++++++++++++++++++ include/hw/virtio/vhost-backend.h | 1 + include/hw/virtio/vhost.h | 1 + 4 files changed, 40 insertions(+) diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c index 4367db0d95..1447d12963 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -261,6 +261,11 @@ static int vhost_kernel_set_owner(struct vhost_dev *de= v) return vhost_kernel_call(dev, VHOST_SET_OWNER, NULL); } =20 +static int vhost_kernel_reset_owner(struct vhost_dev *dev) +{ + return vhost_kernel_call(dev, VHOST_RESET_OWNER, NULL); +} + static int vhost_kernel_get_vq_index(struct vhost_dev *dev, int idx) { assert(idx >=3D dev->vq_index && idx < dev->vq_index + dev->nvqs); @@ -385,6 +390,7 @@ const VhostOps kernel_ops =3D { .vhost_get_features_ex =3D vhost_kernel_get_features, .vhost_set_backend_cap =3D vhost_kernel_set_backend_cap, .vhost_set_owner =3D vhost_kernel_set_owner, + .vhost_reset_owner =3D vhost_kernel_reset_owner, .vhost_get_vq_index =3D vhost_kernel_get_vq_index, .vhost_vsock_set_guest_cid =3D vhost_kernel_vsock_set_guest_cid, .vhost_vsock_set_running =3D vhost_kernel_vsock_set_running, diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 266a11514a..011d73dae2 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -24,6 +24,7 @@ #include "standard-headers/linux/vhost_types.h" #include "hw/virtio/virtio-bus.h" #include "hw/mem/memory-device.h" +#include "migration/misc.h" #include "migration/blocker.h" #include "migration/qemu-file-types.h" #include "system/dma.h" @@ -1540,6 +1541,32 @@ static int vhost_dev_get_features(struct vhost_dev *= hdev, return r; } =20 +static int vhost_cpr_notifier(NotifierWithReturn *notifier, + MigrationEvent *e, Error **errp) +{ + struct vhost_dev *dev; + int r; + + dev =3D container_of(notifier, struct vhost_dev, cpr_transfer_notifier= ); + + if (dev->vhost_ops->backend_type !=3D VHOST_BACKEND_TYPE_KERNEL) { + return 0; + } + + if (e->type =3D=3D MIG_EVENT_PRECOPY_SETUP) { + r =3D dev->vhost_ops->vhost_reset_owner(dev); + if (r < 0) { + VHOST_OPS_DEBUG(r, "vhost_reset_owner failed"); + } + } else if (e->type =3D=3D MIG_EVENT_PRECOPY_FAILED) { + r =3D dev->vhost_ops->vhost_set_owner(dev); + if (r < 0) { + VHOST_OPS_DEBUG(r, "vhost_set_owner failed"); + } + } + return 0; +} + int vhost_dev_init(struct vhost_dev *hdev, void *opaque, VhostBackendType backend_type, uint32_t busyloop_timeou= t, Error **errp) @@ -1550,6 +1577,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, =20 hdev->vdev =3D NULL; hdev->migration_blocker =3D NULL; + hdev->cpr_transfer_notifier.notify =3D NULL; =20 r =3D vhost_set_backend_type(hdev, backend_type); assert(r >=3D 0); @@ -1650,6 +1678,9 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, hdev->log_enabled =3D false; hdev->started =3D false; memory_listener_register(&hdev->memory_listener, &address_space_memory= ); + migration_add_notifier_mode(&hdev->cpr_transfer_notifier, + vhost_cpr_notifier, + MIG_MODE_CPR_TRANSFER); QLIST_INSERT_HEAD(&vhost_devices, hdev, entry); =20 /* @@ -1702,6 +1733,7 @@ void vhost_dev_cleanup(struct vhost_dev *hdev) QLIST_REMOVE(hdev, entry); } migrate_del_blocker(&hdev->migration_blocker); + migration_remove_notifier(&hdev->cpr_transfer_notifier); g_free(hdev->mem); g_free(hdev->mem_sections); if (hdev->vhost_ops) { diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index ff94fa1734..18ce5ea9a0 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -196,6 +196,7 @@ typedef struct VhostOps { vhost_get_features_op vhost_get_features; vhost_set_backend_cap_op vhost_set_backend_cap; vhost_set_owner_op vhost_set_owner; + vhost_set_owner_op vhost_reset_owner; vhost_reset_device_op vhost_reset_device; vhost_get_vq_index_op vhost_get_vq_index; vhost_set_vring_enable_op vhost_set_vring_enable; diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 08bbb4dfe9..5d11a97e43 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -133,6 +133,7 @@ struct vhost_dev { QLIST_ENTRY(vhost_dev) logdev_entry; QLIST_HEAD(, vhost_iommu) iommu_list; IOMMUNotifier n; + NotifierWithReturn cpr_transfer_notifier; const VhostDevConfigOps *config_ops; }; =20 --=20 2.34.1 From nobody Sun Dec 14 06:36:31 2025 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; dmarc=pass(p=quarantine dis=none) header.from=akamai.com ARC-Seal: i=1; a=rsa-sha256; t=1764787529; cv=none; d=zohomail.com; s=zohoarc; b=hPKaJy+TJWLybHI8gesp0JE5AbE/ca8x8QhGlxVzifut2izU4FyUevkX8zbfV+7bRXYVhc0rGXFAo1pba2UlHYBvkYc43u9sVrbePH5zos+vz0hv6uhdNgGhzeRQTIikUGrCjFlTuUSs7C8pf0z3okx1FQL2kMt8oF0ke0def9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764787529; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=iDI9J/2kQZuf9g4MQ4HQ3luovEdJMVHjXyCsvqkM41I=; b=P2VtlzofRz7TAJSSx1Xm979z95gDBsWWa9Hm0xWPYceq+JFU5niY0YYjHJFyroY3DbbvO86bJVWW4avCU9kRnBfNcXbH3XBrwI4LMx4jUQbbS4OELDP5BF9wd+HhD6OcY1mxSdr/vrAf8JT48j1JVscFtVLcpDNum9+8nAClnMM= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17647875298751001.6675048707169; Wed, 3 Dec 2025 10:45:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQrpS-0001l8-Ko; Wed, 03 Dec 2025 13:43:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQrpL-0001hW-5J for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:43:47 -0500 Received: from mx0b-00190b01.pphosted.com ([67.231.157.127]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQrpH-0005hB-7y for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:43:46 -0500 Received: from pps.filterd (m0409410.ppops.net [127.0.0.1]) by m0409410.ppops.net-00190b01. (8.18.1.11/8.18.1.11) with ESMTP id 5B35SO1q2996017 for ; Wed, 3 Dec 2025 18:43:39 GMT Received: from prod-mail-ppoint6 (prod-mail-ppoint6.akamai.com [184.51.33.61]) by m0409410.ppops.net-00190b01. (PPS) with ESMTPS id 4at1xd1ymx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 03 Dec 2025 18:43:39 +0000 (GMT) Received: from pps.filterd (prod-mail-ppoint6.akamai.com [127.0.0.1]) by prod-mail-ppoint6.akamai.com (8.18.1.2/8.18.1.2) with ESMTP id 5B3FEY1E013412 for ; Wed, 3 Dec 2025 13:43:38 -0500 Received: from prod-mail-relay02.akamai.com ([172.27.118.35]) by prod-mail-ppoint6.akamai.com (PPS) with ESMTP id 4aqw21kx8d-1 for ; Wed, 03 Dec 2025 13:43:38 -0500 Received: from bos-lhvkhf.bos01.corp.akamai.com (bos-lhvkhf.bos01.corp.akamai.com [172.28.40.75]) by prod-mail-relay02.akamai.com (Postfix) with ESMTP id 4748C94 for ; Wed, 3 Dec 2025 18:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=jan2016.eng; bh=iDI9J/2kQZuf9g4MQ4HQ3luovEdJMVHjXyCsvqkM41I=; b=jX4UrqrxRFhd rFhEMXlJvrK3QNkmZigJAtfjIl/EiOSsyVjrqYsa1rNeyuojXBN6pxJt9Q/G9AoS HUChkD/yhTMuW7P8cF1Z8aV7eHX4aWmeDuDwDSIyw+r0gDmHSFG30VjFhvnTSduA vIYac20ZZIG4D43S2o6pCuL8k2+FL0Etn3SOX8vpFv+tTtMjAysd9m+p35q8zKI/ EG8NbWeCqNmhe55sPODRTl8YxPMqy5TffKu7fcH+7WjIv34ZbFT5KuP6lSNux/bU 8xTryUJzfWvJd+FTtcgWlMzUWoga/MN+7OkwxJjzH0w+c5XhGvgGQMZqyMOBNzhA LNU2DRG2MA== From: Ben Chaney Date: Wed, 03 Dec 2025 13:43:25 -0500 Subject: [PATCH v3 4/8] cpr: delete all fds MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251203-cpr-tap-v3-4-3cc89e9b19e4@akamai.com> References: <20251203-cpr-tap-v3-0-3cc89e9b19e4@akamai.com> In-Reply-To: <20251203-cpr-tap-v3-0-3cc89e9b19e4@akamai.com> To: qemu-devel@nongnu.org X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764787418; l=1519; i=bchaney@akamai.com; s=20251203; h=from:subject:message-id; bh=Damz0E1eWx9seXrv9+FOKa0jx9R91HPkz/OMuj3AucM=; b=53G568mYcarDf1j4BY9VtJEBAima/E69HeeZbmnBSlsZWOXgWhie3vfCGjNJNxjmNZBg0XdrK rpftoRJftQ0DSsCezdCQrNMqIvF44hoWAgCxqeYkNCdAX4XLxbmh37D X-Developer-Key: i=bchaney@akamai.com; a=ed25519; pk=6+w9cse5QEeVdy3tjqFxs/4rAaRdQ2/fkTxVFq+lWy4= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-03_02,2025-12-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=947 mlxscore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2510240000 definitions=main-2512030146 X-Authority-Analysis: v=2.4 cv=NKrYOk6g c=1 sm=1 tr=0 ts=693084db cx=c_pps a=WPLAOKU3JHlOa4eSsQmUFQ==:117 a=WPLAOKU3JHlOa4eSsQmUFQ==:17 a=IkcTkHD0fZMA:10 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=yPCof4ZbAAAA:8 a=X7Ea-ya5AAAA:8 a=n655hgSsutws6UkWyQYA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: kKHsNpMzkg2LPS1uRNnySHzKh-i-a7vk X-Proofpoint-ORIG-GUID: kKHsNpMzkg2LPS1uRNnySHzKh-i-a7vk X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjAzMDE0NyBTYWx0ZWRfX+fs4heUIt9UT 0wnGgzj4IBUARHUhCvbBLH+8iCU9msNXWhDaR1qwrRRwP8esleHIosD2ojIGDgkt9BLiQDqFStS paaNBs1XcsbgrlY8y62qOpYtZZ7INCMLS6ny/Gme+1xsnOAbHwozMbJf/LFKfnjIvNeKhjCWej9 HjEoKijapTh77WRSrlUXlUZxA+yd6IJPKtM9urrTJGhbX5QXrsUT577F+TGF9wryMM3uou1mw8V k3/3BbV5pRRho1f18f+NpVnjSnClq5qlLgA8OHnL9UcVqy7psDscG7PIbHPiBPXN9uj627heJIf TwHGEgkW9QxxJhfPIiwmWtz+uyiUnoPoh4aws3WMtgJw88gPHRuVfdxNUUhrNQhmiONTvnpD8uv m65bZlA9H7n6DBBlwDIBr6tSCuI/8A== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-03_02,2025-12-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 malwarescore=0 spamscore=0 suspectscore=0 phishscore=0 clxscore=1015 priorityscore=1501 adultscore=0 bulkscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512030147 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=67.231.157.127; envelope-from=bchaney@akamai.com; helo=mx0b-00190b01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @akamai.com) X-ZM-MESSAGEID: 1764787531072019200 From: Steve Sistare Add the cpr_delete_fd_all function to delete all fds associated with a device. Signed-off-by: Steve Sistare Signed-off-by: Ben Chaney --- include/migration/cpr.h | 1 + migration/cpr.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/migration/cpr.h b/include/migration/cpr.h index 027cb98073..d585fadc5b 100644 --- a/include/migration/cpr.h +++ b/include/migration/cpr.h @@ -29,6 +29,7 @@ extern CprState cpr_state; =20 void cpr_save_fd(const char *name, int id, int fd); void cpr_delete_fd(const char *name, int id); +void cpr_delete_fd_all(const char *name); int cpr_find_fd(const char *name, int id); void cpr_resave_fd(const char *name, int id, int fd); int cpr_open_fd(const char *path, int flags, const char *name, int id, diff --git a/migration/cpr.c b/migration/cpr.c index adee2a919a..c0bf93a7ba 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -85,6 +85,19 @@ void cpr_delete_fd(const char *name, int id) trace_cpr_delete_fd(name, id); } =20 +void cpr_delete_fd_all(const char *name) +{ + CprFd *elem, *next_elem; + + QLIST_FOREACH_SAFE(elem, &cpr_state.fds, next, next_elem) { + if (!strcmp(elem->name, name)) { + QLIST_REMOVE(elem, next); + g_free(elem->name); + g_free(elem); + } + } +} + int cpr_find_fd(const char *name, int id) { CprFd *elem =3D find_fd(&cpr_state.fds, name, id); --=20 2.34.1 From nobody Sun Dec 14 06:36:31 2025 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; dmarc=pass(p=quarantine dis=none) header.from=akamai.com ARC-Seal: i=1; a=rsa-sha256; t=1764787518; cv=none; d=zohomail.com; s=zohoarc; b=Qy7SqCKQ76gb4FgsVEiOsqlXEnvxVwfKt6M2lxGweNBGdK9IumM6GBVy0cNz8nu5MfGNJ6Urvgz2WjhgWhF9PkjgzwxZ96wNDCqK4m+XUAQ5YW1MoS0ykhcL2oayEiVQ+tDneTSQCashbfxMRpsxDU3Rcyr8aWJvt7yS4xV/gYY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764787518; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=NID9cQ6TVR/7DxrIYOVpRG111sFYubPS/LHG9jXZ0ns=; b=Fz5hZotpYP535VMuOQt3UdQWJg+3L3wR6h2ZzNOs2EGpMA1aVpHi033f+AWNES5/ls5MvwzKkWCsf0nnvxznZ3vrnFg/MUotNYetVk6zhMZOW3CD3ckGjlVtYPUVDWO+WxQSKxFviHEzneM3BZJNm2738XXUjq/NqQrVY4cYs+4= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1764787516253715.7386879733805; Wed, 3 Dec 2025 10:45:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQrpM-0001hQ-Eq; Wed, 03 Dec 2025 13:43:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQrpJ-0001gM-0w for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:43:45 -0500 Received: from mx0b-00190b01.pphosted.com ([2620:100:9005:57f::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQrpH-0005hH-86 for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:43:44 -0500 Received: from pps.filterd (m0122330.ppops.net [127.0.0.1]) by mx0b-00190b01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5B3HwA98876566 for ; Wed, 3 Dec 2025 18:43:39 GMT Received: from prod-mail-ppoint1 (prod-mail-ppoint1.akamai.com [184.51.33.18]) by mx0b-00190b01.pphosted.com (PPS) with ESMTPS id 4aspcaad5a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 03 Dec 2025 18:43:39 +0000 (GMT) Received: from pps.filterd (prod-mail-ppoint1.akamai.com [127.0.0.1]) by prod-mail-ppoint1.akamai.com (8.18.1.2/8.18.1.2) with ESMTP id 5B3GDt0q030112 for ; Wed, 3 Dec 2025 13:43:38 -0500 Received: from prod-mail-relay02.akamai.com ([172.27.118.35]) by prod-mail-ppoint1.akamai.com (PPS) with ESMTP id 4aqw21m40e-1 for ; Wed, 03 Dec 2025 13:43:38 -0500 Received: from bos-lhvkhf.bos01.corp.akamai.com (bos-lhvkhf.bos01.corp.akamai.com [172.28.40.75]) by prod-mail-relay02.akamai.com (Postfix) with ESMTP id 481E595 for ; Wed, 3 Dec 2025 18:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=jan2016.eng; bh=NID9cQ6TVR/7DxrIYOVpRG111sFYubPS/LHG9jXZ0ns=; b=Nb/jlPZNGw8h 7z8T+D6oZoqhXMfYlBgNnz1UKCLOA5aeUtEzmD4ZP0spnKYAgUXVUE2GYOFz1CTx Xs8uC4CNJ0heCAK/zUFUQzbq1eqhRg4taNg1tbReWiWmKDIWqjTYh4Ykralq0DCT LyhrkCUFjW3aLyPZr0TJCmCGIbXZQmrZ0NrRPocJLR4NV5ky9Z8pIVeOGcSgvqOs LE+d5BWvX0FQ8RJ6Q98JaXjcdBRwBv4hNbJx+JKmCdsTMX7jT7gHEhcup1k3bSAe 9G1Rh8hIA5aPb+tSBh+w9x5tZOrEir6YFuU/WcYdeQP1rCKWE8Smp/XLllkAHO4N u4s9Nyk5LA== From: Ben Chaney Date: Wed, 03 Dec 2025 13:43:26 -0500 Subject: [PATCH v3 5/8] tap: common return label MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251203-cpr-tap-v3-5-3cc89e9b19e4@akamai.com> References: <20251203-cpr-tap-v3-0-3cc89e9b19e4@akamai.com> In-Reply-To: <20251203-cpr-tap-v3-0-3cc89e9b19e4@akamai.com> To: qemu-devel@nongnu.org X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764787418; l=5311; i=bchaney@akamai.com; s=20251203; h=from:subject:message-id; bh=C43PerSzdOjLbyjnfYhRXVpakesxZD1fRN+2JrhKpv0=; b=Zhk1leRkT5uThxIPptYwmf8rzVR/A99p8c5Hxzw4jiAU5gwcr5z0T5xzRtkI6W8QkdLHi4aMe 8RC5el1HcScC45qvQEr7eB7O6VNhbvCLDYd23+UbpEl5/T7q9xxhZZy X-Developer-Key: i=bchaney@akamai.com; a=ed25519; pk=6+w9cse5QEeVdy3tjqFxs/4rAaRdQ2/fkTxVFq+lWy4= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-03_02,2025-12-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 spamscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2510240000 definitions=main-2512030146 X-Proofpoint-GUID: 12xyh9CYjLd_UOg-yjXZ5_bA21boCoNI X-Authority-Analysis: v=2.4 cv=c5umgB9l c=1 sm=1 tr=0 ts=693084db cx=c_pps a=StLZT/nZ0R8Xs+spdojYmg==:117 a=StLZT/nZ0R8Xs+spdojYmg==:17 a=IkcTkHD0fZMA:10 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=yPCof4ZbAAAA:8 a=X7Ea-ya5AAAA:8 a=zPeY32rCmRbJBjnbAY4A:9 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: 12xyh9CYjLd_UOg-yjXZ5_bA21boCoNI X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjAzMDE0NyBTYWx0ZWRfX1+lpwHw2irPk xJEVaXbLqdnyyT+IEUzS3J/UEAH3OubwpMUz5dIU9kZTKqzvr2SdpFFetGxnsuknlptGsZIGu2R g8SaSGKPlimT46VclnXeBeH+17wiCEPF0dBfCDQujNPNJYlEduw6bimXBHOujR5xlhEO2SJXa0Z DaNL7Hk9ZeiTQX8vgg4iEpDDIhUrlAkLf0dZTzjKV+Sm1jUlYiRPWky2ioqeIdpcAwP6SZp+ml+ 05PokBj6IMT/XnYfRuon5PCPwJaCeTTsjny//LloSikziV4bfqTxeWGOO/4fVvlJ8gZyebFH8DB k0qiyx6IkA+d+XHcl0KaB6aJapyaWkeujjBPSzBCMHumLqx+dCDpPX6dsVTiqhUpOsczrvx9gTm kYPtpRRBI6r7BjiADZC8sxOE9KvL+Q== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-03_02,2025-12-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512030147 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2620:100:9005:57f::1; envelope-from=bchaney@akamai.com; helo=mx0b-00190b01.pphosted.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-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: 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 @akamai.com) X-ZM-MESSAGEID: 1764787521044019200 From: Steve Sistare Modify net_init_tap so every return branches to a common label, for common cleanup in a subsequent patch. No functional change. Signed-off-by: Steve Sistare Signed-off-by: Ben Chaney --- net/tap.c | 55 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/net/tap.c b/net/tap.c index abe3b2d036..9d480574c3 100644 --- a/net/tap.c +++ b/net/tap.c @@ -830,7 +830,8 @@ int net_init_tap(const Netdev *netdev, const char *name, * For -netdev, peer is always NULL. */ if (peer && (tap->has_queues || tap->fds || tap->vhostfds)) { error_setg(errp, "Multiqueue tap cannot be used with hubs"); - return -1; + ret =3D -1; + goto out; } =20 if (tap->fd) { @@ -840,23 +841,27 @@ int net_init_tap(const Netdev *netdev, const char *na= me, error_setg(errp, "ifname=3D, script=3D, downscript=3D, vnet_hd= r=3D, " "helper=3D, queues=3D, fds=3D, and vhostfds=3D " "are invalid with fd=3D"); - return -1; + ret =3D -1; + goto out; } =20 fd =3D monitor_fd_param(monitor_cur(), tap->fd, errp); if (fd =3D=3D -1) { - return -1; + ret =3D -1; + goto out; } =20 if (!qemu_set_blocking(fd, false, errp)) { close(fd); - return -1; + ret =3D -1; + goto out; } =20 vnet_hdr =3D tap_probe_vnet_hdr(fd, errp); if (vnet_hdr < 0) { close(fd); - return -1; + ret =3D -1; + goto out; } =20 net_init_tap_one(tap, peer, "tap", name, NULL, @@ -865,7 +870,8 @@ int net_init_tap(const Netdev *netdev, const char *name, if (err) { error_propagate(errp, err); close(fd); - return -1; + ret =3D -1; + goto out; } } else if (tap->fds) { char **fds; @@ -878,7 +884,8 @@ int net_init_tap(const Netdev *netdev, const char *name, error_setg(errp, "ifname=3D, script=3D, downscript=3D, vnet_hd= r=3D, " "helper=3D, queues=3D, and vhostfd=3D " "are invalid with fds=3D"); - return -1; + ret =3D -1; + goto out; } =20 fds =3D g_new0(char *, MAX_TAP_QUEUES); @@ -940,29 +947,35 @@ free_fail: } g_free(fds); g_free(vhost_fds); - return ret; + goto out; + } else if (tap->helper) { if (tap->ifname || tap->script || tap->downscript || tap->has_vnet_hdr || tap->has_queues || tap->vhostfds) { error_setg(errp, "ifname=3D, script=3D, downscript=3D, vnet_hd= r=3D, " "queues=3D, and vhostfds=3D are invalid with helper= =3D"); - return -1; + ret =3D -1; + goto out; } =20 fd =3D net_bridge_run_helper(tap->helper, tap->br ?: DEFAULT_BRIDGE_INTERFACE, errp); if (fd =3D=3D -1) { - return -1; + ret =3D -1; + goto out; } =20 if (!qemu_set_blocking(fd, false, errp)) { - return -1; + close(fd); + ret =3D -1; + goto out; } vnet_hdr =3D tap_probe_vnet_hdr(fd, errp); if (vnet_hdr < 0) { close(fd); - return -1; + ret =3D -1; + goto out; } =20 net_init_tap_one(tap, peer, "bridge", name, ifname, @@ -971,14 +984,16 @@ free_fail: if (err) { error_propagate(errp, err); close(fd); - return -1; + ret =3D -1; + goto out; } } else { g_autofree char *default_script =3D NULL; g_autofree char *default_downscript =3D NULL; if (tap->vhostfds) { error_setg(errp, "vhostfds=3D is invalid if fds=3D wasn't spec= ified"); - return -1; + ret =3D -1; + goto out; } =20 if (!script) { @@ -999,14 +1014,16 @@ free_fail: fd =3D net_tap_init(tap, &vnet_hdr, i >=3D 1 ? "no" : script, ifname, sizeof ifname, queues > 1, errp); if (fd =3D=3D -1) { - return -1; + ret =3D -1; + goto out; } =20 if (queues > 1 && i =3D=3D 0 && !tap->ifname) { if (tap_fd_get_ifname(fd, ifname)) { error_setg(errp, "Fail to get ifname"); close(fd); - return -1; + ret =3D -1; + goto out; } } =20 @@ -1017,12 +1034,14 @@ free_fail: if (err) { error_propagate(errp, err); close(fd); - return -1; + ret =3D -1; + goto out; } } } =20 - return 0; +out: + return ret; } =20 int tap_enable(NetClientState *nc) --=20 2.34.1 From nobody Sun Dec 14 06:36:31 2025 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; dmarc=pass(p=quarantine dis=none) header.from=akamai.com ARC-Seal: i=1; a=rsa-sha256; t=1764787502; cv=none; d=zohomail.com; s=zohoarc; b=GZ9nlO11yyoHKbU7CeccY5kuIyU/tBOzScGPkn/6AKCBL0CH5GEGLvSRBorq1WomleZrwnJtwq4PvvR9jj6y88aCmgFYBejLKNEkGjG8BWP0eDTAQh7hhsessgVlxK2B++tjiBcRNbO6EUVtG2mhI7JTeDgy4gNYp4gOK4+3OdU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764787502; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=sxAo1uqskNqifb7qfIk7I5/SJimHpVVq96+8uOmNsQM=; b=Gu2h9y74/qvVQo70dyLh7Q4K0+gHzqd0jHOhkpkYBF6MXWrZLdRY9kp9vqcwtxoXv9qfvpYAT6MXNIJzgdpBbqmvqUeWEybdjkAu5SkTce/VCxPtp8m2zW2gymU3YSvRyViX1f13W00ArY64ZjOWUUBTcu0CdnPLywZNuWqjhzg= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1764787502851992.3863488662938; Wed, 3 Dec 2025 10:45:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQrpQ-0001jQ-5Q; Wed, 03 Dec 2025 13:43:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQrpK-0001hJ-GU for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:43:46 -0500 Received: from mx0b-00190b01.pphosted.com ([2620:100:9005:57f::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQrpH-0005hI-9X for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:43:46 -0500 Received: from pps.filterd (m0122331.ppops.net [127.0.0.1]) by mx0b-00190b01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5B39qPfF4058597 for ; Wed, 3 Dec 2025 18:43:39 GMT Received: from prod-mail-ppoint5 (prod-mail-ppoint5.akamai.com [184.51.33.60]) by mx0b-00190b01.pphosted.com (PPS) with ESMTPS id 4aswun4u6d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 03 Dec 2025 18:43:39 +0000 (GMT) Received: from pps.filterd (prod-mail-ppoint5.akamai.com [127.0.0.1]) by prod-mail-ppoint5.akamai.com (8.18.1.2/8.18.1.2) with ESMTP id 5B3FaPLB031233 for ; Wed, 3 Dec 2025 10:43:38 -0800 Received: from prod-mail-relay02.akamai.com ([172.27.118.35]) by prod-mail-ppoint5.akamai.com (PPS) with ESMTP id 4aqypdkkhj-1 for ; Wed, 03 Dec 2025 10:43:38 -0800 Received: from bos-lhvkhf.bos01.corp.akamai.com (bos-lhvkhf.bos01.corp.akamai.com [172.28.40.75]) by prod-mail-relay02.akamai.com (Postfix) with ESMTP id 4912798 for ; Wed, 3 Dec 2025 18:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=jan2016.eng; bh=sxAo1uqskNqifb7qfIk7I5/SJimHpVVq96+8uOmNsQM=; b=ltEA9PEO5/qt LCUIrDZcgM95xsmgRC9V5wwro3ObNpBWfVZMKKzJgMD53KMj+F47XNdsQRP6f+b8 SXE2RNSOr77m0RfEJijeFvcw63kACayVtfNpTe+6REAFVuhJzjcZ5/VSIbyQznVZ RaUauRqRY6Rrith5lrkZBUNHbBwAQnMWN9eRzrGhK/KrYnvx6P/LSsnovPivOTWN Ymin09UNME4ybFePGzIJuO8MjLdyeObaqEZwp8PrS8B0P60yErve5SEK12PbjJOk 2kxh+AgzKfdpnP7mkMT+y7atkr5P5TTL414kV+iYYHUW2qHO3DxIAamuBVndhi9T gT7AFpes0w== From: Ben Chaney Date: Wed, 03 Dec 2025 13:43:27 -0500 Subject: [PATCH v3 6/8] tap: cpr support MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251203-cpr-tap-v3-6-3cc89e9b19e4@akamai.com> References: <20251203-cpr-tap-v3-0-3cc89e9b19e4@akamai.com> In-Reply-To: <20251203-cpr-tap-v3-0-3cc89e9b19e4@akamai.com> To: qemu-devel@nongnu.org X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764787418; l=12397; i=bchaney@akamai.com; s=20251203; h=from:subject:message-id; bh=3xg4N8thwWZW4UJ8SY9X2DDt88vnbdrhVb/PFvVwcXA=; b=mZtZY5WaC2FMieofVA+JPJIkWaKodIk6GRm0uofX//N6DTGHUS8espqPrb5tZU8gBLQsYaYaB Fdc23KYzyATCIo2HkZgxfKIsF3NpVxI7dFux8sytrg+osKhiH6NQ5L0 X-Developer-Key: i=bchaney@akamai.com; a=ed25519; pk=6+w9cse5QEeVdy3tjqFxs/4rAaRdQ2/fkTxVFq+lWy4= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-03_02,2025-12-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2510240000 definitions=main-2512030146 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjAzMDE0NyBTYWx0ZWRfX1VIUVH+lsKbe /4+pfMEi8c6YC0OXfyy0J4TbLI8lX45ZaHeWpPuFnW+zmSlfxRFWRBD5/Xk6NYMqa4HrhfL6i3d 4TaajrR26uDduFb9aFf418+rYG9QBtjDrutkR4Udi4aIlBaDmePxGM+FfLSYcy/7PkrdY2RhgKP d5PHo1zNmw2floq1pgA2d/s+ljOdoNS2q4koyTyQ04r+gA7kvULNk4nqW9T2taqqzci/8VRIgXu LLD7/HlDjITd0xFZJgx8qQlnX4IptIBvkZ7L/ijBG6Fmb4vQFlP9mIRLKT1l9UEImavoyppp5QA clbO5dYr5L3jsE96xxS9gsRGLadwMN36r50r+YGnx0SSxysjkNDScqdsrQuHmTwHi3eujgzVvv/ +Ii2k6v5YrFXCJBO15HhCO1YVOFgqA== X-Proofpoint-ORIG-GUID: SDyxIOgquO1ZV6yKDxZ_vUGat8IyIVoj X-Authority-Analysis: v=2.4 cv=O+o0fR9W c=1 sm=1 tr=0 ts=693084db cx=c_pps a=NpDlK6FjLPvvy7XAFEyJFw==:117 a=NpDlK6FjLPvvy7XAFEyJFw==:17 a=IkcTkHD0fZMA:10 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=yPCof4ZbAAAA:8 a=X7Ea-ya5AAAA:8 a=DrAZhfO-21Mt0ZXRAbIA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: SDyxIOgquO1ZV6yKDxZ_vUGat8IyIVoj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-03_02,2025-12-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 clxscore=1015 malwarescore=0 impostorscore=0 adultscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512030147 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2620:100:9005:57f::1; envelope-from=bchaney@akamai.com; helo=mx0b-00190b01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @akamai.com) X-ZM-MESSAGEID: 1764787504603019201 From: Steve Sistare Provide the cpr=3Don option to preserve TAP and vhost descriptors during cpr-transfer, so the management layer does not need to create a new device for the target. Save all tap fd's in canonical order, leveraging the index argument of cpr_save_fd. For the i'th queue, the tap device fd is saved at index 2*i, and the vhostfd (if any) at index 2*i+1. tap and vhost fd's are passed by name to the monitor when a NIC is hot plugged, but the name is not known to qemu after cpr. Allow the manager to pass -1 for the fd "name" in the new qemu args to indicate that QEMU should search for a saved value. Example: -netdev tap,id=3Dhostnet2,fds=3D-1:-1,vhostfds=3D-1:-1,cpr=3Don Signed-off-by: Steve Sistare Signed-off-by: Ben Chaney --- hw/vfio/device.c | 2 +- include/migration/cpr.h | 2 +- migration/cpr.c | 11 ++++---- net/tap.c | 73 +++++++++++++++++++++++++++++++++++++++------= ---- qapi/net.json | 5 +++- 5 files changed, 70 insertions(+), 23 deletions(-) diff --git a/hw/vfio/device.c b/hw/vfio/device.c index 76869828fc..73e622f7b5 100644 --- a/hw/vfio/device.c +++ b/hw/vfio/device.c @@ -362,7 +362,7 @@ void vfio_device_free_name(VFIODevice *vbasedev) =20 void vfio_device_set_fd(VFIODevice *vbasedev, const char *str, Error **err= p) { - vbasedev->fd =3D cpr_get_fd_param(vbasedev->dev->id, str, 0, errp); + vbasedev->fd =3D cpr_get_fd_param(vbasedev->dev->id, str, 0, true, err= p); } =20 static VFIODeviceIOOps vfio_device_io_ops_ioctl; diff --git a/include/migration/cpr.h b/include/migration/cpr.h index d585fadc5b..68424b4b03 100644 --- a/include/migration/cpr.h +++ b/include/migration/cpr.h @@ -48,7 +48,7 @@ void cpr_state_close(void); struct QIOChannel *cpr_state_ioc(void); =20 bool cpr_incoming_needed(void *opaque); -int cpr_get_fd_param(const char *name, const char *fdname, int index, +int cpr_get_fd_param(const char *name, const char *fdname, int index, bool= cpr, Error **errp); =20 QEMUFile *cpr_transfer_output(MigrationChannel *channel, Error **errp); diff --git a/migration/cpr.c b/migration/cpr.c index c0bf93a7ba..19bd56339d 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -316,6 +316,7 @@ bool cpr_incoming_needed(void *opaque) * @name: CPR name for the descriptor * @fdname: An integer-valued string, or a name passed to a getfd command * @index: CPR index of the descriptor + * @cpr: use cpr * @errp: returned error message * * If CPR is not being performed, then use @fdname to find the fd. @@ -325,22 +326,22 @@ bool cpr_incoming_needed(void *opaque) * On success returns the fd value, else returns -1. */ int cpr_get_fd_param(const char *name, const char *fdname, int index, - Error **errp) + bool cpr, Error **errp) { ERRP_GUARD(); int fd; =20 - if (cpr_is_incoming()) { + if (cpr && cpr_is_incoming()) { fd =3D cpr_find_fd(name, index); if (fd < 0) { error_setg(errp, "cannot find saved value for fd %s", fdname); } } else { fd =3D monitor_fd_param(monitor_cur(), fdname, errp); - if (fd >=3D 0) { - cpr_save_fd(name, index, fd); - } else { + if (fd < 0) { error_prepend(errp, "Could not parse object fd %s:", fdname); + } else if (cpr) { + cpr_save_fd(name, index, fd); } } return fd; diff --git a/net/tap.c b/net/tap.c index 9d480574c3..79e29addd1 100644 --- a/net/tap.c +++ b/net/tap.c @@ -35,6 +35,7 @@ #include "net/eth.h" #include "net/net.h" #include "clients.h" +#include "migration/cpr.h" #include "monitor/monitor.h" #include "system/system.h" #include "qapi/error.h" @@ -80,6 +81,7 @@ typedef struct TAPState { bool has_uso; bool has_tunnel; bool enabled; + bool cpr; VHostNetState *vhost_net; unsigned host_vnet_hdr_len; Notifier exit; @@ -323,6 +325,9 @@ static void tap_cleanup(NetClientState *nc) { TAPState *s =3D DO_UPCAST(TAPState, nc, nc); =20 + if (s->cpr) { + cpr_delete_fd_all(nc->name); + } if (s->vhost_net) { vhost_net_cleanup(s->vhost_net); g_free(s->vhost_net); @@ -690,18 +695,24 @@ static int net_tap_init(const NetdevTapOptions *tap, = int *vnet_hdr, return fd; } =20 +/* CPR fd's for each queue are saved at these indices */ +#define TAP_FD_INDEX(queue) (2 * (queue) + 0) +#define TAP_VHOSTFD_INDEX(queue) (2 * (queue) + 1) + #define MAX_TAP_QUEUES 1024 =20 static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *= peer, const char *model, const char *name, const char *ifname, const char *script, const char *downscript, const char *vhostfdna= me, - int vnet_hdr, int fd, Error **errp) + int vnet_hdr, int fd, int index, Error **errp) { Error *err =3D NULL; TAPState *s =3D net_tap_fd_init(peer, model, name, fd, vnet_hdr); + bool cpr =3D tap->has_cpr ? tap->cpr : false; int vhostfd; =20 + s->cpr =3D cpr; tap_set_sndbuf(s->fd, tap, &err); if (err) { error_propagate(errp, err); @@ -736,7 +747,7 @@ static void net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, } =20 if (vhostfdname) { - vhostfd =3D monitor_fd_param(monitor_cur(), vhostfdname, &err); + vhostfd =3D cpr_get_fd_param(name, vhostfdname, index, cpr, &e= rr); if (vhostfd =3D=3D -1) { error_propagate(errp, err); goto failed; @@ -745,13 +756,22 @@ static void net_init_tap_one(const NetdevTapOptions *= tap, NetClientState *peer, goto failed; } } else { - vhostfd =3D open("/dev/vhost-net", O_RDWR); + vhostfd =3D cpr ? cpr_find_fd(name, index) : -1; + if (vhostfd < 0) { + vhostfd =3D open("/dev/vhost-net", O_RDWR); + if (cpr && vhostfd >=3D 0) { + cpr_save_fd(name, index, vhostfd); + } + } if (vhostfd < 0) { error_setg_errno(errp, errno, "tap: open vhost char device failed"); goto failed; } if (!qemu_set_blocking(vhostfd, false, errp)) { + if (!cpr) { + close(vhostfd); + } goto failed; } } @@ -777,6 +797,9 @@ static void net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, return; =20 failed: + if (cpr) { + cpr_delete_fd_all(name); + } qemu_del_net_client(&s->nc); } =20 @@ -809,7 +832,8 @@ static int get_fds(char *str, char *fds[], int max) int net_init_tap(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { - const NetdevTapOptions *tap; + const NetdevTapOptions *tap =3D &netdev->u.tap; + bool cpr =3D tap->has_cpr ? tap->cpr : false; int fd, vnet_hdr =3D 0, i =3D 0, queues; /* for the no-fd, no-helper case */ const char *script; @@ -845,7 +869,7 @@ int net_init_tap(const Netdev *netdev, const char *name, goto out; } =20 - fd =3D monitor_fd_param(monitor_cur(), tap->fd, errp); + fd =3D cpr_get_fd_param(name, tap->fd, TAP_FD_INDEX(0), cpr, errp); if (fd =3D=3D -1) { ret =3D -1; goto out; @@ -866,13 +890,14 @@ int net_init_tap(const Netdev *netdev, const char *na= me, =20 net_init_tap_one(tap, peer, "tap", name, NULL, script, downscript, - vhostfdname, vnet_hdr, fd, &err); + vhostfdname, vnet_hdr, fd, TAP_VHOSTFD_INDEX(0), = &err); if (err) { error_propagate(errp, err); close(fd); ret =3D -1; goto out; } + } else if (tap->fds) { char **fds; char **vhost_fds; @@ -903,7 +928,7 @@ int net_init_tap(const Netdev *netdev, const char *name, } =20 for (i =3D 0; i < nfds; i++) { - fd =3D monitor_fd_param(monitor_cur(), fds[i], errp); + fd =3D cpr_get_fd_param(name, fds[i], TAP_FD_INDEX(i), cpr, er= rp); if (fd =3D=3D -1) { ret =3D -1; goto free_fail; @@ -930,7 +955,7 @@ int net_init_tap(const Netdev *netdev, const char *name, net_init_tap_one(tap, peer, "tap", name, ifname, script, downscript, tap->vhostfds ? vhost_fds[i] : NULL, - vnet_hdr, fd, &err); + vnet_hdr, fd, TAP_VHOSTFD_INDEX(i), &err); if (err) { error_propagate(errp, err); ret =3D -1; @@ -958,9 +983,15 @@ free_fail: goto out; } =20 - fd =3D net_bridge_run_helper(tap->helper, - tap->br ?: DEFAULT_BRIDGE_INTERFACE, - errp); + fd =3D cpr ? cpr_find_fd(name, TAP_FD_INDEX(0)) : -1; + if (fd < 0) { + fd =3D net_bridge_run_helper(tap->helper, + tap->br ?: DEFAULT_BRIDGE_INTERFACE, + errp); + if (cpr && fd >=3D 0) { + cpr_save_fd(name, TAP_FD_INDEX(0), fd); + } + } if (fd =3D=3D -1) { ret =3D -1; goto out; @@ -980,13 +1011,14 @@ free_fail: =20 net_init_tap_one(tap, peer, "bridge", name, ifname, script, downscript, vhostfdname, - vnet_hdr, fd, &err); + vnet_hdr, fd, TAP_VHOSTFD_INDEX(0), &err); if (err) { error_propagate(errp, err); close(fd); ret =3D -1; goto out; } + } else { g_autofree char *default_script =3D NULL; g_autofree char *default_downscript =3D NULL; @@ -1011,8 +1043,14 @@ free_fail: } =20 for (i =3D 0; i < queues; i++) { - fd =3D net_tap_init(tap, &vnet_hdr, i >=3D 1 ? "no" : script, - ifname, sizeof ifname, queues > 1, errp); + fd =3D cpr ? cpr_find_fd(name, TAP_FD_INDEX(i)) : -1; + if (fd < 0) { + fd =3D net_tap_init(tap, &vnet_hdr, i >=3D 1 ? "no" : scri= pt, + ifname, sizeof ifname, queues > 1, errp); + if (cpr && fd >=3D 0) { + cpr_save_fd(name, TAP_FD_INDEX(i), fd); + } + } if (fd =3D=3D -1) { ret =3D -1; goto out; @@ -1030,7 +1068,9 @@ free_fail: net_init_tap_one(tap, peer, "tap", name, ifname, i >=3D 1 ? "no" : script, i >=3D 1 ? "no" : downscript, - vhostfdname, vnet_hdr, fd, &err); + vhostfdname, vnet_hdr, + fd, TAP_VHOSTFD_INDEX(i), + &err); if (err) { error_propagate(errp, err); close(fd); @@ -1041,6 +1081,9 @@ free_fail: } =20 out: + if (ret && cpr) { + cpr_delete_fd_all(name); + } return ret; } =20 diff --git a/qapi/net.json b/qapi/net.json index 118bd34965..264213b5d9 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -355,6 +355,8 @@ # @poll-us: maximum number of microseconds that could be spent on busy # polling for tap (since 2.7) # +# @cpr: preserve fds and vhostfds during cpr-transfer. +# # Since: 1.2 ## { 'struct': 'NetdevTapOptions', @@ -373,7 +375,8 @@ '*vhostfds': 'str', '*vhostforce': 'bool', '*queues': 'uint32', - '*poll-us': 'uint32'} } + '*poll-us': 'uint32', + '*cpr': 'bool'} } =20 ## # @NetdevSocketOptions: --=20 2.34.1 From nobody Sun Dec 14 06:36:31 2025 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; dmarc=pass(p=quarantine dis=none) header.from=akamai.com ARC-Seal: i=1; a=rsa-sha256; t=1764787542; cv=none; d=zohomail.com; s=zohoarc; b=NNFlQGBE+G/k3kO8Yph8JyzSNnQIMLl6iWOsNClLGvNwVmCA1MiYPVrGC9HT7LC4B+sSvmoIYMl31g/zvjgeAZFmsonHGzALNA1xBWzJIC+bYI/W2aROihGVd9pFxLlMelKIsbBa9NLyFjdlx57zHXc6HwWdKyJheMP9bLsFg8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764787542; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=QoR6CzW42yFuzK4C/5cibENCPr6ROAzmTT9DkEW4Iy8=; b=VcBgcd5vgCKejFbYzaEEUOZ1fqJyWrklE5om9Dp0k+ieFIdF8vrjYe0Ws+AY+4ebVwiQ57LKZ7yQEEVqCq4+IAmk/nFVbgMY5Y2bsfzcfHxY358iBnxC1bMSuXXsaVRFUAOOzO9vtj8I6zlaSDedTOW/COrTntReIX/vi0x5wqA= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1764787542280602.6798934947203; Wed, 3 Dec 2025 10:45:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQrpT-0001lD-3t; Wed, 03 Dec 2025 13:43:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQrpL-0001hV-57 for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:43:47 -0500 Received: from mx0b-00190b01.pphosted.com ([2620:100:9005:57f::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQrpH-0005hC-8S for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:43:46 -0500 Received: from pps.filterd (m0122331.ppops.net [127.0.0.1]) by mx0b-00190b01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5B3I6NhR980940 for ; Wed, 3 Dec 2025 18:43:39 GMT Received: from prod-mail-ppoint6 (prod-mail-ppoint6.akamai.com [184.51.33.61]) by mx0b-00190b01.pphosted.com (PPS) with ESMTPS id 4aswun4u6c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 03 Dec 2025 18:43:39 +0000 (GMT) Received: from pps.filterd (prod-mail-ppoint6.akamai.com [127.0.0.1]) by prod-mail-ppoint6.akamai.com (8.18.1.2/8.18.1.2) with ESMTP id 5B3FId4q013420 for ; Wed, 3 Dec 2025 13:43:38 -0500 Received: from prod-mail-relay02.akamai.com ([172.27.118.35]) by prod-mail-ppoint6.akamai.com (PPS) with ESMTP id 4aqw21kx8e-1 for ; Wed, 03 Dec 2025 13:43:38 -0500 Received: from bos-lhvkhf.bos01.corp.akamai.com (bos-lhvkhf.bos01.corp.akamai.com [172.28.40.75]) by prod-mail-relay02.akamai.com (Postfix) with ESMTP id 49EEC99 for ; Wed, 3 Dec 2025 18:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=jan2016.eng; bh=QoR6CzW42yFuzK4C/5cibENCPr6ROAzmTT9DkEW4Iy8=; b=cJTr6tVwlxcx Ln1CwlcsZyAlbcvxku6XFhF5Utfp+uazm2hXPg+W8Sb414UV0ATns3J4K+TaQzUQ Ho29UlSyDcnBcr70oiopYoXv14WoikpxreWH/paSE/5C1L72TVbSx+uESWMm9tDn kE3MgbJuQqH+7xLymYYXWTqnICj10AjM9wp4D3Xl0nELIcfsniOejXLakJMIr0AY AT4Ux8oXzrCcOHHp8sESF4iZE+vUO64vak/zfluGkp/G+hXfWOSdEcSnaQ9lj/iK Crm4Jb97+xozzvef7RxaqdYaEalz2JEoEgkf2wEXiANp37vM6ajSArtWAoQ4Hsge 4DpFu/V6JA== From: Ben Chaney Date: Wed, 03 Dec 2025 13:43:28 -0500 Subject: [PATCH v3 7/8] tap: postload fix for cpr MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251203-cpr-tap-v3-7-3cc89e9b19e4@akamai.com> References: <20251203-cpr-tap-v3-0-3cc89e9b19e4@akamai.com> In-Reply-To: <20251203-cpr-tap-v3-0-3cc89e9b19e4@akamai.com> To: qemu-devel@nongnu.org X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764787418; l=3307; i=bchaney@akamai.com; s=20251203; h=from:subject:message-id; bh=trjqxlGTjzbMkDT7mRMw3NXMaJd7F2w+gOl7JrhHwFU=; b=xiRtR9bMqe91YsEssJiS9eCrb6s34M3UIBl0tEopYQ5oqVqm8+6yBcXqIDKTyQDsdg+TKC/Ww U+UqfvGaaElAv4/HnsnFtX5vOfAsF6kqICNI8gto8sbQ5piGA9sTyc8 X-Developer-Key: i=bchaney@akamai.com; a=ed25519; pk=6+w9cse5QEeVdy3tjqFxs/4rAaRdQ2/fkTxVFq+lWy4= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-03_02,2025-12-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2510240000 definitions=main-2512030146 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjAzMDE0NyBTYWx0ZWRfX0oeDVIOcog9K yiCYVPxwqyAwZl1Q2pnfR+slo194iNA1ioa6T3xLfX+QhOBs0oWqJ1YY8h5oPR+8GF72a+ljBGV LHN1Gj9DyVHEWHKXWIHeSn5LqsZka3/P10UNJA9JnIinZd9jgSMtwRMUUMvDWFNGs6qlAsOJNPF XXRh0M/RIuAPJvXlLfIWARW4aNaGLuOpgLPvm623p9bvV4Hz3PAAPkBX1CM/wqCw31376QF2H7o Q02QYkdlFkBh5TawMGwK9wIGzGV0h6xzcBYgk3dWW2HulKtYU5p7IAP8kvwjD+ogbfW9ZcjhZ+/ BZgINKQzHfh+YFyDSnEMw81STLzxXM4w2yfnlRZILmOt5EDfN4cYjUmBMrcJRdMHYemKYMjUjOE OnNk2ZRIiO3PpTXDsOAzfGf1MVS7nA== X-Proofpoint-ORIG-GUID: XrZv3EPl5W0bwQHO6dOg25Tvm8yO-n85 X-Authority-Analysis: v=2.4 cv=O+o0fR9W c=1 sm=1 tr=0 ts=693084db cx=c_pps a=WPLAOKU3JHlOa4eSsQmUFQ==:117 a=WPLAOKU3JHlOa4eSsQmUFQ==:17 a=IkcTkHD0fZMA:10 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=yPCof4ZbAAAA:8 a=X7Ea-ya5AAAA:8 a=h1OFwVCXqnWUJWdIchYA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: XrZv3EPl5W0bwQHO6dOg25Tvm8yO-n85 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-03_02,2025-12-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 clxscore=1015 malwarescore=0 impostorscore=0 adultscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512030147 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2620:100:9005:57f::1; envelope-from=bchaney@akamai.com; helo=mx0b-00190b01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @akamai.com) X-ZM-MESSAGEID: 1764787542974019200 From: Steve Sistare After cpr of a multi-queue NIC, if any queues are unused, then the corresponding tap is marked enabled in userland, but it is disabled in the kernel for the fd that was preserved. One cannot call tap_disable() during postload, because that eventually calls IFF_DETACH_QUEUE, which fails because the queue is already detached. Define tap_disable_postload to avoid IFF_DETACH_QUEUE. Signed-off-by: Steve Sistare Signed-off-by: Ben Chaney --- hw/net/virtio-net.c | 20 ++++++++++++++++++++ include/net/tap.h | 1 + net/tap-win32.c | 5 +++++ net/tap.c | 17 +++++++++++++++++ 4 files changed, 43 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 3b85560f6f..38ec7ac109 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -765,6 +765,25 @@ static int peer_detach(VirtIONet *n, int index) return tap_disable(nc->peer); } =20 +/* + * Set the disabled flag on unused queue pairs after vmstate load, without + * calling IFF_DETACH_QUEUE, which fails because the queue is already deta= ched. + */ +static void virtio_net_postload_queue_pairs(VirtIONet *n) +{ + int i; + MigMode mode =3D migrate_mode(); + + if (mode =3D=3D MIG_MODE_CPR_TRANSFER) { + for (i =3D n->curr_queue_pairs; i < n->max_queue_pairs; i++) { + NetClientState *nc =3D qemu_get_subqueue(n->nic, i); + if (nc->peer && nc->peer->info->type =3D=3D NET_CLIENT_DRIVER_= TAP) { + tap_disable_postload(nc->peer); + } + } + } +} + static void virtio_net_set_queue_pairs(VirtIONet *n) { int i; @@ -3212,6 +3231,7 @@ static int virtio_net_post_load_device(void *opaque, = int version_id) */ n->saved_guest_offloads =3D n->curr_guest_offloads; =20 + virtio_net_postload_queue_pairs(n); virtio_net_set_queue_pairs(n); =20 /* Find the first multicast entry in the saved MAC filter */ diff --git a/include/net/tap.h b/include/net/tap.h index 6f34f13eae..934131f551 100644 --- a/include/net/tap.h +++ b/include/net/tap.h @@ -30,6 +30,7 @@ =20 int tap_enable(NetClientState *nc); int tap_disable(NetClientState *nc); +void tap_disable_postload(NetClientState *nc); =20 int tap_get_fd(NetClientState *nc); =20 diff --git a/net/tap-win32.c b/net/tap-win32.c index 38baf90e0b..efe81c54ee 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -766,3 +766,8 @@ int tap_disable(NetClientState *nc) { abort(); } + +void tap_disable_postload(NetClientState *nc) +{ + abort(); +} diff --git a/net/tap.c b/net/tap.c index 79e29addd1..5acda81146 100644 --- a/net/tap.c +++ b/net/tap.c @@ -1121,3 +1121,20 @@ int tap_disable(NetClientState *nc) return ret; } } + +/* + * On cpr restart, the tap is marked enabled in userland, but it might be + * disabled in the kernel, and IFF_DETACH_QUEUE will fail because it is + * already detached. This function disables without calling IFF_DETACH_QU= EUE. + */ +void tap_disable_postload(NetClientState *nc) +{ + TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + + if (!s->cpr || s->enabled =3D=3D 0) { + return; + } else { + s->enabled =3D false; + tap_update_fd_handler(s); + } +} --=20 2.34.1 From nobody Sun Dec 14 06:36:31 2025 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; dmarc=pass(p=quarantine dis=none) header.from=akamai.com ARC-Seal: i=1; a=rsa-sha256; t=1764787481; cv=none; d=zohomail.com; s=zohoarc; b=NG0jchRd3GIrP3/UB/lX3j+X/qJexX0rVjwdSMlo9HRngqib6IDvy6YHsvlGAMXSQ3w3PF/v3W4aB5sbeusf7TmbNEr/Z1yxSKbIX5N1cF+34SSMKLjHyRO1XuZsrpNCf0/2Jpl98sATtTEMzMijycZ6vagsyPG3NNuib5MGAOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764787481; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=2tqwxUShjbp6xB29PdE2LrVae4u2i8bzJmQKHr4yHxs=; b=QueTNMz4jLgsXKJFPHZAnFjP2XUOu+07Cu0KJmP7MM0OWBHDdMWFNaC23aOSIP76VNa97YML62zjS9Xh6XvMwMDQIQvm4fGexPfBYkY8FMRhSTl8+3Q4O8OHEnCpdgGHBudhSM5FPg8ObkWTL0ibutIXxlnA22mmrA7LkjGLAkw= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176478748126468.13554506710148; Wed, 3 Dec 2025 10:44:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQrpP-0001j8-OX; Wed, 03 Dec 2025 13:43:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQrpJ-0001gX-TW for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:43:45 -0500 Received: from mx0b-00190b01.pphosted.com ([2620:100:9005:57f::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQrpH-0005hG-9U for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:43:45 -0500 Received: from pps.filterd (m0050102.ppops.net [127.0.0.1]) by m0050102.ppops.net-00190b01. (8.18.1.11/8.18.1.11) with ESMTP id 5B38t2Gb3356703 for ; Wed, 3 Dec 2025 18:43:39 GMT Received: from prod-mail-ppoint6 (prod-mail-ppoint6.akamai.com [184.51.33.61]) by m0050102.ppops.net-00190b01. (PPS) with ESMTPS id 4at1wwjahr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 03 Dec 2025 18:43:39 +0000 (GMT) Received: from pps.filterd (prod-mail-ppoint6.akamai.com [127.0.0.1]) by prod-mail-ppoint6.akamai.com (8.18.1.2/8.18.1.2) with ESMTP id 5B3F5lqu013415 for ; Wed, 3 Dec 2025 13:43:38 -0500 Received: from prod-mail-relay02.akamai.com ([172.27.118.35]) by prod-mail-ppoint6.akamai.com (PPS) with ESMTP id 4aqw21kx8f-1 for ; Wed, 03 Dec 2025 13:43:38 -0500 Received: from bos-lhvkhf.bos01.corp.akamai.com (bos-lhvkhf.bos01.corp.akamai.com [172.28.40.75]) by prod-mail-relay02.akamai.com (Postfix) with ESMTP id 4AB7F9A for ; Wed, 3 Dec 2025 18:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=jan2016.eng; bh=2tqwxUShjbp6xB29PdE2LrVae4u2i8bzJmQKHr4yHxs=; b=aXE+96i1w2SG /SFo9fIZwJ63hYM0Tt8g8Fx9zpyZxRogi/N92sObt/TVAiL4uZeH8D9hWZkMFnr9 osHyMDViSXtw/eLmLUYFdrORxtVpMhtMdel/mdcqzx9wOD2J7T00NvVbNmnsvVDd zhf65QKB+duPRyZPN5Nz3gMEFFjTIPqYv3KZLrQ2F/dCSL1SG9wB4LbqYg+ZtnOm WrGsdnMyMk7rEOzkvOWNwDnVBd4LqJUy226BXJJBue9ojEiY9SZyFkd/KqQSogdi WAzYOXDNW+uYaTaQ1b6GsgiWtY8KEpk5C7nGasSPI7sh+8x3VMzAI3SyKaDE7VbD qNk/Op39SQ== From: Ben Chaney Date: Wed, 03 Dec 2025 13:43:29 -0500 Subject: [PATCH v3 8/8] tap: cpr fixes MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251203-cpr-tap-v3-8-3cc89e9b19e4@akamai.com> References: <20251203-cpr-tap-v3-0-3cc89e9b19e4@akamai.com> In-Reply-To: <20251203-cpr-tap-v3-0-3cc89e9b19e4@akamai.com> To: qemu-devel@nongnu.org X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764787418; l=3243; i=bchaney@akamai.com; s=20251203; h=from:subject:message-id; bh=zPYWBDaP+GisG/WA7Z9aDp07+oXAyy1rWdyxkJgQ9vw=; b=YLbhfEKTPKOw1E5Wu2f4OfUxksPTaCMFq3bL2uNAsqcaOM9thMj/RYamouWALJHxBhlQ6mY28 fjxynlxkc6IC+J2J6ly8X/zeLPhV+jDny0Nh26RWdCC7m+gY32PFg2s X-Developer-Key: i=bchaney@akamai.com; a=ed25519; pk=6+w9cse5QEeVdy3tjqFxs/4rAaRdQ2/fkTxVFq+lWy4= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-03_02,2025-12-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2510240000 definitions=main-2512030146 X-Proofpoint-ORIG-GUID: xjoHhUPw4zGn1QW5jvq_oVp7ie5k0eJb X-Authority-Analysis: v=2.4 cv=EffFgfmC c=1 sm=1 tr=0 ts=693084db cx=c_pps a=WPLAOKU3JHlOa4eSsQmUFQ==:117 a=WPLAOKU3JHlOa4eSsQmUFQ==:17 a=IkcTkHD0fZMA:10 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=yPCof4ZbAAAA:8 a=X7Ea-ya5AAAA:8 a=6R7veym_AAAA:8 a=MOkVEwTOFFmkGxDkLR0A:9 a=QEXdDO2ut3YA:10 a=ILCOIF4F_8SzUMnO7jNM:22 X-Proofpoint-GUID: xjoHhUPw4zGn1QW5jvq_oVp7ie5k0eJb X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjAzMDE0NyBTYWx0ZWRfX/iQeGB1ymNbM SdeT7yTvIXMvTHbgGIBdVcjH+I8bqVud1Qzxr+zLlQuGYPQT7FIZNI/Su0X0h903hwsFVJa2qPm O1g+5ZU8KsfNrt+if6EIhkrYK8r7dDbm8QYeJCQiqECGCJhZ4b9+Ge2rBgfarYmqSctIo6frq6d m0DNKKu00MxZuAcf2oUpJOZnHAYYHmD1yhc5Svqa0RFoKbkHxquLazmg5IM1B5ke2OHZVNQIUW6 IVttY217rJ9CrUEwF2k/jha3VSBWq/rPah+Xubq4Njv/rqln1mpcTm6W3lKkH1OJ6hFC1hoDLLm f2ykq5iKYKNVtFn4GqQbLlIB7adERcXtcHSxukMJgCK/D60PPQFpsfyyA7ZtRMWYxsC7SzJh4cr Xo+5pqjQ2D7Sxp0S83gWQUzlp/sdJw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-03_02,2025-12-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 bulkscore=0 spamscore=0 phishscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512030147 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2620:100:9005:57f::1; envelope-from=bchaney@akamai.com; helo=mx0b-00190b01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @akamai.com) X-ZM-MESSAGEID: 1764787482667019200 From: Steve Sistare Fix "virtio_net_set_queue_pairs: Assertion `!r' failed." Fix "virtio-net: saved image requires vnet_hdr=3Don" Do not change blocking mode of incoming cpr fd's. Reported-by: Ben Chaney Reported-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Steve Sistare Signed-off-by: Ben Chaney --- hw/net/virtio-net.c | 6 ++++++ io/channel-socket.c | 4 +++- net/tap.c | 2 ++ stubs/cpr.c | 8 ++++++++ stubs/meson.build | 1 + 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 38ec7ac109..fd6b30b296 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -37,6 +37,7 @@ #include "qapi/qapi-types-migration.h" #include "qapi/qapi-events-migration.h" #include "hw/virtio/virtio-access.h" +#include "migration/cpr.h" #include "migration/misc.h" #include "standard-headers/linux/ethtool.h" #include "system/system.h" @@ -789,6 +790,11 @@ static void virtio_net_set_queue_pairs(VirtIONet *n) int i; int r; =20 + if (cpr_is_incoming()) { + /* peers are already attached, do nothing */ + return; + } + if (n->nic->peer_deleted) { return; } diff --git a/io/channel-socket.c b/io/channel-socket.c index 3053b35ad8..443ca8cb7c 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -24,6 +24,7 @@ #include "io/channel-socket.h" #include "io/channel-util.h" #include "io/channel-watch.h" +#include "migration/cpr.h" #include "trace.h" #include "qapi/clone-visitor.h" #ifdef CONFIG_LINUX @@ -521,7 +522,8 @@ static bool qio_channel_handle_fds(int *fds, size_t nfd= s, =20 if (!preserve_blocking) { /* O_NONBLOCK is preserved across SCM_RIGHTS so reset it */ - if (!qemu_set_blocking(*fd, true, errp)) { + if (!cpr_is_incoming() && + qemu_set_blocking(*fd, true, errp)) { return false; } } diff --git a/net/tap.c b/net/tap.c index 5acda81146..5e04099c87 100644 --- a/net/tap.c +++ b/net/tap.c @@ -1050,6 +1050,8 @@ free_fail: if (cpr && fd >=3D 0) { cpr_save_fd(name, TAP_FD_INDEX(i), fd); } + } else { + vnet_hdr =3D tap->has_vnet_hdr ? tap->vnet_hdr : 1; } if (fd =3D=3D -1) { ret =3D -1; diff --git a/stubs/cpr.c b/stubs/cpr.c new file mode 100644 index 0000000000..1a4dbbb2d7 --- /dev/null +++ b/stubs/cpr.c @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#include "qemu/osdep.h" +#include "migration/cpr.h" + +bool cpr_is_incoming(void) +{ + return false; +} diff --git a/stubs/meson.build b/stubs/meson.build index 0b2778c568..87af733528 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -10,6 +10,7 @@ stub_ss.add(files('is-daemonized.c')) stub_ss.add(files('monitor-core.c')) stub_ss.add(files('replay-mode.c')) stub_ss.add(files('trace-control.c')) +stub_ss.add(files('cpr.c')) =20 if have_block stub_ss.add(files('bdrv-next-monitor-owned.c')) --=20 2.34.1