From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43622) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjom7-00089W-Cs for qemu-devel@nongnu.org; Tue, 13 Sep 2016 10:33:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjom2-0006Xo-BZ for qemu-devel@nongnu.org; Tue, 13 Sep 2016 10:33:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44346) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjom2-0006VI-5V for qemu-devel@nongnu.org; Tue, 13 Sep 2016 10:33:22 -0400 Date: Tue, 13 Sep 2016 17:33:20 +0300 From: "Michael S. Tsirkin" Message-ID: <20160913173040-mutt-send-email-mst@kernel.org> References: <1473758935-23183-1-git-send-email-chen_han_xiao@126.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1473758935-23183-1-git-send-email-chen_han_xiao@126.com> Subject: Re: [Qemu-devel] [PATCH resend] vhost_net: don't enable vring if backend lack this feature List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chen Hanxiao Cc: qemu-devel@nongnu.org, Jason Wang , Chen Hanxiao , mlureau@redhat.com On Tue, Sep 13, 2016 at 05:28:55PM +0800, Chen Hanxiao wrote: > From: Chen Hanxiao > > 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 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 >