提交 971f406b 编写于 作者: L Li Qiang 提交者: Greg Kurz

9pfs: add cleanup operation for handle backend driver

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: NLi Qiang <liq3ea@gmail.com>
Reviewed-by: NGreg Kurz <groug@kaod.org>
Signed-off-by: NGreg Kurz <groug@kaod.org>
上级 702dbcc2
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册