From cd81ee7cc28b11cd698b61a1db6b99a847bb33ea Mon Sep 17 00:00:00 2001 From: Victor Kaplansky Date: Tue, 24 Nov 2015 15:25:35 +0800 Subject: [PATCH] vhost: fix enabling vring per queue 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. Signed-off-by: Victor Kaplansky Signed-off-by: Yuanhan Liu --- 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 99da029dd5..2934d1c063 100644 --- a/lib/librte_vhost/vhost_user/virtio-net-user.c +++ b/lib/librte_vhost/vhost_user/virtio-net-user.c @@ -323,7 +323,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, @@ -331,12 +330,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; } -- 2.20.1