aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vhost/vhost.c
diff options
context:
space:
mode:
authorJason Wang <jasowang@redhat.com>2011-06-21 06:04:27 -0400
committerMichael S. Tsirkin <mst@redhat.com>2011-07-19 06:28:34 -0400
commitf59281dafb832b161133743fcf3dc29051e6fdb8 (patch)
tree3eacc9fd60396174a94c8bd02326e930ff94351d /drivers/vhost/vhost.c
parent81fc70d86527a1450560709500ca5f52e661da1f (diff)
vhost: init used ring after backend was set
Move the used ring initialization after backend was set. This makes it possible to disable the backend and tweak the used ring, then restart. This will also make it possible to log the used ring write correctly. Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/vhost/vhost.c')
-rw-r--r--drivers/vhost/vhost.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 5ef2f62becf4..9a108038fe52 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -629,15 +629,17 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m)
629 return 0; 629 return 0;
630} 630}
631 631
632static int init_used(struct vhost_virtqueue *vq, 632int vhost_init_used(struct vhost_virtqueue *vq)
633 struct vring_used __user *used)
634{ 633{
635 int r = put_user(vq->used_flags, &used->flags); 634 int r;
635 if (!vq->private_data)
636 return 0;
636 637
638 r = put_user(vq->used_flags, &vq->used->flags);
637 if (r) 639 if (r)
638 return r; 640 return r;
639 vq->signalled_used_valid = false; 641 vq->signalled_used_valid = false;
640 return get_user(vq->last_used_idx, &used->idx); 642 return get_user(vq->last_used_idx, &vq->used->idx);
641} 643}
642 644
643static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp) 645static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
@@ -752,10 +754,6 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
752 } 754 }
753 } 755 }
754 756
755 r = init_used(vq, (struct vring_used __user *)(unsigned long)
756 a.used_user_addr);
757 if (r)
758 break;
759 vq->log_used = !!(a.flags & (0x1 << VHOST_VRING_F_LOG)); 757 vq->log_used = !!(a.flags & (0x1 << VHOST_VRING_F_LOG));
760 vq->desc = (void __user *)(unsigned long)a.desc_user_addr; 758 vq->desc = (void __user *)(unsigned long)a.desc_user_addr;
761 vq->avail = (void __user *)(unsigned long)a.avail_user_addr; 759 vq->avail = (void __user *)(unsigned long)a.avail_user_addr;