diff mbox

vhost_net: initialize acked_features to a safe value during ack

Message ID 1409725530-1425-1-git-send-email-jasowang@redhat.com
State New
Headers show

Commit Message

Jason Wang Sept. 3, 2014, 6:25 a.m. UTC
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 <n.nikolaev@virtualopensystems.com>
Cc: Andrey Korolyov <andrey@xdel.ru>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/net/vhost_net.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Michael S. Tsirkin Sept. 3, 2014, 8:30 a.m. UTC | #1
On Wed, Sep 03, 2014 at 02:25:30PM +0800, Jason Wang wrote:
> 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.

> 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 <n.nikolaev@virtualopensystems.com>
> Cc: Andrey Korolyov <andrey@xdel.ru>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  hw/net/vhost_net.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> index f87c798..b1d4b1f 100644
> --- a/hw/net/vhost_net.c
> +++ b/hw/net/vhost_net.c
> @@ -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.

>      vhost_ack_features(&net->dev, vhost_net_get_feature_bits(net), features);
>  }
>  
> -- 
> 1.8.3.1
Michael S. Tsirkin Sept. 3, 2014, 8:52 a.m. UTC | #2
On Wed, Sep 03, 2014 at 02:25:30PM +0800, Jason Wang wrote:
> 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 <n.nikolaev@virtualopensystems.com>
> Cc: Andrey Korolyov <andrey@xdel.ru>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Jason Wang <jasowang@redhat.com>

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?

> ---
>  hw/net/vhost_net.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> index f87c798..b1d4b1f 100644
> --- a/hw/net/vhost_net.c
> +++ b/hw/net/vhost_net.c
> @@ -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);
>  }
>  
> -- 
> 1.8.3.1
Andrey Korolyov Sept. 3, 2014, 8:54 a.m. UTC | #3
On Wed, Sep 3, 2014 at 12:52 PM, Michael S. Tsirkin <mst@redhat.com> wrote:
> On Wed, Sep 03, 2014 at 02:25:30PM +0800, Jason Wang wrote:
>> 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 <n.nikolaev@virtualopensystems.com>
>> Cc: Andrey Korolyov <andrey@xdel.ru>
>> Cc: Michael S. Tsirkin <mst@redhat.com>
>> Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
>> Cc: qemu-stable@nongnu.org
>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>
> 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?
>
>> ---
>>  hw/net/vhost_net.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
>> index f87c798..b1d4b1f 100644
>> --- a/hw/net/vhost_net.c
>> +++ b/hw/net/vhost_net.c
>> @@ -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);
>>  }
>>
>> --
>> 1.8.3.1

Yes, this patch fixes both issues with vhost subsystem for me.
Michael S. Tsirkin Sept. 3, 2014, 9:08 a.m. UTC | #4
On Wed, Sep 03, 2014 at 12:54:03PM +0400, Andrey Korolyov wrote:
> On Wed, Sep 3, 2014 at 12:52 PM, Michael S. Tsirkin <mst@redhat.com> wrote:
> > On Wed, Sep 03, 2014 at 02:25:30PM +0800, Jason Wang wrote:
> >> 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 <n.nikolaev@virtualopensystems.com>
> >> Cc: Andrey Korolyov <andrey@xdel.ru>
> >> Cc: Michael S. Tsirkin <mst@redhat.com>
> >> Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
> >> Cc: qemu-stable@nongnu.org
> >> Signed-off-by: Jason Wang <jasowang@redhat.com>
> >
> > 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?
> >
> >> ---
> >>  hw/net/vhost_net.c | 1 +
> >>  1 file changed, 1 insertion(+)
> >>
> >> diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> >> index f87c798..b1d4b1f 100644
> >> --- a/hw/net/vhost_net.c
> >> +++ b/hw/net/vhost_net.c
> >> @@ -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);
> >>  }
> >>
> >> --
> >> 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.
Michael S. Tsirkin Sept. 3, 2014, 9:17 a.m. UTC | #5
On Wed, Sep 03, 2014 at 12:54:03PM +0400, Andrey Korolyov wrote:
> On Wed, Sep 3, 2014 at 12:52 PM, Michael S. Tsirkin <mst@redhat.com> wrote:
> > On Wed, Sep 03, 2014 at 02:25:30PM +0800, Jason Wang wrote:
> >> 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 <n.nikolaev@virtualopensystems.com>
> >> Cc: Andrey Korolyov <andrey@xdel.ru>
> >> Cc: Michael S. Tsirkin <mst@redhat.com>
> >> Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
> >> Cc: qemu-stable@nongnu.org
> >> Signed-off-by: Jason Wang <jasowang@redhat.com>
> >
> > 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?
> >
> >> ---
> >>  hw/net/vhost_net.c | 1 +
> >>  1 file changed, 1 insertion(+)
> >>
> >> diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> >> index f87c798..b1d4b1f 100644
> >> --- a/hw/net/vhost_net.c
> >> +++ b/hw/net/vhost_net.c
> >> @@ -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);
> >>  }
> >>
> >> --
> >> 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.
diff mbox

Patch

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index f87c798..b1d4b1f 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -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);
 }