From nobody Mon Feb 9 14:23:49 2026 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=1769632860; cv=none; d=zohomail.com; s=zohoarc; b=ipTTtihspJ//MpKQhVnzrYgDECOdVLviEkPmhELyoRWsySvC30XKndjLEwMTegnewgeMNDgIvs93PBpj8xua7sJj7sqdDbX1SRXw2lgp58bst35Zu/EXfEqn9x5CuPsjjQkkkmcWpXaHie/nQFc4YdtwPH4eVZK1gZoAvtEmd00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769632860; 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=VpKSo7dvDuyWSbsFXQ3bXWOKmh2SUJJjQn/1dvaSXYw=; b=Abt8Z3WtAfytRFgSoZ8LVPAQZsxogKZbRPEeDQ48z0Pw6LM/HLXoPnUpWMLticOjk/tCCMp7WFRn9UQZINIrenv04UI8Wi/Hyex+BJupl9cJsH+K+ECqlREKfvrrjVwoJSBHk7EeI+4Rh3+YcDzFHYk+mlrZ7gfJM3ayPfe8LLM= 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 1769632860228267.98948860806433; Wed, 28 Jan 2026 12:41:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vlCKQ-0007kw-Jy; Wed, 28 Jan 2026 15:39:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vlCKI-0007Xj-Ub for qemu-devel@nongnu.org; Wed, 28 Jan 2026 15:39:50 -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 1vlCKG-00084R-UW for qemu-devel@nongnu.org; Wed, 28 Jan 2026 15:39:46 -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 60SHRWWO1128338; Wed, 28 Jan 2026 20:39:40 GMT Received: from prod-mail-ppoint5 (prod-mail-ppoint5.akamai.com [184.51.33.60]) by m0409411.ppops.net-00190b01. (PPS) with ESMTPS id 4bw8a6cv4c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jan 2026 20:39:40 +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 60SFYGux004167; Wed, 28 Jan 2026 12:39:39 -0800 Received: from prod-mail-relay02.akamai.com ([172.27.118.35]) by prod-mail-ppoint5.akamai.com (PPS) with ESMTP id 4bvvxfyxx8-1; Wed, 28 Jan 2026 12:39:39 -0800 Received: from bos-lhvkhf.bos01.corp.akamai.com (bos-lhvkhf.bos01.corp.akamai.com [172.28.220.254]) by prod-mail-relay02.akamai.com (Postfix) with ESMTP id 0A463A3; Wed, 28 Jan 2026 20:39:39 +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=VpKSo7dvDuyWSbsFXQ3bXWOKmh2SUJJjQn/1dvaSXYw=; b=CMm6vy/sslXx 1McLpstjuUdzy0ZLEZYdAEGe9PZBGRa8cg8FxufbxsnhQOKGCNFnI3W46jLfalPd 4LfxSU/gF3u/LZmJrVV94rsR53CDnFEvXu6HKwoXkdhnzCbaUsa/OSWZKyc2xAg6 RzQ2/qShF6OOInbg4MmYNLpA6wXSvwUZwXr2VpYfNbVRHhG3HrLrS09xge0/Tud+ j80ADXY28RzVwO7TgmxZ6bi7iPSXrKqxlNq3BhpHBKVYHQ50k/tX0UWsipUkDn0l QdjZRnFEhEbjZmx764lG4TMtxHu9rTdmTepdjfnEzS1+DlZPQLQ897+L5Uv5Oh79 FrkVX4LUFQ== From: Ben Chaney Date: Wed, 28 Jan 2026 15:39:31 -0500 Subject: [PATCH v4 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: <20260128-cpr-tap-v4-3-48e334d4216b@akamai.com> References: <20260128-cpr-tap-v4-0-48e334d4216b@akamai.com> In-Reply-To: <20260128-cpr-tap-v4-0-48e334d4216b@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=1769632778; l=5230; i=bchaney@akamai.com; s=20251203; h=from:subject:message-id; bh=fmXj30u3JtRIrwcd6PJUKYFgVyJebbXBSc5CMyYvc3U=; b=3yB+uiXhMIl2zcuNoDiOGDGvLml5IwnJWCBmmBhmCAev6E98liZEmkfvCHfMLsnvJ6iB6BP+C /pCdQp9n5uuD5rgMNc8WAzDFVGZrRANah9ZNgAb1DDDkEKjtfehUqk5 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.51,FMLib:17.12.100.49 definitions=2026-01-28_06,2026-01-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 bulkscore=0 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2601150000 definitions=main-2601280169 X-Proofpoint-ORIG-GUID: IINWAyS4-QIbpb6hA0byL_lG1egR_BiE X-Proofpoint-GUID: IINWAyS4-QIbpb6hA0byL_lG1egR_BiE X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTI4MDE3MCBTYWx0ZWRfXxTrp8UCofi5Q FfzFeOTZR+9FChmSz6hVIm6v85OsF7SWmreujV/8QDjyew67h5IRNmJCkBAMqrwYHODD1USw+B9 stvNAWeuWwGHJTC5+grEOmkhnpzFMF+SJCFHl61AKaRKvxcHo6OQXGzwFOy0LSaFxjaV6YC2Q/M xPaEeI5vEMRCGL9byPHYFnu67oIDZ2ROHcBwidAUVh/S6Y7w2HQtF7VPTT7aL2yTo5DmtNvl8sy uKBw4AEEfX8AsQ5zhcY5xe2RzGAaNmT2qf0AHDt6q69YuPTmLL7U0dhSimCt5zHUjYemxtZkB/Y VwnlmzubHlxWH5woN/H+dTB6TKDQIeby1S22+MpOY7QtCHC7/6sg42zlbpTEHPlaaotaUbLIqEM vjtWC6aBWJKsk6RVsJ1/3/C7OjA7a6dvnu3nZRPCEI+1mRc/oCg4SrnqGfUiXRN1Ywg+Ny6wpdD 3Giz2/Az7ERVtPj+8tA== X-Authority-Analysis: v=2.4 cv=KcPfcAYD c=1 sm=1 tr=0 ts=697a740c cx=c_pps a=NpDlK6FjLPvvy7XAFEyJFw==:117 a=NpDlK6FjLPvvy7XAFEyJFw==:17 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=VkNPw1HP01LnGYTKEx00:22 a=yPCof4ZbAAAA:8 a=X7Ea-ya5AAAA:8 a=6lTwf2g7YyX0f-ifu7AA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-01-28_06,2026-01-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 impostorscore=0 adultscore=0 phishscore=0 clxscore=1011 lowpriorityscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2601280170 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=67.231.157.127; envelope-from=bchaney@akamai.com; helo=mx0b-00190b01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: qemu development 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: 1769632862787158500 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 31e9704cdc..beec547e46 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" @@ -1549,6 +1550,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) @@ -1559,6 +1586,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); @@ -1659,6 +1687,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 /* @@ -1711,6 +1742,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