From nobody Tue Feb 10 00:23:26 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=1610670456; cv=none; d=zohomail.com; s=zohoarc; b=W1p7sy/U8a5J4GKGXhOHCoBqJhI3GanMMTisXB5cnVpJWFN+KiW812D90U+v0yps6bGE8mfMBR5CHqrmnPmKFfQfZnwY68E/Upxi+j5+bNGIMaYK9JlF6JblQoP8fcGjHdSkRM+eYRqANO/TM1Xmw/OtqRMrN2leiIeprRcfTEE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610670456; 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=0rzWooZGZcVfaCvt4A/vGn5zKh1ptDjTXTh9PhGdtCM=; b=MRxq22EEIAY1S4rCc5xdmgdNR3oCsBWbk6T4oFEhSnbA+CyRmUmI8I0UYT+yRE/9couyBQdJpc/3ve7P38cBHGniOwkTRX4SMexTfcHbMvuMaAXCtkpkO+ykBPI+ujhEQD/z8X154ayGhbzkYPn5mzszXRfOZTvSXNd1viWyVP0= 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 1610670456059897.8009245458232; Thu, 14 Jan 2021 16:27:36 -0800 (PST) Received: from localhost ([::1]:60436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0Cxi-0004kj-SV for importer@patchew.org; Thu, 14 Jan 2021 19:27:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0Cvt-0003RQ-SN for qemu-devel@nongnu.org; Thu, 14 Jan 2021 19:25:41 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:35044) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0Cvm-0005NC-Nw for qemu-devel@nongnu.org; Thu, 14 Jan 2021 19:25:41 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10F0FwnF106090; Fri, 15 Jan 2021 00:25:31 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 360kvkasap-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Jan 2021 00:25:31 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10F0FjlT030246; Fri, 15 Jan 2021 00:25:30 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 360keajr77-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Jan 2021 00:25:30 +0000 Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 10F0PTbB008642; Fri, 15 Jan 2021 00:25:29 GMT Received: from localhost.localdomain (/10.211.9.80) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 14 Jan 2021 16:25:28 -0800 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=0rzWooZGZcVfaCvt4A/vGn5zKh1ptDjTXTh9PhGdtCM=; b=SXEgEjI4ATxiKXhE2QliVs/4khLzJyCuBrUICdRFFKBz2k9zoYKzK9AOVZMDXkOfSRvt 6YLlXkMVDuZbWaBsqfnjvG6K7u0gJy/9xd0M580BkDqOcmb0zUjEWtj1ghD73srLQoMc yPeHyVQzNxAjDmQsr3CQ/YPgZ6B1QxEC4S6efIC4jHkvk1PuqIyUSiFt80tvi/f3ahN1 8Z2PnnJKCKiZeW0mvvUAY9zrnoax5aa/hnkG0kQXRyDehsbTH+eJwYNoOJsNsr4y0cUj 97tOuOYKP/VTtptFr/zs9xENGETq7n3iwQ/wa6lMTa3S00LKEo6SWwusQ7AFBKJ9Qoul bQ== From: Dongli Zhang To: qemu-devel@nongnu.org Subject: [PATCH RFC 2/2] vhost-scsi: implement DeviceEvent Date: Thu, 14 Jan 2021 16:27:30 -0800 Message-Id: <20210115002730.1279-3-dongli.zhang@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210115002730.1279-1-dongli.zhang@oracle.com> References: <20210115002730.1279-1-dongli.zhang@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9864 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101150000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9864 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=998 phishscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 impostorscore=0 spamscore=0 mlxscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101150000 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=156.151.31.86; envelope-from=dongli.zhang@oracle.com; helo=userp2130.oracle.com X-Spam_score_int: -46 X-Spam_score: -4.7 X-Spam_bar: ---- X-Spam_report: (-4.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.248, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, 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: berrange@redhat.com, ehabkost@redhat.com, mst@redhat.com, joe.jin@oracle.com, armbru@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, joao.m.martins@oracle.com 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" This patch implements DeviceEvent for vhost-scsi. As RFC, this patch only considers the case of eventfd and only for vhost-scsi. Below are example for HMP and QAPI. (qemu) device_event /machine/peripheral/vscsi0 kick 1 { "execute": "x-debug-device-event", "arguments": { "dev": "/machine/peripheral/vscsi0", "event": "kick", "queue": 1 } } Signed-off-by: Dongli Zhang --- hw/virtio/vhost-scsi-pci.c | 10 ++++++++++ hw/virtio/virtio.c | 19 +++++++++++++++++++ include/hw/virtio/virtio.h | 3 +++ 3 files changed, 32 insertions(+) diff --git a/hw/virtio/vhost-scsi-pci.c b/hw/virtio/vhost-scsi-pci.c index cb71a294fa..0236720868 100644 --- a/hw/virtio/vhost-scsi-pci.c +++ b/hw/virtio/vhost-scsi-pci.c @@ -62,12 +62,22 @@ static void vhost_scsi_pci_realize(VirtIOPCIProxy *vpci= _dev, Error **errp) qdev_realize(vdev, BUS(&vpci_dev->bus), errp); } =20 +static void vhost_scsi_pci_event(DeviceState *dev, int event, int queue, + Error **errp) +{ + VHostSCSIPCI *vscsi =3D VHOST_SCSI_PCI(dev); + DeviceState *vdev =3D DEVICE(&vscsi->vdev); + + virtio_device_event_eventfd(vdev, event, queue, errp); +} + static void vhost_scsi_pci_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); VirtioPCIClass *k =3D VIRTIO_PCI_CLASS(klass); PCIDeviceClass *pcidev_k =3D PCI_DEVICE_CLASS(klass); k->realize =3D vhost_scsi_pci_realize; + dc->event =3D vhost_scsi_pci_event; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); device_class_set_props(dc, vhost_scsi_pci_properties); pcidev_k->vendor_id =3D PCI_VENDOR_ID_REDHAT_QUMRANET; diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index b308026596..d9168c4ac8 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3690,6 +3690,25 @@ static void virtio_device_unrealize(DeviceState *dev) vdev->bus_name =3D NULL; } =20 +void virtio_device_event_eventfd(DeviceState *dev, int event, int queue, + Error **errp) +{ + struct VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + int num =3D virtio_get_num_queues(vdev); + + if (queue < 0 || queue >=3D num) { + error_setg(errp, "Invalid queue %d", queue); + return; + } + + VirtQueue *vq =3D &vdev->vq[queue]; + + if (event =3D=3D DEVICE_EVENT_CALL) + event_notifier_set(&vq->guest_notifier); + else if (event =3D=3D DEVICE_EVENT_KICK) + event_notifier_set(&vq->host_notifier); +} + static void virtio_device_free_virtqueues(VirtIODevice *vdev) { int i; diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index b7ece7a6a8..606ebdfb85 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -397,4 +397,7 @@ static inline bool virtio_device_disabled(VirtIODevice = *vdev) bool virtio_legacy_allowed(VirtIODevice *vdev); bool virtio_legacy_check_disabled(VirtIODevice *vdev); =20 +void virtio_device_event_eventfd(DeviceState *dev, int event, int queue, + Error **errp); + #endif --=20 2.17.1