From: Greg Kurz <groug@kaod.org>
To: qemu-devel@nongnu.org
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
Greg Kurz <groug@kaod.org>, Li Qiang <liq3ea@gmail.com>
Subject: [Qemu-devel] [for-2.8 4/4] 9pfs: add cleanup operation for proxy backend driver
Date: Wed, 23 Nov 2016 17:58:18 +0100 [thread overview]
Message-ID: <1479920298-24983-5-git-send-email-groug@kaod.org> (raw)
In-Reply-To: <1479920298-24983-1-git-send-email-groug@kaod.org>
From: Li Qiang <liq3ea@gmail.com>
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 <liq3ea@gmail.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Greg Kurz <groug@kaod.org>
---
hw/9pfs/9p-proxy.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c
index f2417b7fd73d..f4aa7a9d70f8 100644
--- a/hw/9pfs/9p-proxy.c
+++ b/hw/9pfs/9p-proxy.c
@@ -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,
--
2.7.4
next prev parent reply other threads:[~2016-11-23 17:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-23 16:58 [Qemu-devel] [for-2.8 0/4] 9p patches for 2.8 20161123 Greg Kurz
2016-11-23 16:58 ` [Qemu-devel] [for-2.8 1/4] 9pfs: adjust the order of resource cleanup in device unrealize Greg Kurz
2016-11-23 16:58 ` [Qemu-devel] [for-2.8 2/4] 9pfs: add cleanup operation in FileOperations Greg Kurz
2016-11-23 16:58 ` [Qemu-devel] [for-2.8 3/4] 9pfs: add cleanup operation for handle backend driver Greg Kurz
2016-11-23 16:58 ` Greg Kurz [this message]
2016-11-24 10:19 ` [Qemu-devel] [for-2.8 0/4] 9p patches for 2.8 20161123 Stefan Hajnoczi
2016-11-24 10:36 ` Greg Kurz
2016-11-24 15:24 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1479920298-24983-5-git-send-email-groug@kaod.org \
--to=groug@kaod.org \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=liq3ea@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).