mvadkert / rpms / qemu

Forked from rpms/qemu 6 years ago
Clone
4d7edd7
From: Li Qiang <liq3ea@gmail.com>
4d7edd7
Date: Wed, 23 Nov 2016 13:53:34 +0100
4d7edd7
Subject: [PATCH] 9pfs: add cleanup operation for proxy backend driver
4d7edd7
4d7edd7
In the init operation of proxy backend dirver, it allocates a
4d7edd7
V9fsProxy struct and some other resources. We should free these
4d7edd7
resources when the 9pfs device is unrealized. This is what this
4d7edd7
patch does.
4d7edd7
4d7edd7
Signed-off-by: Li Qiang <liq3ea@gmail.com>
4d7edd7
Reviewed-by: Greg Kurz <groug@kaod.org>
4d7edd7
Signed-off-by: Greg Kurz <groug@kaod.org>
4d7edd7
(cherry picked from commit 898ae90a44551d25b8e956fd87372d303c82fe68)
4d7edd7
---
4d7edd7
 hw/9pfs/9p-proxy.c | 13 +++++++++++++
4d7edd7
 1 file changed, 13 insertions(+)
4d7edd7
4d7edd7
diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c
4d7edd7
index 00a4eb2..7c6aaf3 100644
4d7edd7
--- a/hw/9pfs/9p-proxy.c
4d7edd7
+++ b/hw/9pfs/9p-proxy.c
4d7edd7
@@ -1181,9 +1181,22 @@ static int proxy_init(FsContext *ctx)
4d7edd7
     return 0;
4d7edd7
 }
4d7edd7
 
4d7edd7
+static void proxy_cleanup(FsContext *ctx)
4d7edd7
+{
4d7edd7
+    V9fsProxy *proxy = ctx->private;
4d7edd7
+
4d7edd7
+    g_free(proxy->out_iovec.iov_base);
4d7edd7
+    g_free(proxy->in_iovec.iov_base);
4d7edd7
+    if (ctx->export_flags & V9FS_PROXY_SOCK_NAME) {
4d7edd7
+        close(proxy->sockfd);
4d7edd7
+    }
4d7edd7
+    g_free(proxy);
4d7edd7
+}
4d7edd7
+
4d7edd7
 FileOperations proxy_ops = {
4d7edd7
     .parse_opts   = proxy_parse_opts,
4d7edd7
     .init         = proxy_init,
4d7edd7
+    .cleanup      = proxy_cleanup,
4d7edd7
     .lstat        = proxy_lstat,
4d7edd7
     .readlink     = proxy_readlink,
4d7edd7
     .close        = proxy_close,