From: linzhecheng <linzhecheng@huawei.com>
To: qemu-devel@nongnu.org
Cc: jasowang@redhat.com, wangxinxin.wang@huawei.com,
jianjay.zhou@huawei.com, linzhecheng <linzhecheng@huawei.com>
Subject: [Qemu-devel] [PATCH] tap: delete tap(net client) if net_init_tap_one failed
Date: Tue, 6 Mar 2018 13:11:25 +0800 [thread overview]
Message-ID: <20180306051125.32812-1-linzhecheng@huawei.com> (raw)
If net_init_tap_one failed but net_tap_fd_init succeeded, we should
delete the TAPState *s without vhostforce and has_vhostforce flag.
Signed-off-by: linzhecheng <linzhecheng@huawei.com>
diff --git a/net/tap.c b/net/tap.c
index 2b3a36f9b5..1cb8eaf31f 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -651,7 +651,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) {
@@ -688,6 +688,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
if (vhostfd == -1) {
if (tap->has_vhostforce && tap->vhostforce) {
error_propagate(errp, err);
+ goto fail;
} else {
warn_report_err(err);
}
@@ -699,6 +700,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
if (tap->has_vhostforce && tap->vhostforce) {
error_setg_errno(errp, errno,
"tap: open vhost char device failed");
+ goto fail;
} else {
warn_report("tap: open vhost char device failed: %s",
strerror(errno));
@@ -713,6 +715,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
if (!s->vhost_net) {
if (tap->has_vhostforce && tap->vhostforce) {
error_setg(errp, VHOST_NET_INIT_FAILED);
+ goto fail;
} else {
warn_report(VHOST_NET_INIT_FAILED);
}
@@ -720,7 +723,11 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
}
} 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.12.2.windows.2
next reply other threads:[~2018-03-06 5:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-06 5:11 linzhecheng [this message]
2018-03-06 8:15 ` [Qemu-devel] [PATCH] tap: delete tap(net client) if net_init_tap_one failed Jason Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180306051125.32812-1-linzhecheng@huawei.com \
--to=linzhecheng@huawei.com \
--cc=jasowang@redhat.com \
--cc=jianjay.zhou@huawei.com \
--cc=qemu-devel@nongnu.org \
--cc=wangxinxin.wang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).