vhost_net: don't enable vring if backend lack this feature
PATCH v2 1/1 vhost_net: don't enable vring if backend lack this feature
From: Chen Hanxiao <[email protected]>
If backend(such as dpdk) lack the feather,
don't assume it in vring_enable.
Or we may fail in vhost_net_start, then we can't use vhost. This will bring compat issue with old version backend.
---
v2: return 0 there if protocol features aren't negotiated.
hw/net/vhost_net.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
hw/net/vhost_net.c +9 -3
@@ -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); +/* +* Try to enable vring feature. +* If protocol features aren't negotiated, return 0 for back compat. +*/ +if (ret ==0 ) { + nc->vring_enable = enable; + } }return 0 ;
Signature · 1 line
1.8.3.1
Quoted 3 lines · Chen Hanxiao
From: Chen Hanxiao <[email protected]>
If backend(such as dpdk) lack the feather,
Sorry, I don't understand what does this mean.
Quoted 18 lines
don't assume it in
vring_enable.
Or we may fail invhost_net_start, then we can't use vhost. This will bring compat issue with old version backend.Signed-off-by Chen Hanxiao <[email protected]>---
v2: return 0 there if protocol features aren't negotiated.hw/net/vhost_net.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)hw/net/vhost_net.c +0
-0@@ -425,11 +425,17 @@ int vhost_set_vring_enable(NetClientState *nc, int enable) {VHostNetState *net =get_vhost_net (nc);
hw/net/vhost_net.c int vhost_set_vring_enable(NetClientState *nc, int enable) · line 433
Quoted 10 lines
hw/net/vhost_net.c +4
-3const 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); +/* +* Try to enable vring feature.
What does this mean?
hw/net/vhost_net.c int vhost_set_vring_enable(NetClientState *nc, int enable) · line 434
Quoted 1 line
hw/net/vhost_net.c +1
-0+* If protocol features aren't negotiated, return 0 for back compat.
How do you mean "for back compat"?
hw/net/vhost_net.c int vhost_set_vring_enable(NetClientState *nc, int enable) · line 439
Quoted 5 lines
hw/net/vhost_net.c +4
-0+*/ +if (ret ==0 ) { + nc->vring_enable = enable; + } }
This clearly does not set vring_enable if vhost_set_vring_enable is NULL.
Quoted 5 lines
hw/net/vhost_net.c +0
-0return 0 ;Signature · 1 line
1.8.3.1