From nobody Sun Dec 14 06:37: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=1764787950; cv=none; d=zohomail.com; s=zohoarc; b=Ynyt66FDMkXG/vzEMpQD7vU/ca7ZBrKM0HaxPLE0epgouHniC3vXwjTArmV0ZrU4YV5JV8codsELCKna0LKtZVqbrAucwHoYRc+60vg5TzM4RKt8I5V4EdhbswbVysSY6OGSRX68KNFXPPxql6r9orsWZ+ZuFjWvhctjEHCFFr0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764787950; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SCJJjeHJL3zvQFZyNH6s4ysT7NMl476yKiQWW9PF388=; b=fsDeLaXJKBhaXS76mI6GpuSnMSQA+6vKHuD3PoGvRQmfmJnHFZbW9/ljCTXAe7DW20EY/nEYPUxH9MNNJueem0npclWnduUi7IuK802kQ6WwkcxfQSvRFvzP+iY2c8HTbsMDKNGka85pQXyf+FUcYiOGRlMb9Yf+X6EFpCCiNXo= 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 1764787950292278.88762918294856; Wed, 3 Dec 2025 10:52:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQrwq-0007SG-A2; Wed, 03 Dec 2025 13:51:32 -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 1vQrwp-0007Qp-14 for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:51:31 -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 1vQrwn-0000zR-5z for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:51:30 -0500 Received: from pps.filterd (m0409411.ppops.net [127.0.0.1]) by m0409411.ppops.net-00190b01. (8.18.1.11/8.18.1.11) with ESMTP id 5B3FwH85148441; Wed, 3 Dec 2025 18:51:27 GMT Received: from prod-mail-ppoint2 (prod-mail-ppoint2.akamai.com [184.51.33.19]) by m0409411.ppops.net-00190b01. (PPS) with ESMTPS id 4at31m8y0b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 03 Dec 2025 18:51:27 +0000 (GMT) Received: from pps.filterd (prod-mail-ppoint2.akamai.com [127.0.0.1]) by prod-mail-ppoint2.akamai.com (8.18.1.2/8.18.1.2) with ESMTP id 5B3IZ4A0014679; Wed, 3 Dec 2025 13:51:26 -0500 Received: from prod-mail-relay01.akamai.com ([172.27.118.31]) by prod-mail-ppoint2.akamai.com (PPS) with ESMTP id 4aqw21kuh6-1; Wed, 03 Dec 2025 13:51:26 -0500 Received: from bos-lhvkhf.bos01.corp.akamai.com (bos-lhvkhf.bos01.corp.akamai.com [172.28.40.75]) by prod-mail-relay01.akamai.com (Postfix) with ESMTP id 9CA8184; Wed, 3 Dec 2025 18:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=jan2016.eng; bh=SCJJjeHJL3zvQFZyNH6s4ysT7NMl476yKiQWW9PF388=; b=Uy6tsZ86GKI0 Ee/lp5OZYKvBAsIgv+dYboExsM/fr849GjrtMgaX86mMsvpf39/tw1drbQoc3gpY DbAyXcJPZ90XK1oY1w6HLgaOGGsIND9m69MHQ4REG5UFUI9CHmXLtiaOv528++he 7Uxy0KitMddrfr10+N39IGWO4oMEqE1Bsm0Wa3llCSuaDq0S1k7SPw0qso1wdUUV RhKaRDIBPrG1u4FSTwe+SPS1AGMJxrBnSH0q1/1TcWh52ch64OB68E04ysN1M5AS dspyLwe5IjvzyeiVeDKKkw9tXk7774PomEEEA7vUfZYaK2t8xATC4ohJKu2quUTo o41j2FmJkQ== From: Ben Chaney Date: Wed, 03 Dec 2025 13:51:18 -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-3c12e0a61f8e@akamai.com> References: <20251203-cpr-tap-v3-0-3c12e0a61f8e@akamai.com> In-Reply-To: <20251203-cpr-tap-v3-0-3c12e0a61f8e@akamai.com> To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Stefano Garzarella , Jason Wang , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Eric Blake , Markus Armbruster , Stefan Weil , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Paolo Bonzini , Hamza Khan , Mark Kanda , Joshua Hunt , Max Tottenham , Ben Chaney , Steve Sistare X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764787886; l=4737; i=bchaney@akamai.com; s=20251203; h=from:subject:message-id; bh=6VO5q5TE5yuukYkhY6LLyhvDeAXk7NNxQPT3gWn7Grw=; b=jmB3MnmsjpjuBR/wnVMra/A/TNmA/dppEn5qBFxRW1X9N+Qzwm8MSIeLmEoyL6bBW4kfGSpTe KBQX1b8RC8JCBAbmBEwwsEuzkp3Yi6MwqTXXziriNInNkHbQnMZt6qc 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_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 mlxscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2510240000 definitions=main-2512030148 X-Proofpoint-GUID: X363mFYwB-pYD7snl9ZTA5UTk2bKOKDW X-Authority-Analysis: v=2.4 cv=I6Nohdgg c=1 sm=1 tr=0 ts=693086af cx=c_pps a=BpD+HMUBsFIkYY1OQe22Yw==:117 a=BpD+HMUBsFIkYY1OQe22Yw==: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-ORIG-GUID: X363mFYwB-pYD7snl9ZTA5UTk2bKOKDW X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjAzMDE0NyBTYWx0ZWRfXyRMrCv7efKI4 J0fG9e7AoGAIaTK/g2DnvAh0BYkYO1uJhegDdLplFQVZ03pZWTFNrB8M1GikGIIyzVVMjJgqotO 6BHvCV8vooMm011YWkfLYmu3qxJ9FtCCdjKM3GrF2VST78BnyaFATDfNOTZi3h4zhQaPFJYEKY9 rQG4lXAATcRASrVBX32Ypz7uO0KBk+mj2XNJCitOYk1m7wmMjzDBRdI6SXb5/WlBtWV6SukhLKF 8fAXveIW48hw4LTLt4M1u9FcWEKPN8ke8pCiPo4FgX6W5qeRh1mUIDF1PL2k4U8MUOaiHTYkXQX erUSpPB1FawxYWMCauQ0jf97ZZIfkfHWqH4YhFYhYH7/wf7xc/VTrS0zDwHSAUV4gMO+O84wEv7 2Xdo95s5s8zP9suNutu85SE05BJ8Tw== 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 impostorscore=0 phishscore=0 malwarescore=0 bulkscore=0 clxscore=1011 spamscore=0 lowpriorityscore=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=67.231.157.127; 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_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1764787952259019200 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:37: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=1764788018; cv=none; d=zohomail.com; s=zohoarc; b=UtYdtnHmaOpiLzB6tuilvyfB9nlqwNSSX+SF7SSBVLtEjYk0OfrikBhYGb2FaUA7vP/9h1Wf4obmFPPEsetnd1iVEjvvDdOWCSo0vUZrLse0iMTC+WlmVsKD6FhPmh+VxCKSY9uBkmSh9ImEBliNeMglStmSpVRHfXN5Eu27EUc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764788018; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=t/8WC/8W9FdsPsEYza0XQgEda9PqZPLJMpsz9vEOBB8=; b=fHmXRWUd/G6E3J4o2jV58uTC3mrDWsFFQPL7Kyb6YRjNuoriMcKpa3pjWKtrXWjrwkSvmk4noD0KPXL1xmXnVFtsrFrP6O9QcSEU81Oryk7HQOt5mH75Bb6OUBuXy24o2gldB+MxK1wkGcVQhEYvj9fnC0+23Bz+uB+lPSJy70o= 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 1764788018327945.615134011085; Wed, 3 Dec 2025 10:53:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQrwr-0007TM-Cg; Wed, 03 Dec 2025 13:51:33 -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 1vQrwp-0007R3-Ja for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:51:31 -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 1vQrwn-0000zQ-Bg for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:51:31 -0500 Received: from pps.filterd (m0409411.ppops.net [127.0.0.1]) by m0409411.ppops.net-00190b01. (8.18.1.11/8.18.1.11) with ESMTP id 5B3HaD9k365124; Wed, 3 Dec 2025 18:51:27 GMT Received: from prod-mail-ppoint2 (prod-mail-ppoint2.akamai.com [184.51.33.19]) by m0409411.ppops.net-00190b01. (PPS) with ESMTPS id 4at31m8y0c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 03 Dec 2025 18:51:27 +0000 (GMT) Received: from pps.filterd (prod-mail-ppoint2.akamai.com [127.0.0.1]) by prod-mail-ppoint2.akamai.com (8.18.1.2/8.18.1.2) with ESMTP id 5B3FFwRH029135; Wed, 3 Dec 2025 13:51:26 -0500 Received: from prod-mail-relay01.akamai.com ([172.27.118.31]) by prod-mail-ppoint2.akamai.com (PPS) with ESMTP id 4aqw21kuh7-1; Wed, 03 Dec 2025 13:51:26 -0500 Received: from bos-lhvkhf.bos01.corp.akamai.com (bos-lhvkhf.bos01.corp.akamai.com [172.28.40.75]) by prod-mail-relay01.akamai.com (Postfix) with ESMTP id A1B5094; Wed, 3 Dec 2025 18:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h=cc :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=ZjbO1FblYWdt 9uwR0d9nrRpvLrlGXPdoWDn+uxKFoIINk+UhC49yBqxySNPf39DtUvpe/DknWhHx F88/f+hAMm/hV4viuWCJFnMmfNiqE+9w9mTfzcjcBnEJgut++qNfv38FbxOi8KCJ ZXp1sQi19V6GFmCF56G3yDDh8pzYxp5/RD+xbZihiu0ofezHqWzCvJRlceQ9Cu3E hjX74b8sjxfIoNeRgRGv2SHv+K3h3UztkSa+pz5+yMz367GR8l/zxasnS+vVKQ8j CdO2Y4WHGmwEsBHjAxI40RkmovVPU8Vd5pDrjypBE8uwqzwKF9R5V2gg/uFBvv15 KZyobEHV5Q== From: Ben Chaney Date: Wed, 03 Dec 2025 13:51:19 -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-3c12e0a61f8e@akamai.com> References: <20251203-cpr-tap-v3-0-3c12e0a61f8e@akamai.com> In-Reply-To: <20251203-cpr-tap-v3-0-3c12e0a61f8e@akamai.com> To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Stefano Garzarella , Jason Wang , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Eric Blake , Markus Armbruster , Stefan Weil , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Paolo Bonzini , Hamza Khan , Mark Kanda , Joshua Hunt , Max Tottenham , Ben Chaney , Steve Sistare X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764787886; l=1432; i=bchaney@akamai.com; s=20251203; h=from:subject:message-id; bh=ybfQKPvFeL2sBlrQktra1uae8irgJMED5+q0/d3iGMY=; b=rg7zTjfT3ixnbbFdX2jzPZ/ISY6BkmHvB+4CRKRmZwTQh2JA3SldPyqy8PGjcJKH6L+B+IzbQ YomMPLzKLJmBFvJQykbYnCYLXt1TBxPPdC8j6bdqa05gRbj20+MWiCD 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_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 mlxscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2510240000 definitions=main-2512030148 X-Proofpoint-GUID: rHBQMF77W4e5ezlpkbQaGCRR5cRxmGsc X-Authority-Analysis: v=2.4 cv=I6Nohdgg c=1 sm=1 tr=0 ts=693086af cx=c_pps a=BpD+HMUBsFIkYY1OQe22Yw==:117 a=BpD+HMUBsFIkYY1OQe22Yw==: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: rHBQMF77W4e5ezlpkbQaGCRR5cRxmGsc X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjAzMDE0NyBTYWx0ZWRfX6stM5Kuyw+v+ sEfy4AwwAmNyi1icEJqliZZNLz4se99mlCrEr+KY9Oyz02++3wyFjAxLbBgQuZDUt3KWOgSaWMo 6FbAU8bRPaK74dmv6ticmg2jVhHjlzgiNebvzE4WtanxdDI/LD15MttMrZr7kCkoryCKCh9Hhyv /VSzVKPp/zz3bAt80fzUgY8Ba77ggUtUyd4cxiogYzA+RzvxKK9HFiu82PaOe5ZDwO7D95X3EQ+ /q2HJGTSy9vIRIAw3uGVaDzmTDJGk9rPXg1PtfEzwC0jYIGvfhj0gZmSVVAYd4qCWXEwiygGcg/ DQnDpukTwnPjpCPxhjldYPOhWsUUtcFDNHnU6DgS4iE1/NQLXsHCBILrl/lG8AxxUZdeVIjLCi6 SrAykQQJiJcUvUA7y68O8wllPaXbmA== 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 impostorscore=0 phishscore=0 malwarescore=0 bulkscore=0 clxscore=1011 spamscore=0 lowpriorityscore=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=67.231.157.127; 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_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1764788020726019200 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:37:32 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=1764787987; cv=none; d=zohomail.com; s=zohoarc; b=AnT8EZmZeEuYrFWPvP3TjhGvX/tOrhZZokaiV0+H40FbE8J7qfpD+kv+zGxUxOuyz+MCzWoQq5EI3QdG7Fkv9tOfb9Lix+FbRjTFbklcPNvVStHKRrHJ3+8JZvsNtI8if/vXFHZqI5+Bx0g4n95dkeaVLr1bEI2KnejoJSWLuXQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764787987; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ljRmB77NnqAdrgPEzQrr268ITHscsnHq1PoRVyI/Pzk=; b=m832gUMOcOwLUCfAEJNrKtHh6XA1EA1C5DqpC20/CdRfeL774Krf8sO7SS0WLivX11C6zCadnapFV4v4XNe6PsosPXsWwd6QHD9YfEksdRqLIYDqDtAkdzmrgv6UVmsMeh0KMBpj6+og6th+iqrACGfmyaq0nme0Lh1seoC5sGs= 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 1764787987120411.58553044155633; Wed, 3 Dec 2025 10:53:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQrwq-0007So-VV; Wed, 03 Dec 2025 13:51:32 -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 1vQrwp-0007RK-Sg for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:51:31 -0500 Received: from mx0a-00190b01.pphosted.com ([2620:100:9001:583::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQrwn-0000zX-LE for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:51:31 -0500 Received: from pps.filterd (m0050095.ppops.net [127.0.0.1]) by m0050095.ppops.net-00190b01. (8.18.1.11/8.18.1.11) with ESMTP id 5B3IgRqW274411; Wed, 3 Dec 2025 18:51:28 GMT Received: from prod-mail-ppoint6 (prod-mail-ppoint6.akamai.com [184.51.33.61]) by m0050095.ppops.net-00190b01. (PPS) with ESMTPS id 4atm5s6d01-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 03 Dec 2025 18:51:27 +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 5B3FZraq026859; Wed, 3 Dec 2025 13:51:26 -0500 Received: from prod-mail-relay01.akamai.com ([172.27.118.31]) by prod-mail-ppoint6.akamai.com (PPS) with ESMTP id 4aqw21kxw3-1; Wed, 03 Dec 2025 13:51:26 -0500 Received: from bos-lhvkhf.bos01.corp.akamai.com (bos-lhvkhf.bos01.corp.akamai.com [172.28.40.75]) by prod-mail-relay01.akamai.com (Postfix) with ESMTP id A91DF97; Wed, 3 Dec 2025 18:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=jan2016.eng; bh=ljRmB77NnqAdrgPEzQrr268ITHscsnHq1PoRVyI/Pzk=; b=PdQGilVoAKBs uZelBYn2NQyhZ9E4p5Y197cGB6Xo51/7pLjJsVhFl2UvmqFhi8mMvcE4zwhNhe+j kl+/wYe5Evg7lux92HjOC4c9Oz1FzJThjWAxehTeFtbWpA6/VZPzbO2Q8WAF2yGg 6m7bYWzm8EDY7opnq2UkYZRqqy07kEwWix0VVYkS/s4MxED+PMQWoq9WZ1Xj/6m3 jfvb2zYviLhmKuIBwj8NW5OtcUtHS1diCJJX+3migRnsp3ceR4Pl1pfLpnykoD9U qzkyB/Q2dljfK6pJ54zHuL6R8pwvfA6Zez3GbaBIonMg6auCUx6/S39C5NJ7yKrW j8GdTu/VjA== From: Ben Chaney Date: Wed, 03 Dec 2025 13:51:20 -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-3c12e0a61f8e@akamai.com> References: <20251203-cpr-tap-v3-0-3c12e0a61f8e@akamai.com> In-Reply-To: <20251203-cpr-tap-v3-0-3c12e0a61f8e@akamai.com> To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Stefano Garzarella , Jason Wang , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Eric Blake , Markus Armbruster , Stefan Weil , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Paolo Bonzini , Hamza Khan , Mark Kanda , Joshua Hunt , Max Tottenham , Ben Chaney , Steve Sistare X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764787886; l=5230; i=bchaney@akamai.com; s=20251203; h=from:subject:message-id; bh=6kTSGt3ELi899SPi+eJ4MTXel5sLxi3unzD950w6j/M=; b=2vhlu4zmfRGEftDje4PhskkfZjP3zx3oOQARS8sNrREatZVToDTYrrzWyXmx/RE4MbvmWxQjM ZJrTmfATuGfBqoiBKL5EtDV3rWBnbm4+QGMCjJJ+spjwCYa15YekUHP 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_02,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-2512030148 X-Proofpoint-GUID: RVkisURAx_c3pRunJDSZVbm65r6TfD-C X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjAzMDE0NyBTYWx0ZWRfX2sKSOrMead+G d7JCGWZ9kh43d7SmEygI9fwOegwJ/jUBkNK+eor7ORIW88HwBQAojilIEICahZGAJEWKkztR6Fp jLgl/iUNVTc5ZTaZJAt5f1QYEU/zA4Aw+WPQ+gUcPvCaxW83ErYAhy56nK3kyG+qkJmcQSxh2c5 ZwK2O7opZn5+VKyO+gukV/86PAVcjZd4PdtMTzO7SNN9YIj8VaDCutdd2kpF53yrhxNQYsG7l6f 7s2bGvRY/KJyJmMSmiqrbpLlPK3I8l1Km/UnXlf7eQ5x9vV91pwtr94BkzQSNBRhePbJi6V8iYY Mt7iIFLN9/v70fuiYc2q9KCaP+tl/xIcpj52wqAojJPCbxgQfMzkAyrFQipGIqqZOY2mKSnT/ym yb0s/iKIONgSGEtcwpOCOOOWaWj+dg== X-Authority-Analysis: v=2.4 cv=VdH6/Vp9 c=1 sm=1 tr=0 ts=693086b0 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=6lTwf2g7YyX0f-ifu7AA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: RVkisURAx_c3pRunJDSZVbm65r6TfD-C 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 phishscore=0 bulkscore=0 lowpriorityscore=0 impostorscore=0 spamscore=0 suspectscore=0 clxscore=1015 priorityscore=1501 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:9001:583::1; 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, 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: 1764787988299019200 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:37:32 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=1764788001; cv=none; d=zohomail.com; s=zohoarc; b=SyRp2VtOYuZP7CXLf8OgQ/wsvAgvFckl0AkTh5j0JCfDJOTLnpLqOg8egBkIDQAABx94TqY00PlEh/XFuJwH7+vv35Vu5pU0pjkly0JtZzFaXZKxlnRFyR0cEO73htzrCDxc0ZvP/s8QJCG9N4ZK0606YVAhAEiLI3sZQXMGTvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764788001; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iDI9J/2kQZuf9g4MQ4HQ3luovEdJMVHjXyCsvqkM41I=; b=L0+z1q73jQR/tHZ/bGf0m9ddKvSfafT/kFbOFibuKEDyi1mgtaU5xNHKag+Ouj18kV06zePl+Lm9uE6TtdfbgbzY+aMSCgRLIrGFrhm78vaIe8KGTLu4G54mB+iefH3E7EVV8Bgu+lKSzqWntIBAFJ0ILLX1ZgEJFD58RwWBd2k= 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 1764788001367900.410289560582; Wed, 3 Dec 2025 10:53:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQrwr-0007Tv-Uc; Wed, 03 Dec 2025 13:51:33 -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 1vQrwq-0007SZ-E5 for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:51:32 -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 1vQrwo-0000zq-5B for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:51:32 -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 5B37fSXO3673740; Wed, 3 Dec 2025 18:51:29 GMT Received: from prod-mail-ppoint5 (prod-mail-ppoint5.akamai.com [184.51.33.60]) by mx0b-00190b01.pphosted.com (PPS) with ESMTPS id 4aspcaafqy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 03 Dec 2025 18:51:27 +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 5B3Fjee0029587; Wed, 3 Dec 2025 10:51:27 -0800 Received: from prod-mail-relay01.akamai.com ([172.27.118.31]) by prod-mail-ppoint5.akamai.com (PPS) with ESMTP id 4aqypdkm40-1; Wed, 03 Dec 2025 10:51:26 -0800 Received: from bos-lhvkhf.bos01.corp.akamai.com (bos-lhvkhf.bos01.corp.akamai.com [172.28.40.75]) by prod-mail-relay01.akamai.com (Postfix) with ESMTP id B0FAD9C; Wed, 3 Dec 2025 18:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=jan2016.eng; bh=iDI9J/2kQZuf9g4MQ4HQ3luovEdJMVHjXyCsvqkM41I=; b=nvx+pTE8vwzI 2gD1ms4hLUZYr/nfhI/HAiKANBntZlJZeGAO3pgJXWupg4HtyEhwTRIpuZHFtzmb nVZCf7CLBbz4bUGufdM+en6ykC9nd3bBoGFY/FIBEi11Qluo0kwZvvgSfOtf2iiU NIqSHc4PMa+ok4zyE7dyxqyc7xupq426fnKU3uoUAqYZYNDjBnBkbcNNU2Xd9EUr XPT+PqwhA5iGqUHOT3+096TnBS4aevahRWzQavXva+YA2VrzyLUzOwYy4JD+ptnh hFuLw+Wkp5wJscQ8RQ9dwq6IwVzEcZ2hzaJmetoUYsP0SKNU9oH7mj6R8Xef2ENO Y74MXHvIfQ== From: Ben Chaney Date: Wed, 03 Dec 2025 13:51:21 -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-3c12e0a61f8e@akamai.com> References: <20251203-cpr-tap-v3-0-3c12e0a61f8e@akamai.com> In-Reply-To: <20251203-cpr-tap-v3-0-3c12e0a61f8e@akamai.com> To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Stefano Garzarella , Jason Wang , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Eric Blake , Markus Armbruster , Stefan Weil , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Paolo Bonzini , Hamza Khan , Mark Kanda , Joshua Hunt , Max Tottenham , Ben Chaney , Steve Sistare X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764787886; l=1519; i=bchaney@akamai.com; s=20251203; h=from:subject:message-id; bh=Damz0E1eWx9seXrv9+FOKa0jx9R91HPkz/OMuj3AucM=; b=jWF0pcBBUYtCUa/z42DoxeJeZNgPPoR2VI14vXymAm4iU02JIen8LSSLM22ipL3ND7Soc+m98 f0NxkFp6bDnALaj4tL+SD1V73BM5t1tdI2Y3SfZ7k6cmZ0maI5+P6ur 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_02,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-2512030148 X-Proofpoint-GUID: vuWFN3Ek-Ad1NLybjK4zzAUsSBHQ8uGd X-Authority-Analysis: v=2.4 cv=c5umgB9l c=1 sm=1 tr=0 ts=693086b0 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=n655hgSsutws6UkWyQYA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: vuWFN3Ek-Ad1NLybjK4zzAUsSBHQ8uGd X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjAzMDE0OCBTYWx0ZWRfX17ttQeV5tjmg AICkf9hTAbxcUZx0Lb9mPAVkhlWp2Wn/05UUnPtbdBtlCWo24N3ikX5e4SjEjCRoB7O5bQrpIXZ RqOi2MxBUyAm2NXqY8mifa73k4FWTgeoElWX6s8nCcmtCwjonn4/AaOhxQDFrETGf6HSjsop1I1 rJqXzRgheKBA1N5dnQ+OaCmC7SobRviVbMWflKhY/p0SdCeQMG12aAlYb6A/kGqRNVDT7B2axa0 Xy3/H2gEITZESG44lGzIMstcH9HxiP7SryVBiOiKmNj4kv8DXb4X984isCYHYW7SCZIhz5BCPnO cOeyv8m1o50wK5hXW6oiJZABlIl0QypFKrAcqc87XL4s2oGxC/eRpsnLIXZ5UNfZftht6zZKUE9 YeYkcxfqi4c08sW1hnl6hmUnbFSLmw== 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-2512030148 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: 1764788002424019200 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:37:32 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=1764787997; cv=none; d=zohomail.com; s=zohoarc; b=HgrWvS1c0AHZvTFrICOiXupdo3dDSL+RsSE/y0rsC8/YTfZYXGv0Nha1eJvA9kik9KpON0iTXwqUtcSZCfzviXNX6kWnYHG7dn8soyvRg/tZWwLn/93IK5mDQJewINuDIL43VXeLOGybdMi9+qXYo3Bn6jfAgXsA3nJGSY5kD0I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764787997; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NID9cQ6TVR/7DxrIYOVpRG111sFYubPS/LHG9jXZ0ns=; b=hkWCX+85XBduiE76bxbY5HXi53dT5335pxJWwVrFDJvCmOPe+A+TXKnN+SNKL5mjDMuk2ww0CruKsWjRP6Qqy01E6HcVr1m7wQBG/10hLFTMEWtI9MzUo/GiODvZ2aR/eXWzzGrCKBVeAm+fKY+28ArPDFTCkA4BDmKVwmvOz54= 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 1764787997246664.5277403800862; Wed, 3 Dec 2025 10:53:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQrws-0007U1-Bg; Wed, 03 Dec 2025 13:51:34 -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 1vQrwr-0007T3-4J for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:51:33 -0500 Received: from mx0a-00190b01.pphosted.com ([2620:100:9001:583::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQrwo-0000ze-29 for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:51:32 -0500 Received: from pps.filterd (m0050093.ppops.net [127.0.0.1]) by m0050093.ppops.net-00190b01. (8.18.1.11/8.18.1.11) with ESMTP id 5B3At5Tn3309304; Wed, 3 Dec 2025 18:51:28 GMT Received: from prod-mail-ppoint5 (prod-mail-ppoint5.akamai.com [184.51.33.60]) by m0050093.ppops.net-00190b01. (PPS) with ESMTPS id 4asw4c3scu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 03 Dec 2025 18:51:28 +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 5B3H6aDf010754; Wed, 3 Dec 2025 10:51:27 -0800 Received: from prod-mail-relay01.akamai.com ([172.27.118.31]) by prod-mail-ppoint5.akamai.com (PPS) with ESMTP id 4aqypdkm43-1; Wed, 03 Dec 2025 10:51:26 -0800 Received: from bos-lhvkhf.bos01.corp.akamai.com (bos-lhvkhf.bos01.corp.akamai.com [172.28.40.75]) by prod-mail-relay01.akamai.com (Postfix) with ESMTP id BB053A8; Wed, 3 Dec 2025 18:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h=cc :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=BfT2Pa1BkoP/ d4RDQAubQafAKblmz2R4g0jm4eMvWZoAlsP/vtOhqAaXglss72i5io4hQRsBT+O/ 68kKqhaFzIlU6YgrZnViO55PPGrejZ1jJ/siZicKnyJ0sQpH9yxOmj9JhlkqtQ31 x05LZ91X/dU0AG3zPOt98mNFPf+RCxtS05OiCV3JR+kAZUPxlA7V4dkQxuBuG0dE mDNNEvyF7+kDpDs9DObAwrA5PtpRrxEPqsTgaggp1pV1KNNkUk6icGraJEEdjxsn RN/HamoDSxfSs/fCt9C85fOWVKRzmVxy05uoYe8mnPBryg+EWT9Dun7FRT5JNTSk W+RKpXKMQA== From: Ben Chaney Date: Wed, 03 Dec 2025 13:51:22 -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-3c12e0a61f8e@akamai.com> References: <20251203-cpr-tap-v3-0-3c12e0a61f8e@akamai.com> In-Reply-To: <20251203-cpr-tap-v3-0-3c12e0a61f8e@akamai.com> To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Stefano Garzarella , Jason Wang , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Eric Blake , Markus Armbruster , Stefan Weil , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Paolo Bonzini , Hamza Khan , Mark Kanda , Joshua Hunt , Max Tottenham , Ben Chaney , Steve Sistare X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764787886; l=5311; i=bchaney@akamai.com; s=20251203; h=from:subject:message-id; bh=C43PerSzdOjLbyjnfYhRXVpakesxZD1fRN+2JrhKpv0=; b=EMlxDsBd6GbwvzPIhmQMJg5iPXlg4CXwjoJi/ms+Om4vFMlOgnGy2BonMRVJxJov59QsrQ/to 4+opHPp/NC/AGZuaDKY1xEvW1dWw6JuaUxLUk/LQmlc1JzCksa2sg7z 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_02,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-2512030148 X-Proofpoint-ORIG-GUID: N4HEc5HaniSCw9t3f3932bso0dr4VFJD X-Proofpoint-GUID: N4HEc5HaniSCw9t3f3932bso0dr4VFJD X-Authority-Analysis: v=2.4 cv=Y+z1cxeN c=1 sm=1 tr=0 ts=693086b0 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=zPeY32rCmRbJBjnbAY4A:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjAzMDE0NyBTYWx0ZWRfX7LqgM8gBd742 1Zr2OmJlpvdVJBbhzIfJQexoHsRFYGEKWLb3GQYJ2ww68x6TSUawXv58T6R5ZqWzQlZHJaUjMIh +6fSB+QA01tPRnJ43v+XwXfUMe2joQwZb7tgjC7pwrBETw0LFHhuywv1fn/2mboY6RwnyfFDh+J xrQbalNISoEC4X2Zlk4FDHwby7yCM0mCSvKQ8wz9EUKNibxbZB4Ufi1+Hk5VhBKHOQNyO5FYfxK uoeX+5W9jr4J+9PNGn/eBOoQ1+OeYJWllvuwc+b7vjFEukpGRAQFHashTDshmcPQ9+VbLnHNeSJ hVPPUm7vRhnr96HFIstAQUHTRkIzPUcTe4cb4qx6gW6TeRZmn0enApWLCOYNbxRrevH9NXP28dF VeU3V88yI9mOTL0Jkj/EyfjV1Mo+Gg== 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 clxscore=1015 adultscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 phishscore=0 spamscore=0 lowpriorityscore=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:9001:583::1; 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, 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: 1764787998566019200 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:37:32 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=1764787995; cv=none; d=zohomail.com; s=zohoarc; b=RgGJ/inTJaEEYMLNslKjrH6h3ivmFhdlUn4Umq/DidBpGDHcTNeu9AlvZ+xMDBgvjxxWryXFYthyxF6JvUGgqunaJnS2O3PQTQKZ2C7t/QJgGV2rPEQHEUJRMYhI4yhqNl9qyLmm9EJK/+PQUqpWT5tafkOTGqGwRnTqWR9YgNM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764787995; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sxAo1uqskNqifb7qfIk7I5/SJimHpVVq96+8uOmNsQM=; b=h/hLIAf2Iipd05tbV6RM5ekt0+iVQAalUyq8aP90SeNG3j5Dq4NiF/SRDV88G3jcegaxyLxNWKT5Y9d74Pf4dEfNpOkI3BOU4zw7VtnpXg1HSxFvr0xpzpL9SR+OwZm3ch3Cfkhgd7mpgh1EFitSyLIzMgEUc03FkD8eu0ZdRic= 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 1764787995277351.1885057717403; Wed, 3 Dec 2025 10:53:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQrwr-0007Tt-Oy; Wed, 03 Dec 2025 13:51:33 -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 1vQrwq-0007SF-7C for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:51:32 -0500 Received: from mx0a-00190b01.pphosted.com ([2620:100:9001:583::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQrwn-0000zf-QJ for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:51:31 -0500 Received: from pps.filterd (m0122333.ppops.net [127.0.0.1]) by mx0a-00190b01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5B3GpZ04539770; Wed, 3 Dec 2025 18:51:28 GMT Received: from prod-mail-ppoint1 (prod-mail-ppoint1.akamai.com [184.51.33.18]) by mx0a-00190b01.pphosted.com (PPS) with ESMTPS id 4ats3m9k85-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 03 Dec 2025 18:51:28 +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 5B3IgOHp026436; Wed, 3 Dec 2025 13:51:27 -0500 Received: from prod-mail-relay01.akamai.com ([172.27.118.31]) by prod-mail-ppoint1.akamai.com (PPS) with ESMTP id 4aqw21m4m2-1; Wed, 03 Dec 2025 13:51:26 -0500 Received: from bos-lhvkhf.bos01.corp.akamai.com (bos-lhvkhf.bos01.corp.akamai.com [172.28.40.75]) by prod-mail-relay01.akamai.com (Postfix) with ESMTP id C155DAC; Wed, 3 Dec 2025 18:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h=cc :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=MhGceqx3ZOEv vWWf8DODDR6xRowgZOLNXGnByjp6Y37Xo3l770moJIHjqHYKKB5dhHh84cYdHWbe T0aG4QoraJvrVqPjM1OsVVu7Yg5lzSTdlNNfBWU78Z1IjnMMmFbFsGq7XIK64dww MwuNAQIJmeICxnSXcYWw7H8ey/D3ZhEkd4rlZrYQZHD+lxAsoAVkvTvIT811u8vD fYifKDBVxFfeiqYE8VPLx/OBg4SrC3ASibZjkUn1sJYDYsiZEZmCxNXhPilRauUM 3oZffI2xgnSWZyZfxE/Y5THC8OUE/JsAgLXIqqX9r5QvXd8nM/toXM/Mm/WU0XjW GD2HuBSoPA== From: Ben Chaney Date: Wed, 03 Dec 2025 13:51:23 -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-3c12e0a61f8e@akamai.com> References: <20251203-cpr-tap-v3-0-3c12e0a61f8e@akamai.com> In-Reply-To: <20251203-cpr-tap-v3-0-3c12e0a61f8e@akamai.com> To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Stefano Garzarella , Jason Wang , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Eric Blake , Markus Armbruster , Stefan Weil , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Paolo Bonzini , Hamza Khan , Mark Kanda , Joshua Hunt , Max Tottenham , Ben Chaney , Steve Sistare X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764787886; l=12397; i=bchaney@akamai.com; s=20251203; h=from:subject:message-id; bh=3xg4N8thwWZW4UJ8SY9X2DDt88vnbdrhVb/PFvVwcXA=; b=rvfWZj4lo8VPGCE/2nXX6mT7x4gsUXOUoIyQcm4xrveXjCksszbGRKYEmmjdTwA2lh5GxzATk 7H28wfb5aiFBWQSTUv6zw6JXYfWcROr0xuNVbLrU+mLsvfyWyYSFcT4 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_02,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-2512030148 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjAzMDE0NyBTYWx0ZWRfX5CH5eO+69jZc NKZa7MGiaitAY8PnM3YmvaHR1E4wc4nWZkgAGRrMZwUS+PT/Apw0Yxe3KZ0kn1lT0saBrTWl0ve v16N+lHVTqSV4T0P7Ds2hgwqUiXI/HL+9/FJwSqj86aW6X+j7pMoP57Lt0iYT8nh5iKuLmYrACv RI4vmSo0HamIMH/6cizDlsIRE3LAS3jQCURyG/XyZm5fz4woxLZmjXrtrIFeMcLSvdOxVJMWIHs fi/3beZvP5soLyiRSHVQPmJWMnF7yZwFev0rVDrRj9vpKgK607sokI65zO/HmwTXxcbWTCQk7j5 TDLBYs9DFsXV3P5tReCckP6wWboBaE/vcjfjLA8lhe0dkQObQVB5MUW7Hpo6safCIhakBjEQANp RkgZPhjR3hIiE73CsbQDaBdr79nliA== X-Proofpoint-ORIG-GUID: 13nnXTbLLljLafayvDXa1h_Ao5NjaNh3 X-Authority-Analysis: v=2.4 cv=GIMF0+NK c=1 sm=1 tr=0 ts=693086b0 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=DrAZhfO-21Mt0ZXRAbIA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: 13nnXTbLLljLafayvDXa1h_Ao5NjaNh3 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 bulkscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 impostorscore=0 spamscore=0 adultscore=0 suspectscore=0 malwarescore=0 phishscore=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:9001:583::1; envelope-from=bchaney@akamai.com; helo=mx0a-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: 1764787996491019200 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:37:32 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=1764787919; cv=none; d=zohomail.com; s=zohoarc; b=lGTcN+ZWeik2z9FxYGBOfv6Lk+zl++TT4fhDjn2TJ+vjfE04lvnQb5YMO4uwcYIHLhIzff20nti4dNRp5VbLkzieNHgZXqrHurq3FIO3WsrmlM98ft5z9Rey0cZr9ozHMNFf7jlUqHjWUGh3vowgPtYv4XabhRIfBu3LNoe+PF4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764787919; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QoR6CzW42yFuzK4C/5cibENCPr6ROAzmTT9DkEW4Iy8=; b=TQ4RZreuzaRMwlyLSCWFcAxQW3dBd1ivmNMzPLitLG9iQVgq7aa90lg1hzWQil/yk06YXMQfn6MeVmUcUtsDicqC9Fi46gxZcumAj6HrX9uv+TwtPr6SmrotiLVKwsXpDjfRAxDFHEp+RWPdxYADx16QkdNcIXecYWEAhmM2yKI= 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 1764787919222298.3851816982876; Wed, 3 Dec 2025 10:51:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQrwu-0007Vg-Ql; Wed, 03 Dec 2025 13:51:36 -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 1vQrwr-0007TB-7l for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:51:33 -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 1vQrwo-0000zh-CM for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:51:33 -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 5B35lAR22445836; Wed, 3 Dec 2025 18:51:28 GMT Received: from prod-mail-ppoint6 (prod-mail-ppoint6.akamai.com [184.51.33.61]) by m0409409.ppops.net-00190b01. (PPS) with ESMTPS id 4at0bcqtuf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 03 Dec 2025 18:51:28 +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 5B3FSw37013454; Wed, 3 Dec 2025 13:51:27 -0500 Received: from prod-mail-relay01.akamai.com ([172.27.118.31]) by prod-mail-ppoint6.akamai.com (PPS) with ESMTP id 4aqw21kxw4-1; Wed, 03 Dec 2025 13:51:27 -0500 Received: from bos-lhvkhf.bos01.corp.akamai.com (bos-lhvkhf.bos01.corp.akamai.com [172.28.40.75]) by prod-mail-relay01.akamai.com (Postfix) with ESMTP id C5108AD; Wed, 3 Dec 2025 18:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=jan2016.eng; bh=QoR6CzW42yFuzK4C/5cibENCPr6ROAzmTT9DkEW4Iy8=; b=J/TL4B/XdrCh mIXXuUu8/k5TcGNg38c3pbGb+5z2sdBGoW4nZcKpH/ti0xaRcDN7iF3pGJ2aj+z0 Dn6tsyXl/28GB7bg66oKPLZV0aFXK+7kSvapOJWT+PGxE5jEXLNZGwWn9CbQdpmi /NpZIwOMWdNXnX1bdD0qoN02Mv0MIGiWYJ9by7z+0ZUW48PBLykxpWTDX3j25Xf0 3aV9izqj5sJnfObHGNuAO1ap1BEm1qH7c6xWkAsiBEJ0PEnRHFQblD0k4B38zcdB epHYf9dgUnzMF+ZGe3FSI9zqmINpaizCjGXP7PRYU8FyedzDMI7ZxodHWOcLlHvt qT1xyeBI3w== From: Ben Chaney Date: Wed, 03 Dec 2025 13:51:24 -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-3c12e0a61f8e@akamai.com> References: <20251203-cpr-tap-v3-0-3c12e0a61f8e@akamai.com> In-Reply-To: <20251203-cpr-tap-v3-0-3c12e0a61f8e@akamai.com> To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Stefano Garzarella , Jason Wang , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Eric Blake , Markus Armbruster , Stefan Weil , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Paolo Bonzini , Hamza Khan , Mark Kanda , Joshua Hunt , Max Tottenham , Ben Chaney , Steve Sistare X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764787886; l=3307; i=bchaney@akamai.com; s=20251203; h=from:subject:message-id; bh=trjqxlGTjzbMkDT7mRMw3NXMaJd7F2w+gOl7JrhHwFU=; b=KASaKdIYRViwhLCPvoDl/4aura5SsKK/BZNj31N/hBE561HUCpLeNJeLCwgPNXoTRiVtXjvEX dbVbbFNRxZiBydr31kfBj6DJK1sZ4/Nqq74psOVaLl9fGGbwG/Lb3rq 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_02,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-2512030148 X-Authority-Analysis: v=2.4 cv=AvfjHe9P c=1 sm=1 tr=0 ts=693086b0 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-Spam-Details-Enc: AW1haW4tMjUxMjAzMDE0NyBTYWx0ZWRfX7DDURGHGMDVc +fFyxPMaeFVcw5bL0e3AeOVVnqXl9VqAL/QECLBngotcgvv6SeY0ErUqp/gYTUrpKosW6A2UXS9 2j2Nx7rsmc1vjfbWV0VhtdmV0gbUIlJDw7oKK8gqKrQdp83Bfx+NqfKrz9X+lCzOeZWQUdPWS2O HbPHVkFDKwV0lGh++bJgxbKQuzPuNuboyxRm42+4eY9qLjolf7Wuq6iXH8WY/PMGNuYIIheYNJ2 4Alu2KhNKGWbKgSOSyV3ZNIqocGMrjO+TqUH+kk5TmUxqaCwBwsN0/A5hQXQhdgUgamrEfel723 BxT++Nipv2eeoBlcgMUDsQ6V2zSTiVoeErF+F6140UlJP1nFf168WEIxGg4LlKoaypge3IvfBvj j8THIC6+rx1+3pgshE11oZu1ChDgmA== X-Proofpoint-ORIG-GUID: mvYb3buKW0Na5AehXPWbGpI8XwXmzzb_ X-Proofpoint-GUID: mvYb3buKW0Na5AehXPWbGpI8XwXmzzb_ 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: 1764787920733019200 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:37:32 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=1764788018; cv=none; d=zohomail.com; s=zohoarc; b=CEbluZGsGThYMba90ZR72K9nDvRBWCvymxIDUDyxaH8vgZpbLgGDectrigLqDmTlVfODLhOIpTGJrlDBGoEfvlGe3hBdXE+TxOWUnPLnUWUSUDgtEjdIVlqLxvccR72tfMTVjQQwFrvlGNXFuHh3kfPlkHLswSW80f8kmwr25Aw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764788018; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2tqwxUShjbp6xB29PdE2LrVae4u2i8bzJmQKHr4yHxs=; b=bjc5GzcJM6nkY4dteUZUcxqXkbJw7XMY8bVHeA7dA69fyHbK2wbCtzMcOdwg/9ZfxlWnmZ9aoxDVAf+gqVvVAaOxUTdhpvxJiASTELGbg2/bS3fOyixzM5ZhzVSaX6Pl7mttzXvC/OcvyekvXQIDEFe7wJAmEmtn/J5d1NL2kjw= 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 176478801839148.28010732695748; Wed, 3 Dec 2025 10:53:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQrws-0007U2-C9; Wed, 03 Dec 2025 13:51:34 -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 1vQrwp-0007R4-Ka for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:51:31 -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 1vQrwn-0000zV-6M for qemu-devel@nongnu.org; Wed, 03 Dec 2025 13:51:31 -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 5B33Ma8C3199729; Wed, 3 Dec 2025 18:51:28 GMT Received: from prod-mail-ppoint2 (prod-mail-ppoint2.akamai.com [184.51.33.19]) by mx0b-00190b01.pphosted.com (PPS) with ESMTPS id 4aswun4wr7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 03 Dec 2025 18:51:27 +0000 (GMT) Received: from pps.filterd (prod-mail-ppoint2.akamai.com [127.0.0.1]) by prod-mail-ppoint2.akamai.com (8.18.1.2/8.18.1.2) with ESMTP id 5B3FlNNc025617; Wed, 3 Dec 2025 13:51:27 -0500 Received: from prod-mail-relay01.akamai.com ([172.27.118.31]) by prod-mail-ppoint2.akamai.com (PPS) with ESMTP id 4aqw21kuh9-1; Wed, 03 Dec 2025 13:51:26 -0500 Received: from bos-lhvkhf.bos01.corp.akamai.com (bos-lhvkhf.bos01.corp.akamai.com [172.28.40.75]) by prod-mail-relay01.akamai.com (Postfix) with ESMTP id C885EB1; Wed, 3 Dec 2025 18:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=jan2016.eng; bh=2tqwxUShjbp6xB29PdE2LrVae4u2i8bzJmQKHr4yHxs=; b=FZMpFX+iioNV Rg45FYoki05zTp5henKbiAIpGCw5BcyXNWDzpX/5CTAO2xNY3UsPhWEgdmI0nyC2 yzC/szCm5p6anXvyfXAy+VZmxnL+m432x9lbdf15AxJBEj5syv8SHAfPqQdPFbKM uy1VRSnpPAKo4B8UCadAwDBBB0uQLV0/90yJeBM2BUGi/ZopiLg2HFFzZn0FHC1d 8wX1O6FhEeoE5dfrq3zRrA6cjwfHlmWRh3Qnoo2leWbdMUCtMHujwMFmuJfiakBl kNrIs88IGsrFTlzx6pFWyKeNQhdCOstgQ+qXT4cHeMN1nedTPnkeJh/8xkU8PN7f 1QkgP3TSFw== From: Ben Chaney Date: Wed, 03 Dec 2025 13:51:25 -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-3c12e0a61f8e@akamai.com> References: <20251203-cpr-tap-v3-0-3c12e0a61f8e@akamai.com> In-Reply-To: <20251203-cpr-tap-v3-0-3c12e0a61f8e@akamai.com> To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Stefano Garzarella , Jason Wang , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Eric Blake , Markus Armbruster , Stefan Weil , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Paolo Bonzini , Hamza Khan , Mark Kanda , Joshua Hunt , Max Tottenham , Ben Chaney , Steve Sistare , Vladimir Sementsov-Ogievskiy X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764787886; l=3243; i=bchaney@akamai.com; s=20251203; h=from:subject:message-id; bh=zPYWBDaP+GisG/WA7Z9aDp07+oXAyy1rWdyxkJgQ9vw=; b=sBJh/idUqjxmDyH9Pr7QzvSgVio9NhZuQGQeVDKCNcACRT+mG5c5YzFhYxDlufOU/KEKILuXA sRe+xn5pkJUBiJrzjX3ij6kFG9YyITMukBLNRFRd7QMtCYzQ//FK1OQ 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_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 mlxscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2510240000 definitions=main-2512030148 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjAzMDE0NyBTYWx0ZWRfX4As9gSnRRMUa XKqWC5ZRt8vwsQXf+rhRK5OW2lMtLGPrp3eZ88dCSXhC4UJOe51Oax74+gs8LlyODxjtS4oMfvT /DClhltHM3LBc0yVn6V5M0uO15KHPtd7Vv6E7nKT6S/lHBZncUpLIfi/Jf8mDGRW4mFOpS2NwyR 1tTLyaNQzfAd0vhnYYlL0TbT/JNfmCXrjhr1umQW3FT5jHwpGyxLlboKkghUebuR6UzXTwCxXg2 wejQikXhtCzjCgrxX9rE4RpOW4Tdl+qVKlaktlyXjjwkds403oNgOFTxI2ChELrhEz2ms1K9iJu wglZhx8+TzfU8+Vxi8qY3a24qM0yd3KJ6QK3BJV39RTOih7AIW+v9tBqc7vLgWs4CJvlkCFDOev 5LXRTFAYlRIV18IAGVX8pczyYXtwiA== X-Proofpoint-ORIG-GUID: avPUBhxORbzDmo4WerdgI9EGyKQVXxFF X-Authority-Analysis: v=2.4 cv=O+o0fR9W c=1 sm=1 tr=0 ts=693086af cx=c_pps a=BpD+HMUBsFIkYY1OQe22Yw==:117 a=BpD+HMUBsFIkYY1OQe22Yw==: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: avPUBhxORbzDmo4WerdgI9EGyKQVXxFF 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: 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: 1764788020718019200 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