From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6GT1-0007IY-27 for qemu-devel@nongnu.org; Mon, 14 Nov 2016 07:34:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c6GSx-0003jB-Uu for qemu-devel@nongnu.org; Mon, 14 Nov 2016 07:34:31 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:35188) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c6GSx-0003iS-PN for qemu-devel@nongnu.org; Mon, 14 Nov 2016 07:34:27 -0500 Received: by mail-pf0-f193.google.com with SMTP id i88so6151224pfk.2 for ; Mon, 14 Nov 2016 04:34:27 -0800 (PST) Message-ID: <5829af16.84f4420a.a436f.4a79@mx.google.com> From: Li Qiang Date: Mon, 14 Nov 2016 07:32:58 -0500 In-Reply-To: <1479126778-125867-1-git-send-email-Qiang(liqiang6-s@360.cn)> References: <1479126778-125867-1-git-send-email-Qiang(liqiang6-s@360.cn)> Subject: [Qemu-devel] [PATCH 3/3] 9pfs: add cleanup operation for proxy backend driver List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: groug@kaod.org, qemu-devel@nongnu.org Cc: liqiang6-s@360.cn, Li Qiang From: Li Qiang 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 --- hw/9pfs/9p-proxy.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c index f2417b7..4b22f57 100644 --- a/hw/9pfs/9p-proxy.c +++ b/hw/9pfs/9p-proxy.c @@ -1168,9 +1168,19 @@ static int proxy_init(FsContext *ctx) return 0; } +static void proxy_cleanup(FsContext *ctx) +{ + V9fsProxy *proxy = ctx->private; + close(proxy->sockfd); + g_free(proxy->in_iovec.iov_base); + g_free(proxy->out_iovec.iov_base); + 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, -- 1.8.3.1