1 Star 0 Fork 126

ZhangBo/qemu_src

forked from src-openEuler/qemu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
virtio-net-tap-bugfix-del-net-client-if-net_init_tap.patch 2.37 KB
一键复制 编辑 原始数据 按行查看 历史
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...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ooorz/qemu_src.git
git@gitee.com:ooorz/qemu_src.git
ooorz
qemu_src
qemu_src
master

搜索帮助