Skip to contentSkip to conversation

vhost_net: initialize acked_features to a safe value during ack

PATCH In review Jason Wang 3 participants 6 messages Sep 3, 2014

lore
Share & tools
lore

Jason Wang

author
#0 lore raw

PATCH 1/1 vhost_net: initialize acked_features to a safe value during ack

commit 2e6d46d77ed328d34a94688da8371bcbe243479b (vhost: add vhost_get_features and vhost_ack_features) removes the step that initializes the acked_features to backend_features. This will result an unexpected value of acked_features which may fail the features setting of vhost. This patch fixes it by recover this step.

Cc Nikolay Nikolaev <[email protected]>
Cc Andrey Korolyov <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Cc Michael Roth <[email protected]>
---
 hw/net/vhost_net.c | 1 +
 1 file changed, 1 insertion(+)
hw/net/vhost_net.c +1 -0
index f87c798..b1d4b1f 100644
@@ -115,6 +115,7 @@ unsigned vhost_net_get_features(struct vhost_net *net, unsigned features)
 
 void vhost_net_ack_features(struct vhost_net *net, unsigned features)
 {
+    net->dev.acked_features = net->dev.backend_features;
     vhost_ack_features(&net->dev, vhost_net_get_feature_bits(net), features);
 }
 
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 3 lines · Jason Wang

commit 2e6d46d77ed328d34a94688da8371bcbe243479b (vhost: add vhost_get_features and vhost_ack_features) removes the step that initializes the acked_features to backend_features.

But acked features are set in vhost_ack_features. why would we need to initialize to backend_features? 0 is a better default.

Quoted 19 lines

This will result an
unexpected value of acked_features which may fail the features setting of vhost. This patch fixes it by recover this step.

Cc Nikolay Nikolaev <[email protected]>
Cc Andrey Korolyov <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Cc Michael Roth <[email protected]>
---
 hw/net/vhost_net.c | 1 +
 1 file changed, 1 insertion(+)
hw/net/vhost_net.c +0 -0
index f87c798..b1d4b1f 100644

hw/net/vhost_net.c unsigned vhost_net_get_features(struct vhost_net *net, unsigned features) · line 118

Quoted 4 lines
hw/net/vhost_net.c +1 -0
@@ -115,6 +115,7 @@ unsigned vhost_net_get_features(struct vhost_net *net, unsigned features)
 
 void vhost_net_ack_features(struct vhost_net *net, unsigned features)
 {
+    net->dev.acked_features = net->dev.backend_features;

I think it's wrong: you don't want to set all features.

Quoted 5 lines
hw/net/vhost_net.c +0 -0
     vhost_ack_features(&net->dev, vhost_net_get_feature_bits(net), features);
 }
 
Signature · 1 line
1.8.3.1
#2 lore raw
In reply to Jason Wang
Quoted 6 lines · Jason Wang

commit 2e6d46d77ed328d34a94688da8371bcbe243479b (vhost: add vhost_get_features and vhost_ack_features) removes the step that initializes the acked_features to backend_features. This will result an unexpected value of acked_features which may fail the features setting of vhost. This patch fixes it by recover this step.

Quoted 6 lines
Cc Nikolay Nikolaev <[email protected]>
Cc Andrey Korolyov <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Cc Michael Roth <[email protected]>

OK I get it and it's correct, but I think it's better to put the initialization in core vhost code.
Patch sent, could you confirm that it works for you please?

Quoted 18 lines
---
 hw/net/vhost_net.c | 1 +
 1 file changed, 1 insertion(+)
hw/net/vhost_net.c +1 -0
index f87c798..b1d4b1f 100644
@@ -115,6 +115,7 @@ unsigned vhost_net_get_features(struct vhost_net *net, unsigned features)
 
 void vhost_net_ack_features(struct vhost_net *net, unsigned features)
 {
+    net->dev.acked_features = net->dev.backend_features;
     vhost_ack_features(&net->dev, vhost_net_get_feature_bits(net), features);
 }
 
Signature · 1 line
1.8.3.1
#3 lore raw
Quoted 28 lines · Michael S. Tsirkin
Quoted 6 lines · Jason Wang

commit 2e6d46d77ed328d34a94688da8371bcbe243479b (vhost: add vhost_get_features and vhost_ack_features) removes the step that initializes the acked_features to backend_features. This will result an unexpected value of acked_features which may fail the features setting of vhost. This patch fixes it by recover this step.

