vhost-user: save features if the char dev is closed
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.
--- net/vhost-user.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/vhost-user.c +7 -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; + } + } +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
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.
Reported-by Pei Zhang <[email protected]>Fixes 6ab79a20af3a (do not call vhost_net_cleanup() on running net from char user event)Cc Michael S. Tsirkin <[email protected]>Signed-off-by Adrian Moreno <[email protected]>--- net/vhost-user.c | 7 +++++++ 1 file changed, 7 insertions(+)net/vhost-user.c +0
-0
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
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.
Reported-by Pei Zhang <[email protected]>Fixes 6ab79a20af3a (do not call vhost_net_cleanup() on running net from char user event)Cc Michael S. Tsirkin <[email protected]>Signed-off-by Adrian Moreno <[email protected]>--- net/vhost-user.c | 7 +++++++ 1 file changed, 7 insertions(+)net/vhost-user.c +0
-0@@ -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)?
0x0is 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.