diff mbox series

[v2,5/8] tools/virtio: Use __vring_new_virtqueue in virtio_test.c

Message ID 20200416075643.27330-6-eperezma@redhat.com (mailing list archive)
State New, archived
Headers show
Series tools/vhost: Reset virtqueue on tests | expand

Commit Message

Eugenio Perez Martin April 16, 2020, 7:56 a.m. UTC
As updated in ("2a2d1382fe9d virtio: Add improved queue allocation API")

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
 tools/virtio/virtio_test.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Michael S. Tsirkin April 16, 2020, 10:32 p.m. UTC | #1
On Thu, Apr 16, 2020 at 09:56:40AM +0200, Eugenio Pérez wrote:
> As updated in ("2a2d1382fe9d virtio: Add improved queue allocation API")
> 
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>

Pls add motivation for these changes.

> ---
>  tools/virtio/virtio_test.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c
> index 1d5144590df6..d9827b640c21 100644
> --- a/tools/virtio/virtio_test.c
> +++ b/tools/virtio/virtio_test.c
> @@ -106,10 +106,9 @@ static void vq_info_add(struct vdev_info *dev, int num)
>  	assert(r >= 0);
>  	memset(info->ring, 0, vring_legacy_size(num, 4096));
>  	vring_legacy_init(&info->vring, num, info->ring, 4096);
> -	info->vq = vring_new_virtqueue(info->idx,
> -				       info->vring.num, 4096, &dev->vdev,
> -				       true, false, info->ring,
> -				       vq_notify, vq_callback, "test");
> +	info->vq =
> +		__vring_new_virtqueue(info->idx, info->vring, &dev->vdev, true,
> +				      false, vq_notify, vq_callback, "test");
>  	assert(info->vq);
>  	info->vq->priv = info;
>  	vhost_vq_setup(dev, info);
> -- 
> 2.18.1
Eugenio Perez Martin April 17, 2020, 12:24 p.m. UTC | #2
On Fri, Apr 17, 2020 at 12:33 AM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Thu, Apr 16, 2020 at 09:56:40AM +0200, Eugenio Pérez wrote:
> > As updated in ("2a2d1382fe9d virtio: Add improved queue allocation API")
> >
> > Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
>
> Pls add motivation for these changes.
>

The original motivation was to make code as close as possible to
virtio_net. Also, it skips a (probably not expensive) initialization
in vring_new_virtqueue.

With the recent events, I think that this could be useful to test when
userspace and kernel use different struct layout, maybe with some
sanitizer. I can drop it if you don't see it the same way (or if I
didn't understand the problem and this does not help).

Thanks!

> > ---
> >  tools/virtio/virtio_test.c | 7 +++----
> >  1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c
> > index 1d5144590df6..d9827b640c21 100644
> > --- a/tools/virtio/virtio_test.c
> > +++ b/tools/virtio/virtio_test.c
> > @@ -106,10 +106,9 @@ static void vq_info_add(struct vdev_info *dev, int num)
> >       assert(r >= 0);
> >       memset(info->ring, 0, vring_legacy_size(num, 4096));
> >       vring_legacy_init(&info->vring, num, info->ring, 4096);
> > -     info->vq = vring_new_virtqueue(info->idx,
> > -                                    info->vring.num, 4096, &dev->vdev,
> > -                                    true, false, info->ring,
> > -                                    vq_notify, vq_callback, "test");
> > +     info->vq =
> > +             __vring_new_virtqueue(info->idx, info->vring, &dev->vdev, true,
> > +                                   false, vq_notify, vq_callback, "test");
> >       assert(info->vq);
> >       info->vq->priv = info;
> >       vhost_vq_setup(dev, info);
> > --
> > 2.18.1
>
diff mbox series

Patch

diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c
index 1d5144590df6..d9827b640c21 100644
--- a/tools/virtio/virtio_test.c
+++ b/tools/virtio/virtio_test.c
@@ -106,10 +106,9 @@  static void vq_info_add(struct vdev_info *dev, int num)
 	assert(r >= 0);
 	memset(info->ring, 0, vring_legacy_size(num, 4096));
 	vring_legacy_init(&info->vring, num, info->ring, 4096);
-	info->vq = vring_new_virtqueue(info->idx,
-				       info->vring.num, 4096, &dev->vdev,
-				       true, false, info->ring,
-				       vq_notify, vq_callback, "test");
+	info->vq =
+		__vring_new_virtqueue(info->idx, info->vring, &dev->vdev, true,
+				      false, vq_notify, vq_callback, "test");
 	assert(info->vq);
 	info->vq->priv = info;
 	vhost_vq_setup(dev, info);