]> Git Repo - qemu.git/commitdiff
9pfs: add cleanup operation for proxy backend driver
authorLi Qiang <[email protected]>
Wed, 23 Nov 2016 12:53:34 +0000 (13:53 +0100)
committerGreg Kurz <[email protected]>
Wed, 23 Nov 2016 12:53:34 +0000 (13:53 +0100)
In the init operation of proxy backend dirver, it allocates a
V9fsProxy struct and some other resources. We should free these
resources when the 9pfs device is unrealized. This is what this
patch does.

Signed-off-by: Li Qiang <[email protected]>
Reviewed-by: Greg Kurz <[email protected]>
Signed-off-by: Greg Kurz <[email protected]>
hw/9pfs/9p-proxy.c

index f2417b7fd73d3958bfd3a470b951f5adf4a057ee..f4aa7a9d70f8f4b35f0f1fdbe26c86c88ec4e7a4 100644 (file)
@@ -1168,9 +1168,22 @@ static int proxy_init(FsContext *ctx)
     return 0;
 }
 
+static void proxy_cleanup(FsContext *ctx)
+{
+    V9fsProxy *proxy = ctx->private;
+
+    g_free(proxy->out_iovec.iov_base);
+    g_free(proxy->in_iovec.iov_base);
+    if (ctx->export_flags & V9FS_PROXY_SOCK_NAME) {
+        close(proxy->sockfd);
+    }
+    g_free(proxy);
+}
+
 FileOperations proxy_ops = {
     .parse_opts   = proxy_parse_opts,
     .init         = proxy_init,
+    .cleanup      = proxy_cleanup,
     .lstat        = proxy_lstat,
     .readlink     = proxy_readlink,
     .close        = proxy_close,
This page took 0.025852 seconds and 4 git commands to generate.