* [Qemu-devel] [PATCH resend] vhost_net: don't enable vring if backend lack this feature
@ 2016-09-13 9:28 Chen Hanxiao
2016-09-13 14:33 ` Michael S. Tsirkin
0 siblings, 1 reply; 2+ messages in thread
From: Chen Hanxiao @ 2016-09-13 9:28 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael S. Tsirkin, Jason Wang, Chen Hanxiao
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>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH resend] vhost_net: don't enable vring if backend lack this feature
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
0 siblings, 0 replies; 2+ messages in thread
From: Michael S. Tsirkin @ 2016-09-13 14:33 UTC (permalink / raw)
To: Chen Hanxiao; +Cc: qemu-devel, Jason Wang, Chen Hanxiao, mlureau
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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-09-13 14:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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.