[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 08/55] virtio: add support for configure interrupt
From: |
Michael S. Tsirkin |
Subject: |
[PULL v2 08/55] virtio: add support for configure interrupt |
Date: |
Fri, 7 Jan 2022 06:03:29 -0500 |
From: Cindy Lu <lulu@redhat.com>
Add the functions to support the configure interrupt in virtio
The function virtio_config_guest_notifier_read will notify the
guest if there is an configure interrupt.
The function virtio_config_set_guest_notifier_fd_handler is
to set the fd hander for the notifier
Signed-off-by: Cindy Lu <lulu@redhat.com>
Message-Id: <20211104164827.21911-7-lulu@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/virtio/virtio.h | 4 ++++
hw/virtio/virtio.c | 29 +++++++++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 605ea79c90..d78088d872 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -111,6 +111,7 @@ struct VirtIODevice
bool use_guest_notifier_mask;
AddressSpace *dma_as;
QLIST_HEAD(, VirtQueue) *vector_queues;
+ EventNotifier config_notifier;
};
struct VirtioDeviceClass {
@@ -313,11 +314,14 @@ uint16_t virtio_get_queue_index(VirtQueue *vq);
EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq);
void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
bool with_irqfd);
+void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev,
+ bool assign, bool with_irqfd);
int virtio_device_start_ioeventfd(VirtIODevice *vdev);
int virtio_device_grab_ioeventfd(VirtIODevice *vdev);
void virtio_device_release_ioeventfd(VirtIODevice *vdev);
bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev);
EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq);
+EventNotifier *virtio_config_get_guest_notifier(VirtIODevice *vdev);
void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled);
void virtio_queue_host_notifier_read(EventNotifier *n);
void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx,
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index e11a8a0dba..36edb1dad5 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -3493,7 +3493,14 @@ static void
virtio_queue_guest_notifier_read(EventNotifier *n)
virtio_irq(vq);
}
}
+static void virtio_config_guest_notifier_read(EventNotifier *n)
+{
+ VirtIODevice *vdev = container_of(n, VirtIODevice, config_notifier);
+ if (event_notifier_test_and_clear(n)) {
+ virtio_notify_config(vdev);
+ }
+}
void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
bool with_irqfd)
{
@@ -3510,6 +3517,23 @@ void
virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
}
}
+void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev,
+ bool assign, bool with_irqfd)
+{
+ EventNotifier *n;
+ n = &vdev->config_notifier;
+ if (assign && !with_irqfd) {
+ event_notifier_set_handler(n, virtio_config_guest_notifier_read);
+ } else {
+ event_notifier_set_handler(n, NULL);
+ }
+ if (!assign) {
+ /* Test and clear notifier before closing it,*/
+ /* in case poll callback didn't have time to run. */
+ virtio_config_guest_notifier_read(n);
+ }
+}
+
EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq)
{
return &vq->guest_notifier;
@@ -3583,6 +3607,11 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue
*vq)
return &vq->host_notifier;
}
+EventNotifier *virtio_config_get_guest_notifier(VirtIODevice *vdev)
+{
+ return &vdev->config_notifier;
+}
+
void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled)
{
vq->host_notifier_enabled = enabled;
--
MST
- [PULL v2 00/55] virtio,pci,pc: features,fixes,cleanups, Michael S. Tsirkin, 2022/01/07
- [PULL v2 02/55] acpi: validate hotplug selector on access, Michael S. Tsirkin, 2022/01/07
- [PULL v2 01/55] virtio-mem: Don't skip alignment checks when warning about block size, Michael S. Tsirkin, 2022/01/07
- [PULL v2 03/55] virtio: introduce macro IRTIO_CONFIG_IRQ_IDX, Michael S. Tsirkin, 2022/01/07
- [PULL v2 04/55] virtio-pci: decouple notifier from interrupt process, Michael S. Tsirkin, 2022/01/07
- [PULL v2 05/55] virtio-pci: decouple the single vector from the interrupt process, Michael S. Tsirkin, 2022/01/07
- [PULL v2 06/55] vhost: introduce new VhostOps vhost_set_config_call, Michael S. Tsirkin, 2022/01/07
- [PULL v2 07/55] vhost-vdpa: add support for config interrupt, Michael S. Tsirkin, 2022/01/07
- [PULL v2 09/55] vhost: add support for configure interrupt, Michael S. Tsirkin, 2022/01/07
- [PULL v2 10/55] virtio-net: add support for configure interrupt, Michael S. Tsirkin, 2022/01/07
- [PULL v2 08/55] virtio: add support for configure interrupt,
Michael S. Tsirkin <=
- [PULL v2 11/55] virtio-mmio: add support for configure interrupt, Michael S. Tsirkin, 2022/01/07
- [PULL v2 12/55] virtio-pci: add support for configure interrupt, Michael S. Tsirkin, 2022/01/07
- [PULL v2 13/55] trace-events,pci: unify trace events format, Michael S. Tsirkin, 2022/01/07
- [PULL v2 14/55] vhost-user-blk: reconnect on any error during realize, Michael S. Tsirkin, 2022/01/07
- [PULL v2 15/55] chardev/char-socket: tcp_chr_recv: don't clobber errno, Michael S. Tsirkin, 2022/01/07
- [PULL v2 16/55] chardev/char-socket: tcp_chr_sync_read: don't clobber errno, Michael S. Tsirkin, 2022/01/07
- [PULL v2 17/55] vhost-backend: avoid overflow on memslots_limit, Michael S. Tsirkin, 2022/01/07
- [PULL v2 19/55] vhost-vdpa: stick to -errno error return convention, Michael S. Tsirkin, 2022/01/07
- [PULL v2 18/55] vhost-backend: stick to -errno error return convention, Michael S. Tsirkin, 2022/01/07
- [PULL v2 20/55] vhost-user: stick to -errno error return convention, Michael S. Tsirkin, 2022/01/07