[Qemu-devel] [PATCH] vhost-user: save features if the char dev is closed

Adrian Moreno posted 1 patch 6 years, 1 month ago
Test checkpatch passed
Test FreeBSD passed
Test docker-mingw@fedora passed
Test asan passed
Test docker-clang@ubuntu passed
Test docker-quick@centos7 passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20190917191901.28348-1-amorenoz@redhat.com
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Jason Wang <jasowang@redhat.com>
There is a newer version of this series
net/vhost-user.c | 7 +++++++
1 file changed, 7 insertions(+)
[Qemu-devel] [PATCH] vhost-user: save features if the char dev is closed
Posted by Adrian Moreno 6 years, 1 month ago
That way the state can be correctly restored when the device is opened
again. This might happen if the backend is restarted.

Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1738768
Reported-by: Pei Zhang <pezhang@redhat.com>
Fixes: 6ab79a20af3a (do not call vhost_net_cleanup() on running net from char user event)
Cc: ddstreet@canonical.com
Cc: Michael S. Tsirkin <mst@redhat.com>

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
---
 net/vhost-user.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/vhost-user.c b/net/vhost-user.c
index 51921de443..acf20cb9e0 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -235,6 +235,13 @@ static void chr_closed_bh(void *opaque)
 
     s = DO_UPCAST(NetVhostUserState, nc, ncs[0]);
 
+    if (s->vhost_net) {
+        uint64_t features = vhost_net_get_acked_features(s->vhost_net);
+        if (features) {
+            s->acked_features = features;
+         }
+    }
+
     qmp_set_link(name, false, &err);
 
     qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, net_vhost_user_event,
-- 
2.21.0


Re: [Qemu-devel] [PATCH] vhost-user: save features if the char dev is closed
Posted by Michael S. Tsirkin 6 years, 1 month ago
On Tue, Sep 17, 2019 at 09:19:01PM +0200, Adrian Moreno wrote:
> That way the state can be correctly restored when the device is opened
> again. This might happen if the backend is restarted.
> 
> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1738768
> Reported-by: Pei Zhang <pezhang@redhat.com>
> Fixes: 6ab79a20af3a (do not call vhost_net_cleanup() on running net from char user event)
> Cc: ddstreet@canonical.com
> Cc: Michael S. Tsirkin <mst@redhat.com>
> 
> Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
> ---
>  net/vhost-user.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/net/vhost-user.c b/net/vhost-user.c
> index 51921de443..acf20cb9e0 100644
> --- a/net/vhost-user.c
> +++ b/net/vhost-user.c
> @@ -235,6 +235,13 @@ static void chr_closed_bh(void *opaque)
>  
>      s = DO_UPCAST(NetVhostUserState, nc, ncs[0]);
>  
> +    if (s->vhost_net) {
> +        uint64_t features = vhost_net_get_acked_features(s->vhost_net);
> +        if (features) {
> +            s->acked_features = features;
> +         }

why does it make sense to check if (features)?
0x0 is a valid feature bitmap, isn't it?

> +    }
> +
>      qmp_set_link(name, false, &err);
>  
>      qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, net_vhost_user_event,
> -- 
> 2.21.0

Re: [Qemu-devel] [PATCH] vhost-user: save features if the char dev is closed
Posted by Adrian Moreno 6 years, 1 month ago
On 9/17/19 11:40 PM, Michael S. Tsirkin wrote:
> On Tue, Sep 17, 2019 at 09:19:01PM +0200, Adrian Moreno wrote:
>> That way the state can be correctly restored when the device is opened
>> again. This might happen if the backend is restarted.
>>
>> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1738768
>> Reported-by: Pei Zhang <pezhang@redhat.com>
>> Fixes: 6ab79a20af3a (do not call vhost_net_cleanup() on running net from char user event)
>> Cc: ddstreet@canonical.com
>> Cc: Michael S. Tsirkin <mst@redhat.com>
>>
>> Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
>> ---
>>  net/vhost-user.c | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/net/vhost-user.c b/net/vhost-user.c
>> index 51921de443..acf20cb9e0 100644
>> --- a/net/vhost-user.c
>> +++ b/net/vhost-user.c
>> @@ -235,6 +235,13 @@ static void chr_closed_bh(void *opaque)
>>  
>>      s = DO_UPCAST(NetVhostUserState, nc, ncs[0]);
>>  
>> +    if (s->vhost_net) {
>> +        uint64_t features = vhost_net_get_acked_features(s->vhost_net);
>> +        if (features) {
>> +            s->acked_features = features;
>> +         }
> 
> why does it make sense to check if (features)?
> 0x0 is a valid feature bitmap, isn't it?
You're right. It doesn't.
I'll remove the check.

> 
>> +    }
>> +
>>      qmp_set_link(name, false, &err);
>>  
>>      qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, net_vhost_user_event,
>> -- 
>> 2.21.0

Thanks.