From patchwork Thu Nov 17 03:16:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 695977 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tK5vJ2nTRz9sD5 for ; Thu, 17 Nov 2016 14:19:08 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cr6w4Fuc"; dkim-atps=neutral Received: from localhost ([::1]:56376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7DE9-0006Yk-Af for incoming@patchwork.ozlabs.org; Wed, 16 Nov 2016 22:19:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7DCi-0005RT-Ng for qemu-devel@nongnu.org; Wed, 16 Nov 2016 22:17:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c7DCf-0004y2-K4 for qemu-devel@nongnu.org; Wed, 16 Nov 2016 22:17:36 -0500 Received: from mail-it0-x243.google.com ([2607:f8b0:4001:c0b::243]:34299) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c7DCf-0004xc-Ct for qemu-devel@nongnu.org; Wed, 16 Nov 2016 22:17:33 -0500 Received: by mail-it0-x243.google.com with SMTP id o1so11990833ito.1 for ; Wed, 16 Nov 2016 19:17:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=U0cATO9PqwWiA07LtBhEybIyyBdj7sK6O+O4b3TS1vk=; b=cr6w4FucAU6NZ8aoymj3r/+oA0svh+hoefJ8FZuCavvsADJmqxhirkQ6sVhEWFTqgw SXvenCsNSrSabxpC9Vptt2H3KBWw/Hg07dlQZ7r8Tu9KzMxhMA6YE4xz/88d0DBO0VGZ 9a49pqnWFDkqfvzGLKtrPi+K7iSVx1hLNtUVL2OimSg5HmGoZm5mFkv7Z6MWZSA5TAS0 mOU0ZXfYUZdvlt7koMPLGKoMSemNupMAldoXP2Wix7ImiT5O6mG05RKyDa9B0+3NUTIO TvWPc1pIjE2voyhy+ZDzK9OPv6zm7PuegtXCDHzCxwW/JtffGbmvIgUQTX/S/DJcju6S rC0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U0cATO9PqwWiA07LtBhEybIyyBdj7sK6O+O4b3TS1vk=; b=ZGnNCFHgGlPAWTpSTRPHIIgWWAPn65/zHnZFznR/+WDeYAMqOJsFQ0qmcoWWG+9Ywf 7tQSXYaPiZyxYpg1y7apxF4RIkz8K/m+lB9zNA6bfuEUSAUwPy4ZyxmeLnEW++fgfVuw 3+tgL4QPZFo+bncgGB1tLVVlK0vjupFgHhOHgcgn+wbNKpq2gfCT7hblAblBPcdlybvR qDtaK5VjIRdHHtOfDU9/7biTOZr/Esar6Xittib+KGO3EEWERoHW6Q0TzvgjQ2bJAp5g LptTCZJ3Y04nW7fXM4vjhhuDQbGvZ0J1D81SbWG2X6QXtPGi7PHZnftPP3UvUXHkZOEU vnjg== X-Gm-Message-State: AKaTC03m7ACGeT3p9mFbCLDjabfrozYtMkXh9skcut+IPaLx9eOiLYxJKgJYTDmyjWjAqg== X-Received: by 10.107.201.129 with SMTP id z123mr1146135iof.112.1479352652368; Wed, 16 Nov 2016 19:17:32 -0800 (PST) Received: from localhost.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id l3sm4424577iti.3.2016.11.16.19.17.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Nov 2016 19:17:31 -0800 (PST) From: Li Qiang To: groug@kaod.org, qemu-devel@nongnu.org Date: Wed, 16 Nov 2016 22:16:56 -0500 Message-Id: <1479352616-64991-5-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1479352616-64991-1-git-send-email-liq3ea@gmail.com> References: <1479352616-64991-1-git-send-email-liq3ea@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4001:c0b::243 Subject: [Qemu-devel] [PATCH v3 4/4] 9pfs: add cleanup operation for proxy backend driver X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang , liqiang6-s@360.cn Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- Changes since the v2: -only close proxy->sockfd if QEMU opened the fd -do the cleanup work in reverse order hw/9pfs/9p-proxy.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c index f2417b7..f4aa7a9 100644 --- a/hw/9pfs/9p-proxy.c +++ b/hw/9pfs/9p-proxy.c @@ -1168,9 +1168,22 @@ static int proxy_init(FsContext *ctx) return 0; } +static void proxy_cleanup(FsContext *ctx) +{ + V9fsProxy *proxy = ctx->private; + + g_free(proxy->out_iovec.iov_base); + g_free(proxy->in_iovec.iov_base); + if (ctx->export_flags & V9FS_PROXY_SOCK_NAME) { + close(proxy->sockfd); + } + 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,