Quoted 6 lines
Cc Nikolay Nikolaev <[email protected]>
Cc Andrey Korolyov <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Cc Michael Roth <[email protected]>

OK I get it and it's correct, but I think it's better to put the initialization in core vhost code.
Patch sent, could you confirm that it works for you please?

Quoted 10 lines
---
 hw/net/vhost_net.c | 1 +
 1 file changed, 1 insertion(+)
hw/net/vhost_net.c +0 -0
index f87c798..b1d4b1f 100644
@@ -115,6 +115,7 @@ unsigned vhost_net_get_features(struct vhost_net *net, unsigned features)
 
Quoted 8 lines
Quoted 8 lines
hw/net/vhost_net.c +1 -1
 void vhost_net_ack_features(struct vhost_net *net, unsigned features)
 {
+    net->dev.acked_features = net->dev.backend_features;
     vhost_ack_features(&net->dev, vhost_net_get_feature_bits(net), features);
 }
 
--

1.8.3.1

Yes, this patch fixes both issues with vhost subsystem for me.

#4 lore raw
Quoted 35 lines · Andrey Korolyov
Quoted 34 lines · Michael S. Tsirkin
Quoted 6 lines · Jason Wang

commit 2e6d46d77ed328d34a94688da8371bcbe243479b (vhost: add vhost_get_features and vhost_ack_features) removes the step that initializes the acked_features to backend_features. This will result an unexpected value of acked_features which may fail the features setting of vhost. This patch fixes it by recover this step.

Quoted 6 lines
Cc Nikolay Nikolaev <[email protected]>
Cc Andrey Korolyov <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Cc Michael Roth <[email protected]>

OK I get it and it's correct, but I think it's better to put the initialization in core vhost code.
Patch sent, could you confirm that it works for you please?

Quoted 16 lines
---
 hw/net/vhost_net.c | 1 +
 1 file changed, 1 insertion(+)
hw/net/vhost_net.c +1 -0
index f87c798..b1d4b1f 100644
@@ -115,6 +115,7 @@ unsigned vhost_net_get_features(struct vhost_net *net, unsigned features)
 
 void vhost_net_ack_features(struct vhost_net *net, unsigned features)
 {
+    net->dev.acked_features = net->dev.backend_features;
     vhost_ack_features(&net->dev, vhost_net_get_feature_bits(net), features);
 }
 
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

--
1.8.3.1

Yes, this patch fixes both issues with vhost subsystem for me.

Sorry posted a different one - can you pls try it out? We still have a bug somewhere in error handling I suspect, so let's keep debugging.

#5 lore raw
In reply to Andrey Korolyov
Quoted 35 lines · Andrey Korolyov
Quoted 34 lines · Michael S. Tsirkin
Quoted 6 lines · Jason Wang

commit 2e6d46d77ed328d34a94688da8371bcbe243479b (vhost: add vhost_get_features and vhost_ack_features) removes the step that initializes the acked_features to backend_features. This will result an unexpected value of acked_features which may fail the features setting of vhost. This patch fixes it by recover this step.

Quoted 6 lines
Cc Nikolay Nikolaev <[email protected]>
Cc Andrey Korolyov <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Cc Michael Roth <[email protected]>

OK I get it and it's correct, but I think it's better to put the initialization in core vhost code.
Patch sent, could you confirm that it works for you please?

Quoted 16 lines
---
 hw/net/vhost_net.c | 1 +
 1 file changed, 1 insertion(+)
hw/net/vhost_net.c +1 -0
index f87c798..b1d4b1f 100644
@@ -115,6 +115,7 @@ unsigned vhost_net_get_features(struct vhost_net *net, unsigned features)
 
 void vhost_net_ack_features(struct vhost_net *net, unsigned features)
 {
+    net->dev.acked_features = net->dev.backend_features;
     vhost_ack_features(&net->dev, vhost_net_get_feature_bits(net), features);
 }
 
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

--
1.8.3.1

Yes, this patch fixes both issues with vhost subsystem for me.

OK, applied, thanks!
But let's hack on the assert a bit more: apparently something is wrong with the userspace fallback: after init failure, it should never trigger, and it does.

Signature · 1 line
MST