Skip to contentSkip to conversation

vhost_net: don't enable vring if backend lack this feature

PATCH Superseded Chen Hanxiao 1 participant 2 messages Sep 3, 2016 – Sep 8, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost_net: don't enable vring if backend lack this feature

From: Chen Hanxiao <[email protected]>

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.

---
 hw/net/vhost_net.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
hw/net/vhost_net.c +9 -3
index f2d49ad..3819e65 100644
@@ -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;
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 10 lines · Chen Hanxiao

From: Chen Hanxiao <[email protected]>

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.

---

Hi,

Any comments?

Regards,
- Chen