Skip to content

Commit b04d910

Browse files
Longpengmstsirkin
authored andcommitted
vdpa: support exposing the count of vqs to userspace
- GET_VQS_COUNT: the count of virtqueues that exposed Signed-off-by: Longpeng <longpeng2@huawei.com> Link: https://lore.kernel.org/r/20220315032553.455-4-longpeng2@huawei.com Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Longpeng &lt;<a href="mailto:longpeng2@huawei.com" target="_blank">longpeng2@huawei.com</a>&gt;<br> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
1 parent 81d46d6 commit b04d910

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

drivers/vhost/vdpa.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,16 @@ static long vhost_vdpa_get_config_size(struct vhost_vdpa *v, u32 __user *argp)
373373
return 0;
374374
}
375375

376+
static long vhost_vdpa_get_vqs_count(struct vhost_vdpa *v, u32 __user *argp)
377+
{
378+
struct vdpa_device *vdpa = v->vdpa;
379+
380+
if (copy_to_user(argp, &vdpa->nvqs, sizeof(vdpa->nvqs)))
381+
return -EFAULT;
382+
383+
return 0;
384+
}
385+
376386
static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
377387
void __user *argp)
378388
{
@@ -513,6 +523,9 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
513523
case VHOST_VDPA_GET_CONFIG_SIZE:
514524
r = vhost_vdpa_get_config_size(v, argp);
515525
break;
526+
case VHOST_VDPA_GET_VQS_COUNT:
527+
r = vhost_vdpa_get_vqs_count(v, argp);
528+
break;
516529
default:
517530
r = vhost_dev_ioctl(&v->vdev, cmd, argp);
518531
if (r == -ENOIOCTLCMD)

include/uapi/linux/vhost.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,7 @@
154154
/* Get the config size */
155155
#define VHOST_VDPA_GET_CONFIG_SIZE _IOR(VHOST_VIRTIO, 0x79, __u32)
156156

157+
/* Get the count of all virtqueues */
158+
#define VHOST_VDPA_GET_VQS_COUNT _IOR(VHOST_VIRTIO, 0x80, __u32)
159+
157160
#endif

0 commit comments

Comments
 (0)