From patchwork Thu Nov 17 03:16:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 695978 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 3tK5zD0g4Zz9t1H for ; Thu, 17 Nov 2016 14:22:32 +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="I2+QglfS"; dkim-atps=neutral Received: from localhost ([::1]:56409 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7DHR-00010R-Ba for incoming@patchwork.ozlabs.org; Wed, 16 Nov 2016 22:22:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7DCa-0005KL-Uh for qemu-devel@nongnu.org; Wed, 16 Nov 2016 22:17:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c7DCa-0004vC-2X for qemu-devel@nongnu.org; Wed, 16 Nov 2016 22:17:28 -0500 Received: from mail-it0-x242.google.com ([2607:f8b0:4001:c0b::242]:36208) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c7DCZ-0004uq-SO for qemu-devel@nongnu.org; Wed, 16 Nov 2016 22:17:28 -0500 Received: by mail-it0-x242.google.com with SMTP id n68so11932453itn.3 for ; Wed, 16 Nov 2016 19:17:27 -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=j5SQH3M3Np1wyZ9eHNyHRuF6ZgeCvCt/gO3ojCkBxl4=; b=I2+QglfSwThIrUEv148eBd4PV6+xof0Yneu5Fr8z0LkJRptznejfApx10zpL0uAW8f HJGcWIjDiHwvkenki294bns7LIpucxC3Qm1b24EPan575DY4TaywW87FP19pVdsg9zUv cs/ruwbWWlUQ8MFwmao+p97iBkoNLDMmk+F5O+5lr/N6sH3NilZ9CXvr2QMj8hxZ4Vk+ S+MHP38NGgbdKK4Wsgar3+sYWDN5T2W7LNkH0wK55e91VEcKoWo5vF3Bn8omdkriz9sL TKgrtmFhKH3bQvBxS2u6NvxjiZoaKjv6+ZAwKUETpksa9h4eDNNYkBzx/XVog0rXHxZ4 k/Jg== 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=j5SQH3M3Np1wyZ9eHNyHRuF6ZgeCvCt/gO3ojCkBxl4=; b=mNZpp7Ow7G+CTCS3Z8+chxNYsDufMnOr9Do69Pedv/2WoQOXrA+0+Bgr6J9mQl3M3b PKEaiASpLx2dypdcGFf0DKjnTqCJHDl2qIhfYqrCp7HCKr50uVqB4pY2iFjvnbXKt+tM 67/vQcMieyC1zFDxSQPyJDXZMcxO2err8T/f2lqQtfb2xzIFQhY2ZP451usEKFLn50Hh BQ0Af1NyWoTKU2qutfO7kNUWwsKCllFM5YsZZi9WiK/RNHses3rgj2kMgl9iritnZHwT BCNSVDMJtBknCEFoVAZUqqD4i8RRfWYZcYmFEcr6eYCjKGGWCbwJCLWBhdFeJ0Khk4ZD AMeA== X-Gm-Message-State: ABUngvfshxqO17Vq2VxjWDQUobRudbknMvfPwUt0q8tvb9uzqsIa/Nx6khK8ANiCdskv3Q== X-Received: by 10.36.150.134 with SMTP id z128mr1158009itd.62.1479352646918; Wed, 16 Nov 2016 19:17:26 -0800 (PST) Received: from localhost.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id l3sm4424577iti.3.2016.11.16.19.17.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Nov 2016 19:17:26 -0800 (PST) From: Li Qiang To: groug@kaod.org, qemu-devel@nongnu.org Date: Wed, 16 Nov 2016 22:16:55 -0500 Message-Id: <1479352616-64991-4-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::242 Subject: [Qemu-devel] [PATCH v3 3/4] 9pfs: add cleanup operation for handle 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 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 --- hw/9pfs/9p-handle.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/9pfs/9p-handle.c b/hw/9pfs/9p-handle.c index 3d77594..1687661 100644 --- a/hw/9pfs/9p-handle.c +++ b/hw/9pfs/9p-handle.c @@ -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,