1 From ae9b5c9dae96dd8d3bdf9bb6b9a0f7a2d6f532f7 Mon Sep 17 00:00:00 2001
2 From: Li Qiang <liq3ea@gmail.com>
3 Date: Wed, 23 Nov 2016 13:53:34 +0100
4 Subject: [PATCH 09/12] 9pfs: add cleanup operation for proxy backend driver
6 In the init operation of proxy backend dirver, it allocates a
7 V9fsProxy struct and some other resources. We should free these
8 resources when the 9pfs device is unrealized. This is what this
11 Signed-off-by: Li Qiang <liq3ea@gmail.com>
12 Reviewed-by: Greg Kurz <groug@kaod.org>
13 Signed-off-by: Greg Kurz <groug@kaod.org>
15 hw/9pfs/9p-proxy.c | 13 +++++++++++++
16 1 file changed, 13 insertions(+)
18 diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c
19 index f265501..336e9fe 100644
20 --- a/hw/9pfs/9p-proxy.c
21 +++ b/hw/9pfs/9p-proxy.c
22 @@ -1179,9 +1179,22 @@ static int proxy_init(FsContext *ctx)
26 +static void proxy_cleanup(FsContext *ctx)
28 + V9fsProxy *proxy = ctx->private;
30 + g_free(proxy->out_iovec.iov_base);
31 + g_free(proxy->in_iovec.iov_base);
32 + if (ctx->export_flags & V9FS_PROXY_SOCK_NAME) {
33 + close(proxy->sockfd);
38 FileOperations proxy_ops = {
39 .parse_opts = proxy_parse_opts,
41 + .cleanup = proxy_cleanup,
43 .readlink = proxy_readlink,