virtio: net-tap: bugfix: del net client if net_init_tap_one failed
In net_init_tap_one(), if the net-tap initializes successful but other actions failed during vhost-net hot-plugging, the net-tap will remain in the net clients.causing next hot-plug fails again. Signed-off-by: Jinhua Cao <caojinhua1@huawei.com>
This commit is contained in:
parent
a55dd0838d
commit
c7155d3353
76
virtio-net-tap-bugfix-del-net-client-if-net_init_tap.patch
Normal file
76
virtio-net-tap-bugfix-del-net-client-if-net_init_tap.patch
Normal file
@ -0,0 +1,76 @@
|
||||
From cee545754b44b6283408ec6a43eb0e317c98ebb1 Mon Sep 17 00:00:00 2001
|
||||
From: Jinhua Cao <caojinhua1@huawei.com>
|
||||
Date: Wed, 9 Feb 2022 20:27:41 +0800
|
||||
Subject: [PATCH] virtio: net-tap: bugfix: del net client if net_init_tap_one
|
||||
failed
|
||||
|
||||
In net_init_tap_one(), if the net-tap initializes successful
|
||||
but other actions failed during vhost-net hot-plugging, the
|
||||
net-tap will remain in the net clients.causing next hot-plug
|
||||
fails again.
|
||||
|
||||
Signed-off-by: Jinhua Cao <caojinhua1@huawei.com>
|
||||
---
|
||||
net/tap.c | 16 +++++++++++-----
|
||||
1 file changed, 11 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/net/tap.c b/net/tap.c
|
||||
index c5cbeaa7a2..3f79cd06c2 100644
|
||||
--- a/net/tap.c
|
||||
+++ b/net/tap.c
|
||||
@@ -684,7 +684,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
|
||||
tap_set_sndbuf(s->fd, tap, &err);
|
||||
if (err) {
|
||||
error_propagate(errp, err);
|
||||
- return;
|
||||
+ goto fail;
|
||||
}
|
||||
|
||||
if (tap->has_fd || tap->has_fds) {
|
||||
@@ -726,13 +726,13 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
|
||||
} else {
|
||||
warn_report_err(err);
|
||||
}
|
||||
- return;
|
||||
+ goto fail;
|
||||
}
|
||||
ret = qemu_try_set_nonblock(vhostfd);
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d",
|
||||
name, fd);
|
||||
- return;
|
||||
+ goto fail;
|
||||
}
|
||||
} else {
|
||||
vhostfd = open("/dev/vhost-net", O_RDWR);
|
||||
@@ -744,7 +744,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
|
||||
warn_report("tap: open vhost char device failed: %s",
|
||||
strerror(errno));
|
||||
}
|
||||
- return;
|
||||
+ goto fail;
|
||||
}
|
||||
qemu_set_nonblock(vhostfd);
|
||||
}
|
||||
@@ -758,11 +758,17 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
|
||||
} else {
|
||||
warn_report(VHOST_NET_INIT_FAILED);
|
||||
}
|
||||
- return;
|
||||
+ goto fail;
|
||||
}
|
||||
} else if (vhostfdname) {
|
||||
error_setg(errp, "vhostfd(s)= is not valid without vhost");
|
||||
+ goto fail;
|
||||
}
|
||||
+
|
||||
+ return;
|
||||
+
|
||||
+fail:
|
||||
+ qemu_del_net_client(&s->nc);
|
||||
}
|
||||
|
||||
static int get_fds(char *str, char *fds[], int max)
|
||||
--
|
||||
2.27.0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user