From nobody Tue Feb 10 11:13:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1620391416; cv=none; d=zohomail.com; s=zohoarc; b=TpowKeXSeILB8LGRNg7PqMkb5DwoshCuOMT7n9hgJ5knxF2TQjw1mk+Z7mFqY+8ymA8ZXv3oC48nIyWXPGORz+NiRtuMVaEiauM6tN9P0T0p67erSVO+kJwZpwrOusF06IlFyImdeNkyH96VdwatcdL0Bz9QV8QIYgVn8y7Cn2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620391416; 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=JfjHWFHUNhb7JM67PxW1K1BAotVKjQnVbNBqz87553U=; b=iNYbHCfviAkraScp/KLwGsk2OqSGfSeSaEI53Jq6n+NVJVJ89JxmPkw1RKCSwUwYrpozR28eeL84bKf6zEpqnSWD8x+cDt1inaafHqjdl9IfaXCpAaRA+8FuxZtb+FxMznezvwReNJhSiPYBDcD33WmoibkYmClBz9zE8P8YPq0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1620391416321727.6993379774511; Fri, 7 May 2021 05:43:36 -0700 (PDT) Received: from localhost ([::1]:37786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lezpP-0004V1-Ga for importer@patchew.org; Fri, 07 May 2021 08:43:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lezbU-0000g2-3s for qemu-devel@nongnu.org; Fri, 07 May 2021 08:29:12 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:49986) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lezbP-0001Tr-TO for qemu-devel@nongnu.org; Fri, 07 May 2021 08:29:11 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 147CEJtJ148872; Fri, 7 May 2021 12:29:05 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 38csrd9ewm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 May 2021 12:29:04 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 147CFkMl168017; Fri, 7 May 2021 12:29:04 GMT Received: from pps.reinject (localhost [127.0.0.1]) by userp3020.oracle.com with ESMTP id 38csrh1t9r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 May 2021 12:29:04 +0000 Received: from userp3020.oracle.com (userp3020.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 147CT3K6014655; Fri, 7 May 2021 12:29:03 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 38csrh1t8c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 May 2021 12:29:03 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 147CT1Vm016430; Fri, 7 May 2021 12:29:01 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 07 May 2021 05:29:01 -0700 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-2020-01-29; bh=JfjHWFHUNhb7JM67PxW1K1BAotVKjQnVbNBqz87553U=; b=aIQNWHXzKS1n0T6GUQeUQ4k7pUFITq8pSxmsH+iiykdut9mnuURuhxFfermOa2Ehb8tH lOC6EvNRtdg3ez4GE2ae8S+oGITnz8Rj74T9Lz+tgLpO2H/mRV8uNOKPVHEKdDULx1eR N3x6d8NKm+1NGbVFfMdjJDrXIYI6LkDFN11W0V2uNdS8GKci5Q84VJPo4gWM7+sRvqTR LoZ4i4Lc1HAjIUtSHJV0/A2svyKjFKiECoap4E5iWe9vKGggUvBm5+1vQg6P518dken4 rrkfQUKmiOcIoLdknqRaHY8DGagbk2BnpLthDXqg3R4OqEURTLyAbHd5H7yi1vhOgpVH +Q== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V3 14/22] vhost: reset vhost devices upon cprsave Date: Fri, 7 May 2021 05:25:12 -0700 Message-Id: <1620390320-301716-15-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1620390320-301716-1-git-send-email-steven.sistare@oracle.com> References: <1620390320-301716-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-ORIG-GUID: iqFO6HJQCikgcx2EFq3caxffR8ecit2d X-Proofpoint-GUID: iqFO6HJQCikgcx2EFq3caxffR8ecit2d X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9976 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 clxscore=1015 malwarescore=0 adultscore=0 mlxlogscore=999 impostorscore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105070085 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=141.146.126.79; envelope-from=steven.sistare@oracle.com; helo=aserp2130.oracle.com X-Spam_score_int: -50 X-Spam_score: -5.1 X-Spam_bar: ----- X-Spam_report: (-5.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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 | 11 +++++++++++ include/hw/virtio/vhost.h | 1 + migration/cpr.c | 1 + 3 files changed, 13 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index e2163a0..8c0c9c3 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1820,6 +1820,17 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODe= vice *vdev) hdev->vdev =3D NULL; } =20 +void vhost_dev_reset_all(void) +{ + struct vhost_dev *dev; + + QLIST_FOREACH(dev, &vhost_devices, entry) { + if (dev->vhost_ops->vhost_reset_device(dev) < 0) { + VHOST_OPS_DEBUG("vhost_reset_device failed"); + } + } +} + int vhost_net_set_backend(struct vhost_dev *hdev, struct vhost_vring_file *file) { diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 4a8bc75..71704d4 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -106,6 +106,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque, void vhost_dev_cleanup(struct vhost_dev *hdev); int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev); void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev); +void vhost_dev_reset_all(void); int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev); void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vde= v); =20 diff --git a/migration/cpr.c b/migration/cpr.c index e9a189b..3cde26f 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -136,6 +136,7 @@ void cprsave(const char *file, CprMode mode, Error **er= rp) goto err; } walkenv(FD_PREFIX, preserve_fd, 0); + vhost_dev_reset_all(); setenv("QEMU_START_FREEZE", "", 1); qemu_system_exec_request(); } --=20 1.8.3.1