[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 04/27] vhost: add vhost_kernel_set_vring_enable
From: |
Eugenio Pérez |
Subject: |
[RFC PATCH 04/27] vhost: add vhost_kernel_set_vring_enable |
Date: |
Fri, 20 Nov 2020 19:50:42 +0100 |
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
hw/virtio/vhost-backend.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
index 222bbcc62d..317f1f96fa 100644
--- a/hw/virtio/vhost-backend.c
+++ b/hw/virtio/vhost-backend.c
@@ -201,6 +201,34 @@ static int vhost_kernel_get_vq_index(struct vhost_dev
*dev, int idx)
return idx - dev->vq_index;
}
+static int vhost_kernel_set_vq_enable(struct vhost_dev *dev, unsigned idx,
+ bool enable)
+{
+ struct vhost_vring_file file = {
+ .index = idx,
+ };
+
+ if (!enable) {
+ file.fd = -1; /* Pass -1 to unbind from file. */
+ } else {
+ struct vhost_net *vn_dev = container_of(dev, struct vhost_net, dev);
+ file.fd = vn_dev->backend;
+ }
+
+ return vhost_kernel_net_set_backend(dev, &file);
+}
+
+static int vhost_kernel_set_vring_enable(struct vhost_dev *dev, int enable)
+{
+ int i;
+
+ for (i = 0; i < dev->nvqs; ++i) {
+ vhost_kernel_set_vq_enable(dev, i, enable);
+ }
+
+ return 0;
+}
+
#ifdef CONFIG_VHOST_VSOCK
static int vhost_kernel_vsock_set_guest_cid(struct vhost_dev *dev,
uint64_t guest_cid)
@@ -317,6 +345,7 @@ static const VhostOps kernel_ops = {
.vhost_set_owner = vhost_kernel_set_owner,
.vhost_reset_device = vhost_kernel_reset_device,
.vhost_get_vq_index = vhost_kernel_get_vq_index,
+ .vhost_set_vring_enable = vhost_kernel_set_vring_enable,
#ifdef CONFIG_VHOST_VSOCK
.vhost_vsock_set_guest_cid = vhost_kernel_vsock_set_guest_cid,
.vhost_vsock_set_running = vhost_kernel_vsock_set_running,
--
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 <=
- [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, 2020/11/20
- [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