Skip to contentSkip to conversation

vhost-user: save features if the char dev is closed

PATCH Superseded Adrian Moreno 2 participants 3 messages Sep 17, 2019 – Sep 18, 2019 Networking

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost-user: save features if the char dev is closed

That way the state can be correctly restored when the device is opened again. This might happen if the backend is restarted.

Fixes 6ab79a20af3a (do not call vhost_net_cleanup() on running net from char user event)
Cc Michael S. Tsirkin <[email protected]>
---
 net/vhost-user.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/vhost-user.c +7 -0
index 51921de443..acf20cb9e0 100644
@@ -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,
Signature · 1 line
2.21.0
#1 lore raw
Quoted 19 lines · Adrian Moreno

That way the state can be correctly restored when the device is opened again. This might happen if the backend is restarted.

Fixes 6ab79a20af3a (do not call vhost_net_cleanup() on running net from char user event)
Cc Michael S. Tsirkin <[email protected]>
---
 net/vhost-user.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/vhost-user.c +0 -0
index 51921de443..acf20cb9e0 100644

net/vhost-user.c static void chr_closed_bh(void *opaque) · line 242

Quoted 8 lines
net/vhost-user.c +5 -0
@@ -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?

Quoted 7 lines
net/vhost-user.c +2 -0
+    }
+
     qmp_set_link(name, false, &err);
 
     qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, net_vhost_user_event,
Signature · 1 line
2.21.0
#2 lore raw
Quoted 23 lines · Michael S. Tsirkin
Quoted 22 lines · Adrian Moreno

That way the state can be correctly restored when the device is opened again. This might happen if the backend is restarted.

Fixes 6ab79a20af3a (do not call vhost_net_cleanup() on running net from char user event)
Cc Michael S. Tsirkin <[email protected]>
---
 net/vhost-user.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/vhost-user.c +0 -0
index 51921de443..acf20cb9e0 100644
@@ -235,6 +235,13 @@ static void chr_closed_bh(void *opaque)
 
     s = DO_UPCAST(NetVhostUserState, nc, ncs[0]);
 
Quoted 8 lines

net/vhost-user.c static void chr_closed_bh(void *opaque) · line 242

Quoted 5 lines
net/vhost-user.c +5 -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.

Quoted 8 lines
Quoted 8 lines
net/vhost-user.c +2 -0
+    }
+
     qmp_set_link(name, false, &err);
 
     qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, net_vhost_user_event,
Signature · 1 line
2.21.0

Thanks.