The notifier is used only to call the downscript. Avoid extra
notifier for other cases.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
net/tap.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/net/tap.c b/net/tap.c
index 151fb73820..4f3512a831 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -336,8 +336,10 @@ static void tap_cleanup(NetClientState *nc)
qemu_purge_queued_packets(nc);
- tap_exit_notify(&s->exit, NULL);
- qemu_remove_exit_notifier(&s->exit);
+ if (s->exit.notify) {
+ tap_exit_notify(&s->exit, NULL);
+ qemu_remove_exit_notifier(&s->exit);
+ }
tap_read_poll(s, false);
tap_write_poll(s, false);
@@ -727,9 +729,7 @@ static int net_tap_fd_init_common(const Netdev *netdev, NetClientState *peer,
}
tap_read_poll(s, true);
s->vhost_net = NULL;
-
- s->exit.notify = tap_exit_notify;
- qemu_add_exit_notifier(&s->exit);
+ s->exit.notify = NULL;
if (netdev->type == NET_CLIENT_DRIVER_BRIDGE) {
const NetdevBridgeOptions *bridge = &netdev->u.bridge;
@@ -757,6 +757,8 @@ static int net_tap_fd_init_common(const Netdev *netdev, NetClientState *peer,
snprintf(s->down_script, sizeof(s->down_script), "%s", downscript);
snprintf(s->down_script_arg, sizeof(s->down_script_arg),
"%s", ifname);
+ s->exit.notify = tap_exit_notify;
+ qemu_add_exit_notifier(&s->exit);
}
}
--
2.48.1