[dpdk-dev,v2] vhost-user: fix enabling of queue pair

Message ID 1448349935-1935-1-git-send-email-yuanhan.liu@linux.intel.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Yuanhan Liu Nov. 24, 2015, 7:25 a.m. UTC
  From: Victor Kaplansky <victork@redhat.com>

The VHOST_USER_SET_VRING_ENABLE request was sent for each queue-pair.
However, it's changed to be sent per queue in the queue-pair by QEMU
commit dc3db6ad ("vhost-user: start/stop all rings"). The change
is reasonable, as we send all other request per queue, instead of
queue-pair.

Hence we should do proper changes to adapt to the QEMU change here.
Otherwise, a segfault will be triggered when last TX queue was enabled.

[ commit log reword --  Yuanhan Liu ]

Signed-off-by: Victor Kaplansky <victork@redhat.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---

v2: invoke vring_state_changed() callback per-vring as well

This fixes a fatal issue, without that MQ will not work properly.
Seems that Victor is busy at something else (or out of office so
far), hence I sent v2 on behalf of him.

---
 lib/librte_vhost/vhost_user/virtio-net-user.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
  

Comments

Victor Kaplansky Nov. 24, 2015, 7:43 a.m. UTC | #1
Yuanhan, looks fine. Thanks for handling this.
-- Victor

On Tue, Nov 24, 2015 at 03:25:35PM +0800, Yuanhan Liu wrote:
> From: Victor Kaplansky <victork@redhat.com>
> 
> The VHOST_USER_SET_VRING_ENABLE request was sent for each queue-pair.
> However, it's changed to be sent per queue in the queue-pair by QEMU
> commit dc3db6ad ("vhost-user: start/stop all rings"). The change
> is reasonable, as we send all other request per queue, instead of
> queue-pair.
> 
> Hence we should do proper changes to adapt to the QEMU change here.
> Otherwise, a segfault will be triggered when last TX queue was enabled.
> 
> [ commit log reword --  Yuanhan Liu ]
> 
> Signed-off-by: Victor Kaplansky <victork@redhat.com>
> Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> ---
> 
> v2: invoke vring_state_changed() callback per-vring as well
> 
> This fixes a fatal issue, without that MQ will not work properly.
> Seems that Victor is busy at something else (or out of office so
> far), hence I sent v2 on behalf of him.
> 
> ---
>  lib/librte_vhost/vhost_user/virtio-net-user.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c
> index d07452a..b2ada9f 100644
> --- a/lib/librte_vhost/vhost_user/virtio-net-user.c
> +++ b/lib/librte_vhost/vhost_user/virtio-net-user.c
> @@ -317,7 +317,6 @@ user_set_vring_enable(struct vhost_device_ctx ctx,
>  		      struct vhost_vring_state *state)
>  {
>  	struct virtio_net *dev = get_device(ctx);
> -	uint16_t base_idx = state->index;
>  	int enable = (int)state->num;
>  
>  	RTE_LOG(INFO, VHOST_CONFIG,
> @@ -325,12 +324,10 @@ user_set_vring_enable(struct vhost_device_ctx ctx,
>  		enable, state->index);
>  
>  	if (notify_ops->vring_state_changed) {
> -		notify_ops->vring_state_changed(dev, base_idx / VIRTIO_QNUM,
> -						enable);
> +		notify_ops->vring_state_changed(dev, state->index, enable);
>  	}
>  
> -	dev->virtqueue[base_idx + VIRTIO_RXQ]->enabled = enable;
> -	dev->virtqueue[base_idx + VIRTIO_TXQ]->enabled = enable;
> +	dev->virtqueue[state->index]->enabled = enable;
>  
>  	return 0;
>  }
> -- 
> 1.9.3
  
Thomas Monjalon Nov. 24, 2015, 8:29 p.m. UTC | #2
2015-11-24 09:43, Victor Kaplansky:
> Yuanhan, looks fine. Thanks for handling this.
> -- Victor
> 
> On Tue, Nov 24, 2015 at 03:25:35PM +0800, Yuanhan Liu wrote:
> > From: Victor Kaplansky <victork@redhat.com>
> > 
> > The VHOST_USER_SET_VRING_ENABLE request was sent for each queue-pair.
> > However, it's changed to be sent per queue in the queue-pair by QEMU
> > commit dc3db6ad ("vhost-user: start/stop all rings"). The change
> > is reasonable, as we send all other request per queue, instead of
> > queue-pair.
> > 
> > Hence we should do proper changes to adapt to the QEMU change here.
> > Otherwise, a segfault will be triggered when last TX queue was enabled.
> > 
> > [ commit log reword --  Yuanhan Liu ]
> > 
> > Signed-off-by: Victor Kaplansky <victork@redhat.com>
> > Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> > ---
> > 
> > v2: invoke vring_state_changed() callback per-vring as well
> > 
> > This fixes a fatal issue, without that MQ will not work properly.
> > Seems that Victor is busy at something else (or out of office so
> > far), hence I sent v2 on behalf of him.

Applied, thanks
  

Patch

diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c
index d07452a..b2ada9f 100644
--- a/lib/librte_vhost/vhost_user/virtio-net-user.c
+++ b/lib/librte_vhost/vhost_user/virtio-net-user.c
@@ -317,7 +317,6 @@  user_set_vring_enable(struct vhost_device_ctx ctx,
 		      struct vhost_vring_state *state)
 {
 	struct virtio_net *dev = get_device(ctx);
-	uint16_t base_idx = state->index;
 	int enable = (int)state->num;
 
 	RTE_LOG(INFO, VHOST_CONFIG,
@@ -325,12 +324,10 @@  user_set_vring_enable(struct vhost_device_ctx ctx,
 		enable, state->index);
 
 	if (notify_ops->vring_state_changed) {
-		notify_ops->vring_state_changed(dev, base_idx / VIRTIO_QNUM,
-						enable);
+		notify_ops->vring_state_changed(dev, state->index, enable);
 	}
 
-	dev->virtqueue[base_idx + VIRTIO_RXQ]->enabled = enable;
-	dev->virtqueue[base_idx + VIRTIO_TXQ]->enabled = enable;
+	dev->virtqueue[state->index]->enabled = enable;
 
 	return 0;
 }