]>
Commit | Line | Data |
---|---|---|
f262231e WB |
1 | From 4196726e44c437793294af15d95e53164cf9a02d 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 08/12] 9pfs: add cleanup operation for handle backend driver | |
5 | ||
6 | In the init operation of handle backend dirver, it allocates a | |
7 | handle_data struct and opens a mount file. We should free these | |
8 | resources when the 9pfs device is unrealized. This is what this | |
9 | patch does. | |
10 | ||
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> | |
14 | --- | |
15 | hw/9pfs/9p-handle.c | 9 +++++++++ | |
16 | 1 file changed, 9 insertions(+) | |
17 | ||
18 | diff --git a/hw/9pfs/9p-handle.c b/hw/9pfs/9p-handle.c | |
19 | index 3d77594..1687661 100644 | |
20 | --- a/hw/9pfs/9p-handle.c | |
21 | +++ b/hw/9pfs/9p-handle.c | |
22 | @@ -649,6 +649,14 @@ out: | |
23 | return ret; | |
24 | } | |
25 | ||
26 | +static void handle_cleanup(FsContext *ctx) | |
27 | +{ | |
28 | + struct handle_data *data = ctx->private; | |
29 | + | |
30 | + close(data->mountfd); | |
31 | + g_free(data); | |
32 | +} | |
33 | + | |
34 | static int handle_parse_opts(QemuOpts *opts, struct FsDriverEntry *fse) | |
35 | { | |
36 | const char *sec_model = qemu_opt_get(opts, "security_model"); | |
37 | @@ -671,6 +679,7 @@ static int handle_parse_opts(QemuOpts *opts, struct FsDriverEntry *fse) | |
38 | FileOperations handle_ops = { | |
39 | .parse_opts = handle_parse_opts, | |
40 | .init = handle_init, | |
41 | + .cleanup = handle_cleanup, | |
42 | .lstat = handle_lstat, | |
43 | .readlink = handle_readlink, | |
44 | .close = handle_close, | |
45 | -- | |
46 | 2.1.4 | |
47 |