[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 06/31] net/slirp: free forwarding rules on cleanup
From: |
Samuel Thibault |
Subject: |
[Qemu-devel] [PULL 06/31] net/slirp: free forwarding rules on cleanup |
Date: |
Sun, 27 Jan 2019 13:05:01 +0100 |
From: Marc-André Lureau <address@hidden>
Signed-off-by: Marc-André Lureau <address@hidden>
Signed-off-by: Samuel Thibault <address@hidden>
---
net/slirp.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/net/slirp.c b/net/slirp.c
index b91741b8fc..750105a466 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -75,6 +75,13 @@ struct slirp_config_str {
char str[1024];
};
+struct GuestFwd {
+ CharBackend hd;
+ struct in_addr server;
+ int port;
+ Slirp *slirp;
+};
+
typedef struct SlirpState {
NetClientState nc;
QTAILQ_ENTRY(SlirpState) entry;
@@ -83,6 +90,7 @@ typedef struct SlirpState {
#ifndef _WIN32
gchar *smb_dir;
#endif
+ GSList *fwd;
} SlirpState;
static struct slirp_config_str *slirp_configs;
@@ -122,10 +130,19 @@ static void slirp_smb_exit(Notifier *n, void *data)
slirp_smb_cleanup(s);
}
+static void slirp_free_fwd(gpointer data)
+{
+ struct GuestFwd *fwd = data;
+
+ qemu_chr_fe_deinit(&fwd->hd, true);
+ g_free(data);
+}
+
static void net_slirp_cleanup(NetClientState *nc)
{
SlirpState *s = DO_UPCAST(SlirpState, nc, nc);
+ g_slist_free_full(s->fwd, slirp_free_fwd);
slirp_cleanup(s->slirp);
if (s->exit_notifier.notify) {
qemu_remove_exit_notifier(&s->exit_notifier);
@@ -717,13 +734,6 @@ static int slirp_smb(SlirpState* s, const char
*exported_dir,
#endif /* !defined(_WIN32) */
-struct GuestFwd {
- CharBackend hd;
- struct in_addr server;
- int port;
- Slirp *slirp;
-};
-
static int guestfwd_can_read(void *opaque)
{
struct GuestFwd *fwd = opaque;
@@ -814,6 +824,7 @@ static int slirp_guestfwd(SlirpState *s, const char
*config_str, Error **errp)
qemu_chr_fe_set_handlers(&fwd->hd, guestfwd_can_read, guestfwd_read,
NULL, NULL, fwd, NULL, true);
+ s->fwd = g_slist_append(s->fwd, fwd);
}
return 0;
--
2.20.1
- [Qemu-devel] [PULL 00/31] More work towards libslirp, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 05/31] net/slirp: simplify checking for cmd: prefix, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 01/31] slirp: Avoid unaligned 16bit memory access, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 06/31] net/slirp: free forwarding rules on cleanup,
Samuel Thibault <=
- [Qemu-devel] [PULL 02/31] slirp: Avoid marking naturally packed structs as QEMU_PACKED, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 07/31] net/slirp: fix leaks on forwarding rule registration error, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 04/31] slirp: generalize guestfwd with a callback based approach, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 19/31] slirp: remove qemu timer.h dependency, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 08/31] slirp: add callbacks for timer, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 14/31] slirp: replace qemu_notify_event() with a callback, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 23/31] slirp: replace QEMU_BUILD_BUG_ON with G_STATIC_ASSERT, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 09/31] slirp: replace trace functions with DEBUG calls, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 03/31] slirp: Don't mark struct ipq or struct ipasfrag as packed, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 16/31] slirp: do not include qemu headers in libslirp.h public API header, Samuel Thibault, 2019/01/27