From nobody Mon Feb 9 17:25:13 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=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1655305433; cv=none; d=zohomail.com; s=zohoarc; b=aBKOKpbzDB8BiZzuE9nAvUk1EITWiSaPIfGB4rQNrTblDAiq3eRPDyQF3LSQUtnP7/TZeX/znzlBZRwDy13+g3SKU87pU7uln/oKEuFt+nf4Fw+nw6OQKQgdGylkSnitYwH+u2EtkRoey/hjDDUXS/qd2QTGta9rbkzKrQHwngQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655305433; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=u+USWiZ7o3DyQxWHdJI7EwK8AIskaFZDpN+FFhGWYKM=; b=Ql0d0wyDUYxAVgT9jcvQHtgrv0Yhk49kE+9aa7toyr54NeeUFPXjX8zyVQnYGSotA5K7Y+YWrYlzBsRT1i4b6KxYj4bb8s1FxJK29IeHjwcOLsg8AzzMCaVujA4ktKNU1uZxFJ88JWlnV50Scrad7NY8qBvKlXZgKOiGZaIjtzo= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655305433153853.9930517632117; Wed, 15 Jun 2022 08:03:53 -0700 (PDT) Received: from localhost ([::1]:56280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1UYi-00034G-52 for importer@patchew.org; Wed, 15 Jun 2022 11:03:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1UOX-0007HR-Tv for qemu-devel@nongnu.org; Wed, 15 Jun 2022 10:53:23 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:34582) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1UOV-00015T-R9 for qemu-devel@nongnu.org; Wed, 15 Jun 2022 10:53:21 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25FDrshi015214; Wed, 15 Jun 2022 14:53:07 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gmhn0gvfu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Jun 2022 14:53:07 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25FEQ7KB023155; Wed, 15 Jun 2022 14:53:06 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gpr25vq3v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Jun 2022 14:53:06 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 25FEqSNj018501; Wed, 15 Jun 2022 14:53:05 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gpr25vpfm-32; Wed, 15 Jun 2022 14:53:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2021-07-09; bh=u+USWiZ7o3DyQxWHdJI7EwK8AIskaFZDpN+FFhGWYKM=; b=XoR7Cc3PrSieTnP1mm+SUS+MhF+Kxc7XOsPBukQuqgow4JlZ7lPQpLAgI6TrIpuNsPFO 9g89KtaN4CE+jywXtGE7VOC6zOh92tbxChPn1yX91bQGrhk0BqIkrJ9lqM2jcRCf7GPA SZsOUI5jd3+DXawjNcHdvj3LKPw+641BBl5n3O7A4gZH9tScVFeqdxOnG1tISaZbi4lB XG356DdozQlybIBWwW9y3dQiJjvp/TOkzqZk+a53JUfgVncx2AjeqpKZPNRiX+7X1MUZ OLNxFJc5CLpRCVX8/Nt1TR6xL+hTKeEPMkysX7+mNhOku3NpVK+Ap5J1WNp6wk67jRoX 8Q== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Dr. David Alan Gilbert" , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , "Daniel P. Berrange" , Juan Quintela , Markus Armbruster , Eric Blake , Jason Zeng , Zheng Chuan , Steve Sistare , Mark Kanda , Guoyi Tu , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Igor Mammedov , David Hildenbrand , John Snow Subject: [PATCH V8 31/39] vhost: reset vhost devices for cpr Date: Wed, 15 Jun 2022 07:52:18 -0700 Message-Id: <1655304746-102776-32-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1655304746-102776-1-git-send-email-steven.sistare@oracle.com> References: <1655304746-102776-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-GUID: Qr0T5rhpOzzWG1gwnovkgnz-cuq7IxNH X-Proofpoint-ORIG-GUID: Qr0T5rhpOzzWG1gwnovkgnz-cuq7IxNH 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=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-00069f02.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_MED=-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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1655305434206100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" A vhost device is implicitly preserved across re-exec because its fd is not closed, and the value of the fd is specified on the command line for the new qemu to find. However, new qemu issues an VHOST_RESET_OWNER ioctl, which fails because the device already has an owner. To fix, reset the owner prior to exec. Signed-off-by: Mark Kanda Signed-off-by: Steve Sistare --- hw/virtio/vhost.c | 17 +++++++++++++++++ include/hw/virtio/vhost.h | 1 + 2 files changed, 18 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index dd3263d..efaa28c 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -23,6 +23,7 @@ #include "standard-headers/linux/vhost_types.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" +#include "migration/cpr.h" #include "migration/blocker.h" #include "migration/qemu-file-types.h" #include "sysemu/dma.h" @@ -1306,6 +1307,17 @@ static void vhost_virtqueue_cleanup(struct vhost_vir= tqueue *vq) event_notifier_cleanup(&vq->masked_notifier); } =20 +static void vhost_cpr_exec_notifier(Notifier *notifier, void *data) +{ + struct vhost_dev *dev =3D container_of(notifier, struct vhost_dev, + cpr_notifier); + int r =3D dev->vhost_ops->vhost_reset_device(dev); + + if (r < 0) { + VHOST_OPS_DEBUG(r, "vhost_reset_device failed"); + } +} + int vhost_dev_init(struct vhost_dev *hdev, void *opaque, VhostBackendType backend_type, uint32_t busyloop_timeou= t, Error **errp) @@ -1405,6 +1417,8 @@ 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= ); + cpr_add_notifier(&hdev->cpr_notifier, vhost_cpr_exec_notifier, + CPR_NOTIFY_EXEC); QLIST_INSERT_HEAD(&vhost_devices, hdev, entry); =20 if (used_memslots > hdev->vhost_ops->vhost_backend_memslots_limit(hdev= )) { @@ -1444,6 +1458,9 @@ void vhost_dev_cleanup(struct vhost_dev *hdev) migrate_del_blocker(hdev->migration_blocker); error_free(hdev->migration_blocker); } + if (hdev->cpr_notifier.notify) { + cpr_remove_notifier(&hdev->cpr_notifier); + } g_free(hdev->mem); g_free(hdev->mem_sections); if (hdev->vhost_ops) { diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index b291fe4..1316b14 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -100,6 +100,7 @@ struct vhost_dev { QLIST_ENTRY(vhost_dev) entry; QLIST_HEAD(, vhost_iommu) iommu_list; IOMMUNotifier n; + Notifier cpr_notifier; const VhostDevConfigOps *config_ops; }; =20 --=20 1.8.3.1