[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 8/8] virtio: del net client if net_init_tap_one failed
From: |
Jason Wang |
Subject: |
[PULL 8/8] virtio: del net client if net_init_tap_one failed |
Date: |
Tue, 27 Sep 2022 15:30:22 +0800 |
From: lu zhipeng <luzhipeng@cestc.cn>
If the net tap initializes successful, but failed during
network card hot-plugging, the net-tap will remains,
so cleanup.
Signed-off-by: lu zhipeng <luzhipeng@cestc.cn>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
net/tap.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/net/tap.c b/net/tap.c
index b3ddfd4..e203d07 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -686,7 +686,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 failed;
}
if (tap->has_fd || tap->has_fds) {
@@ -726,12 +726,12 @@ static void net_init_tap_one(const NetdevTapOptions *tap,
NetClientState *peer,
} else {
warn_report_err(err);
}
- return;
+ goto failed;
}
if (!g_unix_set_fd_nonblocking(vhostfd, true, NULL)) {
error_setg_errno(errp, errno, "%s: Can't use file descriptor
%d",
name, fd);
- return;
+ goto failed;
}
} else {
vhostfd = open("/dev/vhost-net", O_RDWR);
@@ -743,11 +743,11 @@ static void net_init_tap_one(const NetdevTapOptions *tap,
NetClientState *peer,
warn_report("tap: open vhost char device failed: %s",
strerror(errno));
}
- return;
+ goto failed;
}
if (!g_unix_set_fd_nonblocking(vhostfd, true, NULL)) {
error_setg_errno(errp, errno, "Failed to set FD nonblocking");
- return;
+ goto failed;
}
}
options.opaque = (void *)(uintptr_t)vhostfd;
@@ -760,11 +760,17 @@ static void net_init_tap_one(const NetdevTapOptions *tap,
NetClientState *peer,
} else {
warn_report(VHOST_NET_INIT_FAILED);
}
- return;
+ goto failed;
}
} else if (vhostfdname) {
error_setg(errp, "vhostfd(s)= is not valid without vhost");
+ goto failed;
}
+
+ return;
+
+failed:
+ qemu_del_net_client(&s->nc);
}
static int get_fds(char *str, char *fds[], int max)
--
2.7.4
- [PULL 0/8] Net patches, Jason Wang, 2022/09/27
- [PULL 1/8] e1000e: set RX desc status with DD flag in a separate operation, Jason Wang, 2022/09/27
- [PULL 4/8] vdpa: Add vhost_vdpa_net_load_mq, Jason Wang, 2022/09/27
- [PULL 2/8] vdpa: Make VhostVDPAState cvq_cmd_in_buffer control ack type, Jason Wang, 2022/09/27
- [PULL 3/8] vdpa: extract vhost_vdpa_net_load_mac from vhost_vdpa_net_load, Jason Wang, 2022/09/27
- [PULL 5/8] vdpa: validate MQ CVQ commands, Jason Wang, 2022/09/27
- [PULL 6/8] virtio-net: Update virtio-net curr_queue_pairs in vdpa backends, Jason Wang, 2022/09/27
- [PULL 7/8] vdpa: Allow MQ feature in SVQ, Jason Wang, 2022/09/27
- [PULL 8/8] virtio: del net client if net_init_tap_one failed,
Jason Wang <=
- Re: [PULL 0/8] Net patches, Stefan Hajnoczi, 2022/09/27