All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Chen Hanxiao <chen_han_xiao@126.com>
Cc: qemu-devel@nongnu.org, Jason Wang <jasowang@redhat.com>,
	Chen Hanxiao <chenhanxiao@gmail.com>,
	mlureau@redhat.com
Subject: Re: [Qemu-devel] [PATCH resend] vhost_net: don't enable vring if backend lack this feature
Date: Tue, 13 Sep 2016 17:33:20 +0300	[thread overview]
Message-ID: <20160913173040-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <1473758935-23183-1-git-send-email-chen_han_xiao@126.com>

On Tue, Sep 13, 2016 at 05:28:55PM +0800, Chen Hanxiao wrote:
> From: Chen Hanxiao <chenhanxiao@gmail.com>
> 
> If backend(such as dpdk) lack this feature,
> don't assume it and mark it in vring_enable.
> Or we may fail in vhost_net_start,
> then we can't use vhost net.
> This will bring compat issue with old version backend.
> 
> Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>

Is there value in returning an error from vhost_user_set_vring_enable then?
Maybe we should just return 0 there if protocol
features aren't negotiated, or even change it to return void.


> ---
>  hw/net/vhost_net.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> index f2d49ad..3819e65 100644
> --- a/hw/net/vhost_net.c
> +++ b/hw/net/vhost_net.c
> @@ -425,11 +425,17 @@ int vhost_set_vring_enable(NetClientState *nc, int enable)
>  {
>      VHostNetState *net = get_vhost_net(nc);
>      const VhostOps *vhost_ops = net->dev.vhost_ops;
> -
> -    nc->vring_enable = enable;
> +    int ret;
>  
>      if (vhost_ops && vhost_ops->vhost_set_vring_enable) {
> -        return vhost_ops->vhost_set_vring_enable(&net->dev, enable);
> +        ret = vhost_ops->vhost_set_vring_enable(&net->dev, enable);
> +        if (ret == 0) {
> +            nc->vring_enable = enable;
> +        } else {
> +            nc->vring_enable = false;
> +        }
> +
> +        return ret;
>      }
>  
>      return 0;
> -- 
> 1.8.3.1
> 

      reply	other threads:[~2016-09-13 14:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-13  9:28 [Qemu-devel] [PATCH resend] vhost_net: don't enable vring if backend lack this feature Chen Hanxiao
2016-09-13 14:33 ` Michael S. Tsirkin [this message]

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=20160913173040-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=chen_han_xiao@126.com \
    --cc=chenhanxiao@gmail.com \
    --cc=jasowang@redhat.com \
    --cc=mlureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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.