[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 05/31] vhost: Add Shadow VirtQueue kick forwarding capabilities
From: |
Eugenio Pérez |
Subject: |
[PATCH 05/31] vhost: Add Shadow VirtQueue kick forwarding capabilities |
Date: |
Fri, 21 Jan 2022 21:27:07 +0100 |
At this mode no buffer forwarding will be performed in SVQ mode: Qemu
will just forward the guest's kicks to the device.
Also, host notifiers must be disabled at SVQ start, and they will not
start if SVQ has been enabled when the device is stopped. This will be
addressed in next patches.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
hw/virtio/vhost-shadow-virtqueue.h | 2 ++
hw/virtio/vhost-shadow-virtqueue.c | 27 ++++++++++++++++++++++++++-
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/hw/virtio/vhost-shadow-virtqueue.h
b/hw/virtio/vhost-shadow-virtqueue.h
index a56ecfc09d..4c583a9171 100644
--- a/hw/virtio/vhost-shadow-virtqueue.h
+++ b/hw/virtio/vhost-shadow-virtqueue.h
@@ -19,6 +19,8 @@ void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue *svq, int
svq_kick_fd);
const EventNotifier *vhost_svq_get_dev_kick_notifier(
const VhostShadowVirtqueue *svq);
+void vhost_svq_stop(VhostShadowVirtqueue *svq);
+
VhostShadowVirtqueue *vhost_svq_new(void);
void vhost_svq_free(VhostShadowVirtqueue *vq);
diff --git a/hw/virtio/vhost-shadow-virtqueue.c
b/hw/virtio/vhost-shadow-virtqueue.c
index 21534bc94d..8991f0b3c3 100644
--- a/hw/virtio/vhost-shadow-virtqueue.c
+++ b/hw/virtio/vhost-shadow-virtqueue.c
@@ -42,11 +42,26 @@ const EventNotifier *vhost_svq_get_dev_kick_notifier(
return &svq->hdev_kick;
}
+/* Forward guest notifications */
+static void vhost_handle_guest_kick(EventNotifier *n)
+{
+ VhostShadowVirtqueue *svq = container_of(n, VhostShadowVirtqueue,
+ svq_kick);
+
+ if (unlikely(!event_notifier_test_and_clear(n))) {
+ return;
+ }
+
+ event_notifier_set(&svq->hdev_kick);
+}
+
/**
* Set a new file descriptor for the guest to kick SVQ and notify for avail
*
* @svq The svq
- * @svq_kick_fd The new svq kick fd
+ * @svq_kick_fd The svq kick fd
+ *
+ * Note that SVQ will never close the old file descriptor.
*/
void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue *svq, int svq_kick_fd)
{
@@ -65,12 +80,22 @@ void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue *svq,
int svq_kick_fd)
* need to explicitely check for them.
*/
event_notifier_init_fd(&svq->svq_kick, svq_kick_fd);
+ event_notifier_set_handler(&svq->svq_kick, vhost_handle_guest_kick);
if (!check_old || event_notifier_test_and_clear(&tmp)) {
event_notifier_set(&svq->hdev_kick);
}
}
+/**
+ * Stop shadow virtqueue operation.
+ * @svq Shadow Virtqueue
+ */
+void vhost_svq_stop(VhostShadowVirtqueue *svq)
+{
+ event_notifier_set_handler(&svq->svq_kick, NULL);
+}
+
/**
* Creates vhost shadow virtqueue, and instruct vhost device to use the shadow
* methods and file descriptors.
--
2.27.0
- Re: [PATCH 02/31] vhost: Add VhostShadowVirtqueue, (continued)
- [PATCH 01/31] vdpa: Reorder virtio/vhost-vdpa.c functions, Eugenio Pérez, 2022/01/21
- [PATCH 03/31] vdpa: Add vhost_svq_get_dev_kick_notifier, Eugenio Pérez, 2022/01/21
- [PATCH 04/31] vdpa: Add vhost_svq_set_svq_kick_fd, Eugenio Pérez, 2022/01/21
- [PATCH 05/31] vhost: Add Shadow VirtQueue kick forwarding capabilities,
Eugenio Pérez <=
- [PATCH 06/31] vhost: Route guest->host notification through shadow virtqueue, Eugenio Pérez, 2022/01/21
- [PATCH 07/31] vhost: dd vhost_svq_get_svq_call_notifier, Eugenio Pérez, 2022/01/21
- [PATCH 08/31] vhost: Add vhost_svq_set_guest_call_notifier, Eugenio Pérez, 2022/01/21
- [PATCH 09/31] vhost-vdpa: Take into account SVQ in vhost_vdpa_set_vring_call, Eugenio Pérez, 2022/01/21