vhost-test: Make vhost/test.c work
Subsystems (3)
PATCH v2 1/1 vhost-test: Make vhost/test.c work
Fix it by switching to use the new device specific fields per vq
---
This is for 3.10.
drivers/vhost/test.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-)
drivers/vhost/test.c +24 -11
@@ -29,16 +29,20 @@ enum { VHOST_TEST_VQ_MAX = 1, }; +struct vhost_test_virtqueue { +struct vhost_virtqueue vq; +}; +struct vhost_test {struct vhost_dev dev; -struct vhost_virtqueue vqs[VHOST_TEST_VQ_MAX ]; +struct vhost_test_virtqueue vqs[VHOST_TEST_VQ_MAX ]; };/* Expects to be always run from workqueue - which acts as * read-size critical section for our kind of RCU. */ static void handle_vq (struct vhost_test *n) { -struct vhost_virtqueue *vq = &n->dev.vqs[VHOST_TEST_VQ ]; +struct vhost_virtqueue *vq = n->dev.vqs[VHOST_TEST_VQ ];unsigned out, in;int head;size_t len, total_len =0 ;
@@ -101,15 +105,23 @@ static void handle_vq_kick(struct vhost_work *work)static int vhost_test_open (struct inode *inode,struct file *f) {struct vhost_test *n =kmalloc (sizeof *n,GFP_KERNEL ); +struct vhost_virtqueue **vqs;struct vhost_dev *dev;int r;if (!n)return -ENOMEM ; + vqs =kmalloc (VHOST_TEST_VQ_MAX *sizeof (*vqs),GFP_KERNEL ); +if (!vqs) { +kfree (n); +return -ENOMEM ; + } + dev = &n->dev; - n->vqs[VHOST_TEST_VQ ].handle_kick = handle_vq_kick; - r =vhost_dev_init (dev, n->vqs,VHOST_TEST_VQ_MAX ); + vqs[VHOST_TEST_VQ ] = &n->vqs[VHOST_TEST_VQ ].vq; + n->vqs[VHOST_TEST_VQ ].vq.handle_kick = handle_vq_kick; + r =vhost_dev_init (dev, vqs,VHOST_TEST_VQ_MAX );if (r <0 ) {kfree (n);return r;
@@ -135,12 +147,12 @@ static void *vhost_test_stop_vq(struct vhost_test *n,static void vhost_test_stop (struct vhost_test *n,void **privatep) { - *privatep =vhost_test_stop_vq (n, n->vqs +VHOST_TEST_VQ ); + *privatep =vhost_test_stop_vq (n, &n->vqs[VHOST_TEST_VQ ].vq); }static void vhost_test_flush_vq (struct vhost_test *n,int index) { -vhost_poll_flush (&n->dev.vqs[index].poll); +vhost_poll_flush (&n->vqs[index].vq.poll); }static void vhost_test_flush (struct vhost_test *n)
@@ -159,6 +171,7 @@ static int vhost_test_release(struct inode *inode, struct file *f)/* We do an extra flush before freeing memory, * since jobs can re-queue themselves. */ vhost_test_flush (n); +kfree (n->dev.vqs);kfree (n);return 0 ; }
@@ -179,14 +192,14 @@ static long vhost_test_run(struct vhost_test *n, int test)for (index =0 ; index < n->dev.nvqs; ++index) {/* Verify that ring has been setup correctly. */ -if (!vhost_vq_access_ok (&n->vqs[index])) { +if (!vhost_vq_access_ok (&n->vqs[index].vq)) { r = -EFAULT ; goto err; } }for (index =0 ; index < n->dev.nvqs; ++index) { - vq = n->vqs + index; + vq = &n->vqs[index].vq;mutex_lock (&vq->mutex); priv = test ? n :NULL ;
@@ -195,7 +208,7 @@ static long vhost_test_run(struct vhost_test *n, int test) lockdep_is_held(&vq->mutex));rcu_assign_pointer (vq->private_data, priv); - r =vhost_init_used (&n->vqs[index]); + r =vhost_init_used (&n->vqs[index].vq);mutex_unlock (&vq->mutex);
@@ -268,14 +281,14 @@ static long vhost_test_ioctl(struct file *f, unsigned int ioctl,return -EFAULT ;return vhost_test_run (n, test);case VHOST_GET_FEATURES : - features =VHOST_NET_FEATURES ; + features =VHOST_FEATURES ;if (copy_to_user (featurep, &features,sizeof features))return -EFAULT ;return 0 ;case VHOST_SET_FEATURES :if (copy_from_user (&features, featurep,sizeof features))return -EFAULT ; -if (features & ~VHOST_NET_FEATURES ) +if (features & ~VHOST_FEATURES )return -EOPNOTSUPP ;return vhost_test_set_features (n, features);case VHOST_RESET_OWNER :
Signature · 1 line
1.8.1.4
Michael S. Tsirkin
maintainerQuoted 15 lines · Asias He
Fix it by switching to use the new device specific fields per vq
Signed-off-by Asias He <[email protected]>---
This is for 3.10.
drivers/vhost/test.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-)drivers/vhost/test.c +0
-0
drivers/vhost/test.c enum { · line 35
Quoted 7 lines
drivers/vhost/test.c +4
-0@@ -29,16 +29,20 @@ enum { VHOST_TEST_VQ_MAX = 1, }; +struct vhost_test_virtqueue { +struct vhost_virtqueue vq; +}; +
Well there are no test specific fields here, so this structure is not needed. Here's what I queued:
--->
vhost-test: fix up test module after API change
Recent vhost API changes broke vhost test module.
Update it to the new APIs.
---
drivers/vhost/test.c +8 -6
@@ -38,7 +38,7 @@ struct vhost_test {* read-size critical section for our kind of RCU. */ static void handle_vq (struct vhost_test *n) { -struct vhost_virtqueue *vq = &n->dev.vqs[VHOST_TEST_VQ ]; +struct vhost_virtqueue *vq = &n->vqs[VHOST_TEST_VQ ];unsigned out, in;int head;size_t len, total_len =0 ;
@@ -102,6 +102,7 @@ static int vhost_test_open(struct inode *inode, struct file *f) {struct vhost_test *n =kmalloc (sizeof *n,GFP_KERNEL );struct vhost_dev *dev; +struct vhost_virtqueue *vqs[VHOST_TEST_VQ_MAX ];int r;if (!n)
@@ -109,7 +110,8 @@ static int vhost_test_open(struct inode *inode, struct file *f) dev = &n->dev; n->vqs[VHOST_TEST_VQ ].handle_kick = handle_vq_kick; - r =vhost_dev_init (dev, n->vqs,VHOST_TEST_VQ_MAX ); + vqs[VHOST_TEST_VQ ] = &n->vqs[VHOST_TEST_VQ ]; + r =vhost_dev_init (dev, vqs,VHOST_TEST_VQ_MAX );if (r <0 ) {kfree (n);return r;
@@ -140,7 +142,7 @@ static void vhost_test_stop(struct vhost_test *n, void **privatep)static void vhost_test_flush_vq (struct vhost_test *n,int index) { -vhost_poll_flush (&n->dev.vqs[index].poll); +vhost_poll_flush (&n->vqs[index].poll); }static void vhost_test_flush (struct vhost_test *n)
@@ -268,21 +270,21 @@ static long vhost_test_ioctl(struct file *f, unsigned int ioctl,return -EFAULT ;return vhost_test_run (n, test);case VHOST_GET_FEATURES : - features =VHOST_NET_FEATURES ; + features =VHOST_FEATURES ;if (copy_to_user (featurep, &features,sizeof features))return -EFAULT ;return 0 ;case VHOST_SET_FEATURES :if (copy_from_user (&features, featurep,sizeof features))return -EFAULT ; -if (features & ~VHOST_NET_FEATURES ) +if (features & ~VHOST_FEATURES )return -EOPNOTSUPP ;return vhost_test_set_features (n, features);case VHOST_RESET_OWNER :return vhost_test_reset_owner (n);default :mutex_lock (&n->dev.mutex); - r =vhost_dev_ioctl (&n->dev, ioctl, arg); + r =vhost_dev_ioctl (&n->dev, ioctl, argp);vhost_test_flush (n);mutex_unlock (&n->dev.mutex);return r;
Quoted 19 lines · Michael S. Tsirkin
Quoted 18 lines · Asias He
Fix it by switching to use the new device specific fields per vq
Signed-off-by Asias He <[email protected]>---
This is for 3.10.
drivers/vhost/test.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-)drivers/vhost/test.c +0
-0@@ -29,16 +29,20 @@ enum { VHOST_TEST_VQ_MAX = 1, };
Quoted 7 lines
drivers/vhost/test.c enum { · line 35
Quoted 4 lines
drivers/vhost/test.c +4
-0+struct vhost_test_virtqueue { +struct vhost_virtqueue vq; +}; +Well there are no test specific fields here, so this structure is not needed. Here's what I queued:
Could you push the queue to your git repo ?
Quoted 76 lines
--->
vhost-test: fix up test module after API change
Recent vhost API changes broke vhost test module.
Update it to the new APIs.Signed-off-by Michael S. Tsirkin <[email protected]>---
drivers/vhost/test.c +8
-6@@ -38,7 +38,7 @@ struct vhost_test {* read-size critical section for our kind of RCU. */ static void handle_vq (struct vhost_test *n) { -struct vhost_virtqueue *vq = &n->dev.vqs[VHOST_TEST_VQ ]; +struct vhost_virtqueue *vq = &n->vqs[VHOST_TEST_VQ ];unsigned out, in;int head;size_t len, total_len =0 ;@@ -102,6 +102,7 @@ static int vhost_test_open(struct inode *inode, struct file *f) {struct vhost_test *n =kmalloc (sizeof *n,GFP_KERNEL );struct vhost_dev *dev; +struct vhost_virtqueue *vqs[VHOST_TEST_VQ_MAX ];int r;if (!n)@@ -109,7 +110,8 @@ static int vhost_test_open(struct inode *inode, struct file *f) dev = &n->dev; n->vqs[VHOST_TEST_VQ ].handle_kick = handle_vq_kick; - r =vhost_dev_init (dev, n->vqs,VHOST_TEST_VQ_MAX ); + vqs[VHOST_TEST_VQ ] = &n->vqs[VHOST_TEST_VQ ]; + r =vhost_dev_init (dev, vqs,VHOST_TEST_VQ_MAX );if (r <0 ) {kfree (n);return r;@@ -140,7 +142,7 @@ static void vhost_test_stop(struct vhost_test *n, void **privatep)static void vhost_test_flush_vq (struct vhost_test *n,int index) { -vhost_poll_flush (&n->dev.vqs[index].poll); +vhost_poll_flush (&n->vqs[index].poll); }static void vhost_test_flush (struct vhost_test *n)@@ -268,21 +270,21 @@ static long vhost_test_ioctl(struct file *f, unsigned int ioctl,return -EFAULT ;return vhost_test_run (n, test);case VHOST_GET_FEATURES : - features =VHOST_NET_FEATURES ; + features =VHOST_FEATURES ;if (copy_to_user (featurep, &features,sizeof features))return -EFAULT ;return 0 ;case VHOST_SET_FEATURES :if (copy_from_user (&features, featurep,sizeof features))return -EFAULT ; -if (features & ~VHOST_NET_FEATURES ) +if (features & ~VHOST_FEATURES )return -EOPNOTSUPP ;return vhost_test_set_features (n, features);case VHOST_RESET_OWNER :return vhost_test_reset_owner (n);default :mutex_lock (&n->dev.mutex); - r =vhost_dev_ioctl (&n->dev, ioctl, arg); + r =vhost_dev_ioctl (&n->dev, ioctl, argp);vhost_test_flush (n);mutex_unlock (&n->dev.mutex);return r;
Signature · 1 line
Asias
Michael S. Tsirkin
maintainerQuoted 28 lines · Asias He
Quoted 19 lines · Michael S. Tsirkin
Quoted 18 lines · Asias He
Fix it by switching to use the new device specific fields per vq
Signed-off-by Asias He <[email protected]>---
This is for 3.10.
drivers/vhost/test.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-)drivers/vhost/test.c +0
-0@@ -29,16 +29,20 @@ enum { VHOST_TEST_VQ_MAX = 1, };Quoted 7 lines
drivers/vhost/test.c enum { · line 35
Quoted 4 lines
drivers/vhost/test.c +4
-0+struct vhost_test_virtqueue { +struct vhost_virtqueue vq; +}; +Well there are no test specific fields here, so this structure is not needed. Here's what I queued:
Quoted 1 line
Could you push the queue to your git repo ?
done
branch vhost
Quoted 79 lines
Quoted 76 lines
--->
vhost-test: fix up test module after API change
Recent vhost API changes broke vhost test module.
Update it to the new APIs.Signed-off-by Michael S. Tsirkin <[email protected]>---
drivers/vhost/test.c +8
-6@@ -38,7 +38,7 @@ struct vhost_test {* read-size critical section for our kind of RCU. */ static void handle_vq (struct vhost_test *n) { -struct vhost_virtqueue *vq = &n->dev.vqs[VHOST_TEST_VQ ]; +struct vhost_virtqueue *vq = &n->vqs[VHOST_TEST_VQ ];unsigned out, in;int head;size_t len, total_len =0 ;@@ -102,6 +102,7 @@ static int vhost_test_open(struct inode *inode, struct file *f) {struct vhost_test *n =kmalloc (sizeof *n,GFP_KERNEL );struct vhost_dev *dev; +struct vhost_virtqueue *vqs[VHOST_TEST_VQ_MAX ];int r;if (!n)@@ -109,7 +110,8 @@ static int vhost_test_open(struct inode *inode, struct file *f) dev = &n->dev; n->vqs[VHOST_TEST_VQ ].handle_kick = handle_vq_kick; - r =vhost_dev_init (dev, n->vqs,VHOST_TEST_VQ_MAX ); + vqs[VHOST_TEST_VQ ] = &n->vqs[VHOST_TEST_VQ ]; + r =vhost_dev_init (dev, vqs,VHOST_TEST_VQ_MAX );if (r <0 ) {kfree (n);return r;@@ -140,7 +142,7 @@ static void vhost_test_stop(struct vhost_test *n, void **privatep)static void vhost_test_flush_vq (struct vhost_test *n,int index) { -vhost_poll_flush (&n->dev.vqs[index].poll); +vhost_poll_flush (&n->vqs[index].poll); }static void vhost_test_flush (struct vhost_test *n)@@ -268,21 +270,21 @@ static long vhost_test_ioctl(struct file *f, unsigned int ioctl,return -EFAULT ;return vhost_test_run (n, test);case VHOST_GET_FEATURES : - features =VHOST_NET_FEATURES ; + features =VHOST_FEATURES ;if (copy_to_user (featurep, &features,sizeof features))return -EFAULT ;return 0 ;case VHOST_SET_FEATURES :if (copy_from_user (&features, featurep,sizeof features))return -EFAULT ; -if (features & ~VHOST_NET_FEATURES ) +if (features & ~VHOST_FEATURES )return -EOPNOTSUPP ;return vhost_test_set_features (n, features);case VHOST_RESET_OWNER :return vhost_test_reset_owner (n);default :mutex_lock (&n->dev.mutex); - r =vhost_dev_ioctl (&n->dev, ioctl, arg); + r =vhost_dev_ioctl (&n->dev, ioctl, argp);vhost_test_flush (n);mutex_unlock (&n->dev.mutex);return r;Signature · 1 line
Asias
Michael S. Tsirkin
maintainerQuoted 15 lines · Asias He
Fix it by switching to use the new device specific fields per vq
Signed-off-by Asias He <[email protected]>---
This is for 3.10.
drivers/vhost/test.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-)drivers/vhost/test.c +0
-0
drivers/vhost/test.c enum { · line 35
Quoted 7 lines
drivers/vhost/test.c +4
-0@@ -29,16 +29,20 @@ enum { VHOST_TEST_VQ_MAX = 1, }; +struct vhost_test_virtqueue { +struct vhost_virtqueue vq; +}; +
Well there are no test specific fields here, so this structure is not needed. Here's what I queued:
--->
vhost-test: fix up test module after API change
Recent vhost API changes broke vhost test module.
Update it to the new APIs.
---
drivers/vhost/test.c +8 -6
@@ -38,7 +38,7 @@ struct vhost_test {* read-size critical section for our kind of RCU. */ static void handle_vq (struct vhost_test *n) { -struct vhost_virtqueue *vq = &n->dev.vqs[VHOST_TEST_VQ ]; +struct vhost_virtqueue *vq = &n->vqs[VHOST_TEST_VQ ];unsigned out, in;int head;size_t len, total_len =0 ;
@@ -102,6 +102,7 @@ static int vhost_test_open(struct inode *inode, struct file *f) {struct vhost_test *n =kmalloc (sizeof *n,GFP_KERNEL );struct vhost_dev *dev; +struct vhost_virtqueue *vqs[VHOST_TEST_VQ_MAX ];int r;if (!n)
@@ -109,7 +110,8 @@ static int vhost_test_open(struct inode *inode, struct file *f) dev = &n->dev; n->vqs[VHOST_TEST_VQ ].handle_kick = handle_vq_kick; - r =vhost_dev_init (dev, n->vqs,VHOST_TEST_VQ_MAX ); + vqs[VHOST_TEST_VQ ] = &n->vqs[VHOST_TEST_VQ ]; + r =vhost_dev_init (dev, vqs,VHOST_TEST_VQ_MAX );if (r <0 ) {kfree (n);return r;
@@ -140,7 +142,7 @@ static void vhost_test_stop(struct vhost_test *n, void **privatep)static void vhost_test_flush_vq (struct vhost_test *n,int index) { -vhost_poll_flush (&n->dev.vqs[index].poll); +vhost_poll_flush (&n->vqs[index].poll); }static void vhost_test_flush (struct vhost_test *n)
@@ -268,21 +270,21 @@ static long vhost_test_ioctl(struct file *f, unsigned int ioctl,return -EFAULT ;return vhost_test_run (n, test);case VHOST_GET_FEATURES : - features =VHOST_NET_FEATURES ; + features =VHOST_FEATURES ;if (copy_to_user (featurep, &features,sizeof features))return -EFAULT ;return 0 ;case VHOST_SET_FEATURES :if (copy_from_user (&features, featurep,sizeof features))return -EFAULT ; -if (features & ~VHOST_NET_FEATURES ) +if (features & ~VHOST_FEATURES )return -EOPNOTSUPP ;return vhost_test_set_features (n, features);case VHOST_RESET_OWNER :return vhost_test_reset_owner (n);default :mutex_lock (&n->dev.mutex); - r =vhost_dev_ioctl (&n->dev, ioctl, arg); + r =vhost_dev_ioctl (&n->dev, ioctl, argp);vhost_test_flush (n);mutex_unlock (&n->dev.mutex);return r;