From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6asW-0001Or-BR for qemu-devel@nongnu.org; Tue, 15 Nov 2016 05:22:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c6asT-0007Ny-6d for qemu-devel@nongnu.org; Tue, 15 Nov 2016 05:22:12 -0500 Received: from 2.mo53.mail-out.ovh.net ([178.33.254.39]:47892) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c6asT-0007Nn-13 for qemu-devel@nongnu.org; Tue, 15 Nov 2016 05:22:09 -0500 Received: from player158.ha.ovh.net (b7.ovh.net [213.186.33.57]) by mo53.mail-out.ovh.net (Postfix) with ESMTP id C204043690 for ; Tue, 15 Nov 2016 11:22:07 +0100 (CET) Date: Tue, 15 Nov 2016 11:22:03 +0100 From: Greg Kurz Message-ID: <20161115112203.5b0a7d5b@bahia> In-Reply-To: <1479176033-36604-3-git-send-email-liq3ea@gmail.com> References: <1479176033-36604-1-git-send-email-liq3ea@gmail.com> <1479176033-36604-3-git-send-email-liq3ea@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 2/3] 9pfs: add cleanup operation for handle backend driver List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Li Qiang Cc: qemu-devel@nongnu.org, liqiang6-s@360.cn On Mon, 14 Nov 2016 21:13:52 -0500 Li Qiang wrote: > 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 > --- Reviewed-by: Greg Kurz > hw/9pfs/9p-handle.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/hw/9pfs/9p-handle.c b/hw/9pfs/9p-handle.c > index 3d77594..9b50f40 100644 > --- a/hw/9pfs/9p-handle.c > +++ b/hw/9pfs/9p-handle.c > @@ -649,6 +649,13 @@ 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 +678,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,