[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 09/10] vhost: add VHOST_SET_VRING_ENABLE support
From: |
Mike Christie |
Subject: |
[PATCH 09/10] vhost: add VHOST_SET_VRING_ENABLE support |
Date: |
Thu, 12 Nov 2020 17:19:09 -0600 |
This adds a new ioctl VHOST_SET_VRING_ENABLE that the vhost drivers can
implement a callout for and execute an operation when the vq is
enabled/disabled.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
drivers/vhost/vhost.c | 25 +++++++++++++++++++++++++
drivers/vhost/vhost.h | 1 +
include/uapi/linux/vhost.h | 1 +
3 files changed, 27 insertions(+)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 2f98b81..e953031 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -1736,6 +1736,28 @@ static long vhost_vring_set_num_addr(struct vhost_dev *d,
return r;
}
+
+static long vhost_vring_set_enable(struct vhost_dev *d,
+ struct vhost_virtqueue *vq,
+ void __user *argp)
+{
+ struct vhost_vring_state s;
+ int ret = 0;
+
+ if (vq->private_data)
+ return -EBUSY;
+
+ if (copy_from_user(&s, argp, sizeof s))
+ return -EFAULT;
+
+ if (s.num != 1 && s.num != 0)
+ return -EINVAL;
+
+ if (d->ops && d->ops->enable_vring)
+ ret = d->ops->enable_vring(vq, s.num);
+ return ret;
+}
+
long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user
*argp)
{
struct file *eventfp, *filep = NULL;
@@ -1765,6 +1787,9 @@ long vhost_vring_ioctl(struct vhost_dev *d, unsigned int
ioctl, void __user *arg
mutex_lock(&vq->mutex);
switch (ioctl) {
+ case VHOST_SET_VRING_ENABLE:
+ r = vhost_vring_set_enable(d, vq, argp);
+ break;
case VHOST_SET_VRING_BASE:
/* Moving base with an active backend?
* You don't want to do that. */
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index a293f48..1279c09 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -158,6 +158,7 @@ struct vhost_msg_node {
struct vhost_dev_ops {
int (*msg_handler)(struct vhost_dev *dev, struct vhost_iotlb_msg *msg);
+ int (*enable_vring)(struct vhost_virtqueue *vq, bool enable);
};
struct vhost_dev {
diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
index c998860..3ffd133 100644
--- a/include/uapi/linux/vhost.h
+++ b/include/uapi/linux/vhost.h
@@ -70,6 +70,7 @@
#define VHOST_VRING_BIG_ENDIAN 1
#define VHOST_SET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x13, struct
vhost_vring_state)
#define VHOST_GET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x14, struct
vhost_vring_state)
+#define VHOST_SET_VRING_ENABLE _IOW(VHOST_VIRTIO, 0x15, struct
vhost_vring_state)
/* The following ioctls use eventfd file descriptors to signal and poll
* for events. */
--
1.8.3.1
- [PATCH 00/10] vhost/qemu: thread per IO SCSI vq, Mike Christie, 2020/11/12
- [PATCH 05/10] vhost: poll support support multiple workers, Mike Christie, 2020/11/12
- [PATCH 08/10] vhost: move msg_handler to new ops struct, Mike Christie, 2020/11/12
- [PATCH 09/10] vhost: add VHOST_SET_VRING_ENABLE support,
Mike Christie <=
- [PATCH 03/10] vhost poll: fix coding style, Mike Christie, 2020/11/12
- [PATCH 07/10] vhost, vhost-scsi: flush IO vqs then send TMF rsp, Mike Christie, 2020/11/12
- [PATCH 02/10] vhost scsi: remove extra flushes, Mike Christie, 2020/11/12
- [PATCH 01/10] vhost: remove work arg from vhost_work_flush, Mike Christie, 2020/11/12
- [PATCH 04/10] vhost: support multiple worker threads, Mike Christie, 2020/11/12