qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Li Qiang <liq3ea@gmail.com>
To: groug@kaod.org, qemu-devel@nongnu.org
Cc: liqiang6-s@360.cn, Li Qiang <liq3ea@gmail.com>
Subject: [Qemu-devel] [PATCH v3 3/4] 9pfs: add cleanup operation for handle backend driver
Date: Wed, 16 Nov 2016 22:16:55 -0500	[thread overview]
Message-ID: <1479352616-64991-4-git-send-email-liq3ea@gmail.com> (raw)
In-Reply-To: <1479352616-64991-1-git-send-email-liq3ea@gmail.com>

In the init operation of handle backend dirver, it allocates a
handle_data struct and opens a mount file. 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>
---
 hw/9pfs/9p-handle.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/hw/9pfs/9p-handle.c b/hw/9pfs/9p-handle.c
index 3d77594..1687661 100644
--- a/hw/9pfs/9p-handle.c
+++ b/hw/9pfs/9p-handle.c
@@ -649,6 +649,14 @@ out:
     return ret;
 }
 
+static void handle_cleanup(FsContext *ctx)
+{
+    struct handle_data *data = ctx->private;
+
+    close(data->mountfd);
+    g_free(data);
+}
+
 static int handle_parse_opts(QemuOpts *opts, struct FsDriverEntry *fse)
 {
     const char *sec_model = qemu_opt_get(opts, "security_model");
@@ -671,6 +679,7 @@ static int handle_parse_opts(QemuOpts *opts, struct FsDriverEntry *fse)
 FileOperations handle_ops = {
     .parse_opts   = handle_parse_opts,
     .init         = handle_init,
+    .cleanup      = handle_cleanup,
     .lstat        = handle_lstat,
     .readlink     = handle_readlink,
     .close        = handle_close,
-- 
1.8.3.1

  parent reply	other threads:[~2016-11-17  3:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-17  3:16 [Qemu-devel] [PATCH v3 0/4] 9pfs: add cleanup operation in handle/proxy backend Li Qiang
2016-11-17  3:16 ` [Qemu-devel] [PATCH v3 1/4] 9pfs: adjust the order of resource cleanup in device unrealize Li Qiang
2016-11-17  3:16 ` [Qemu-devel] [PATCH v3 2/4] 9pfs: add cleanup operation in FileOperations Li Qiang
2016-11-17  3:16 ` Li Qiang [this message]
2016-11-17  3:16 ` [Qemu-devel] [PATCH v3 4/4] 9pfs: add cleanup operation for proxy backend driver Li Qiang
2016-11-21 16:05 ` [Qemu-devel] [PATCH v3 0/4] 9pfs: add cleanup operation in handle/proxy backend Greg Kurz

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=1479352616-64991-4-git-send-email-liq3ea@gmail.com \
    --to=liq3ea@gmail.com \
    --cc=groug@kaod.org \
    --cc=liqiang6-s@360.cn \
    --cc=qemu-devel@nongnu.org \
    /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).