Re: [Qemu-devel] [PATCH] vhost_net: don't enable vring if backend lack this feature

2016-09-08 Thread Chen Hanxiao


At 2016-09-03 16:44:47, "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 
>---

Hi,

Any comments?

Regards,
- Chen

[Qemu-devel] [PATCH] vhost_net: don't enable vring if backend lack this feature

2016-09-03 Thread Chen Hanxiao
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 
---
 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(>dev, enable);
+ret = vhost_ops->vhost_set_vring_enable(>dev, enable);
+if (ret == 0) {
+nc->vring_enable = enable;
+} else {
+nc->vring_enable = false;
+}
+
+return ret;
 }
 
 return 0;
-- 
1.8.3.1