From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Tetsuya Mukawa <mukawa@igel.co.jp>
Cc: dev@dpdk.org, ann.zhuangyanying@huawei.com
Subject: Re: [PATCH] vhost: Fix wrong handling of virtqueue array index
Date: Tue, 27 Oct 2015 16:00:14 +0800 [thread overview]
Message-ID: <20151027080014.GF3115@yliu-dev.sh.intel.com> (raw)
In-Reply-To: <1445932306-11880-1-git-send-email-mukawa@igel.co.jp>
On Tue, Oct 27, 2015 at 04:51:46PM +0900, Tetsuya Mukawa wrote:
> The patch fixes wrong handling of virtqueue array index when
> GET_VRING_BASE message comes.
> The vhost backend will receive the message per virtqueue.
> Also we should call a destroy callback handler when both RXQ
> and TXQ receives the message.
>
> Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Thanks.
--yliu
> ---
> lib/librte_vhost/vhost_user/virtio-net-user.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c
> index a998ad8..99c075f 100644
> --- a/lib/librte_vhost/vhost_user/virtio-net-user.c
> +++ b/lib/librte_vhost/vhost_user/virtio-net-user.c
> @@ -283,12 +283,10 @@ user_get_vring_base(struct vhost_device_ctx ctx,
> struct vhost_vring_state *state)
> {
> struct virtio_net *dev = get_device(ctx);
> + uint16_t base_idx = state->index / VIRTIO_QNUM * VIRTIO_QNUM;
>
> if (dev == NULL)
> return -1;
> - /* We have to stop the queue (virtio) if it is running. */
> - if (dev->flags & VIRTIO_DEV_RUNNING)
> - notify_ops->destroy_device(dev);
>
> /* Here we are safe to get the last used index */
> ops->get_vring_base(ctx, state->index, state);
> @@ -300,15 +298,17 @@ user_get_vring_base(struct vhost_device_ctx ctx,
> * sent and only sent in vhost_vring_stop.
> * TODO: cleanup the vring, it isn't usable since here.
> */
> - if (dev->virtqueue[state->index + VIRTIO_RXQ]->kickfd >= 0) {
> - close(dev->virtqueue[state->index + VIRTIO_RXQ]->kickfd);
> - dev->virtqueue[state->index + VIRTIO_RXQ]->kickfd = -1;
> - }
> - if (dev->virtqueue[state->index + VIRTIO_TXQ]->kickfd >= 0) {
> - close(dev->virtqueue[state->index + VIRTIO_TXQ]->kickfd);
> - dev->virtqueue[state->index + VIRTIO_TXQ]->kickfd = -1;
> + if (dev->virtqueue[state->index]->kickfd >= 0) {
> + close(dev->virtqueue[state->index]->kickfd);
> + dev->virtqueue[state->index]->kickfd = -1;
> }
>
> + /* We have to stop the queue (virtio) if it is running. */
> + if ((dev->flags & VIRTIO_DEV_RUNNING) &&
> + (dev->virtqueue[base_idx + VIRTIO_RXQ]->kickfd == -1) &&
> + (dev->virtqueue[base_idx + VIRTIO_TXQ]->kickfd == -1))
> + notify_ops->destroy_device(dev);
> +
> return 0;
> }
>
> --
> 2.1.4
next prev parent reply other threads:[~2015-10-27 7:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-27 7:51 [PATCH] vhost: Fix wrong handling of virtqueue array index Tetsuya Mukawa
2015-10-27 8:00 ` Yuanhan Liu [this message]
2015-10-27 8:24 ` Xie, Huawei
2015-10-27 8:39 ` Yuanhan Liu
2015-10-27 8:46 ` Xie, Huawei
2015-10-27 8:57 ` Yuanhan Liu
2015-10-27 9:25 ` Tetsuya Mukawa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151027080014.GF3115@yliu-dev.sh.intel.com \
--to=yuanhan.liu@linux.intel.com \
--cc=ann.zhuangyanying@huawei.com \
--cc=dev@dpdk.org \
--cc=mukawa@igel.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.