Add an ioctl cmd to allow userspace to figure out the vq's worker.

Signed-off-by: Mike Christie <michael.chris...@oracle.com>
---
 drivers/vhost/vhost.c      | 10 ++++++++++
 include/uapi/linux/vhost.h |  3 ++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index b2d567a4cd53..e6148acbe928 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -1885,6 +1885,16 @@ long vhost_vring_ioctl(struct vhost_dev *d, unsigned int 
ioctl, void __user *arg
                if (!r && copy_to_user(argp, &w, sizeof(w)))
                        r = -EFAULT;
                break;
+       case VHOST_GET_VRING_WORKER:
+               w.index = idx;
+               w.pid = -1;
+
+               if (vq->worker)
+                       w.pid = vq->worker->task->pid;
+
+               if (copy_to_user(argp, &w, sizeof(w)))
+                       r = -EFAULT;
+               break;
        default:
                r = -ENOIOCTLCMD;
        }
diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
index 61a57f5366ee..24569f89611b 100644
--- a/include/uapi/linux/vhost.h
+++ b/include/uapi/linux/vhost.h
@@ -75,7 +75,8 @@
  * worker will be created and bound to the vq.
  */
 #define VHOST_SET_VRING_WORKER _IOWR(VHOST_VIRTIO, 0x15, struct 
vhost_vring_worker)
-
+/* Return the vqs worker's pid. If no worker is set pid is -1 */
+#define VHOST_GET_VRING_WORKER _IOR(VHOST_VIRTIO, 0x16, struct 
vhost_vring_worker)
 
 /* The following ioctls use eventfd file descriptors to signal and poll
  * for events. */
-- 
2.25.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Reply via email to