[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 10/27] vhost: Allocate shadow vring
From: |
Eugenio Pérez |
Subject: |
[RFC PATCH 10/27] vhost: Allocate shadow vring |
Date: |
Fri, 20 Nov 2020 19:50:48 +0100 |
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
hw/virtio/vhost-sw-lm-ring.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/hw/virtio/vhost-sw-lm-ring.c b/hw/virtio/vhost-sw-lm-ring.c
index cbf53965cd..cd7b5ba772 100644
--- a/hw/virtio/vhost-sw-lm-ring.c
+++ b/hw/virtio/vhost-sw-lm-ring.c
@@ -16,8 +16,11 @@
#include "qemu/event_notifier.h"
typedef struct VhostShadowVirtqueue {
+ struct vring vring;
EventNotifier hdev_notifier;
VirtQueue *vq;
+
+ vring_desc_t descs[];
} VhostShadowVirtqueue;
static inline bool vhost_vring_should_kick(VhostShadowVirtqueue *vq)
@@ -37,10 +40,12 @@ VhostShadowVirtqueue *vhost_sw_lm_shadow_vq(struct
vhost_dev *dev, int idx)
.index = idx
};
VirtQueue *vq = virtio_get_queue(dev->vdev, idx);
+ unsigned num = virtio_queue_get_num(dev->vdev, idx);
+ size_t ring_size = vring_size(num, VRING_DESC_ALIGN_SIZE);
VhostShadowVirtqueue *svq;
int r;
- svq = g_new0(VhostShadowVirtqueue, 1);
+ svq = g_malloc0(sizeof(*svq) + ring_size);
svq->vq = vq;
r = event_notifier_init(&svq->hdev_notifier, 0);
--
2.18.4
- [RFC PATCH 00/27] vDPA software assisted live migration, Eugenio Pérez, 2020/11/20
- [RFC PATCH 01/27] vhost: Add vhost_dev_can_log, Eugenio Pérez, 2020/11/20
- [RFC PATCH 02/27] vhost: Add device callback in vhost_migration_log, Eugenio Pérez, 2020/11/20
- [RFC PATCH 03/27] vhost: Move log resize/put to vhost_dev_set_log, Eugenio Pérez, 2020/11/20
- [RFC PATCH 04/27] vhost: add vhost_kernel_set_vring_enable, Eugenio Pérez, 2020/11/20
- [RFC PATCH 05/27] vhost: Add hdev->dev.sw_lm_vq_handler, Eugenio Pérez, 2020/11/20
- [RFC PATCH 06/27] virtio: Add virtio_queue_get_used_notify_split, Eugenio Pérez, 2020/11/20
- [RFC PATCH 07/27] vhost: Route guest->host notification through qemu, Eugenio Pérez, 2020/11/20
- [RFC PATCH 08/27] vhost: Add a flag for software assisted Live Migration, Eugenio Pérez, 2020/11/20
- [RFC PATCH 09/27] vhost: Route host->guest notification through qemu, Eugenio Pérez, 2020/11/20
- [RFC PATCH 10/27] vhost: Allocate shadow vring,
Eugenio Pérez <=
- [RFC PATCH 11/27] virtio: const-ify all virtio_tswap* functions, Eugenio Pérez, 2020/11/20
- [RFC PATCH 12/27] virtio: Add virtio_queue_full, Eugenio Pérez, 2020/11/20
- [RFC PATCH 13/27] vhost: Send buffers to device, Eugenio Pérez, 2020/11/20
- [RFC PATCH 14/27] virtio: Remove virtio_queue_get_used_notify_split, Eugenio Pérez, 2020/11/20
- [RFC PATCH 15/27] vhost: Do not invalidate signalled used, Eugenio Pérez, 2020/11/20
- [RFC PATCH 16/27] virtio: Expose virtqueue_alloc_element, Eugenio Pérez, 2020/11/20
- [RFC PATCH 17/27] vhost: add vhost_vring_set_notification_rcu, Eugenio Pérez, 2020/11/20
- [RFC PATCH 18/27] vhost: add vhost_vring_poll_rcu, Eugenio Pérez, 2020/11/20
- [RFC PATCH 19/27] vhost: add vhost_vring_get_buf_rcu, Eugenio Pérez, 2020/11/20
- [RFC PATCH 20/27] vhost: Return used buffers, Eugenio Pérez, 2020/11/20