tcm_vhost: Add ioctl to get and set events missed flag
authorAsias He <asias@redhat.com>
Thu, 25 Apr 2013 07:35:22 +0000 (15:35 +0800)
committerNicholas Bellinger <nab@linux-iscsi.org>
Thu, 25 Apr 2013 08:07:45 +0000 (01:07 -0700)
Signed-off-by: Asias He <asias@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/vhost/tcm_vhost.c
drivers/vhost/tcm_vhost.h

index 5340fd759c6e05010437cc0a85f52c4222ee349b..07217d818ad7a8496d586b8469cfe5cb0f02c52e 100644 (file)
@@ -1200,8 +1200,11 @@ static long vhost_scsi_ioctl(struct file *f, unsigned int ioctl,
        struct vhost_scsi_target backend;
        void __user *argp = (void __user *)arg;
        u64 __user *featurep = argp;
+       u32 __user *eventsp = argp;
+       u32 events_missed;
        u64 features;
        int r, abi_version = VHOST_SCSI_ABI_VERSION;
+       struct vhost_virtqueue *vq = &vs->vqs[VHOST_SCSI_VQ_EVT];
 
        switch (ioctl) {
        case VHOST_SCSI_SET_ENDPOINT:
@@ -1222,6 +1225,20 @@ static long vhost_scsi_ioctl(struct file *f, unsigned int ioctl,
                if (copy_to_user(argp, &abi_version, sizeof abi_version))
                        return -EFAULT;
                return 0;
+       case VHOST_SCSI_SET_EVENTS_MISSED:
+               if (get_user(events_missed, eventsp))
+                       return -EFAULT;
+               mutex_lock(&vq->mutex);
+               vs->vs_events_missed = events_missed;
+               mutex_unlock(&vq->mutex);
+               return 0;
+       case VHOST_SCSI_GET_EVENTS_MISSED:
+               mutex_lock(&vq->mutex);
+               events_missed = vs->vs_events_missed;
+               mutex_unlock(&vq->mutex);
+               if (put_user(events_missed, eventsp))
+                       return -EFAULT;
+               return 0;
        case VHOST_GET_FEATURES:
                features = VHOST_SCSI_FEATURES;
                if (copy_to_user(featurep, &features, sizeof features))
index a545a5b766a3aa6e5c3e9627f27090f0b34a0259..514b9fda230e85b7b8f9f82a525a447bbbf10855 100644 (file)
@@ -123,3 +123,6 @@ struct vhost_scsi_target {
 #define VHOST_SCSI_CLEAR_ENDPOINT _IOW(VHOST_VIRTIO, 0x41, struct vhost_scsi_target)
 /* Changing this breaks userspace. */
 #define VHOST_SCSI_GET_ABI_VERSION _IOW(VHOST_VIRTIO, 0x42, int)
+/* Set and get the events missed flag */
+#define VHOST_SCSI_SET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x43, __u32)
+#define VHOST_SCSI_GET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x44, __u32)