From patchwork Mon Nov 14 12:32:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9427421 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 930BD60476 for ; Mon, 14 Nov 2016 12:35:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A00F286BB for ; Mon, 14 Nov 2016 12:35:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DD882878F; Mon, 14 Nov 2016 12:35:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 19F03286BB for ; Mon, 14 Nov 2016 12:35:04 +0000 (UTC) Received: from localhost ([::1]:39521 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6GTY-0007GT-4C for patchwork-qemu-devel@patchwork.kernel.org; Mon, 14 Nov 2016 07:35:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45392) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6GSu-0007FC-8M for qemu-devel@nongnu.org; Mon, 14 Nov 2016 07:34:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c6GSr-0003fn-5Z for qemu-devel@nongnu.org; Mon, 14 Nov 2016 07:34:24 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:33498) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c6GSr-0003eb-0R for qemu-devel@nongnu.org; Mon, 14 Nov 2016 07:34:21 -0500 Received: by mail-pf0-f196.google.com with SMTP id 144so6173107pfv.0 for ; Mon, 14 Nov 2016 04:34:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:from:to:cc:subject:date:in-reply-to:references; bh=tDXi2Fm2p8TTSrdd/mptvYdGpRpSr3uHZbF9Uo1DhpI=; b=pROcCZzUcSLy0uz6HvVUhrAuFZf9WnA2AkpdyKMhqlLDHf5kaC/tQzQuX+1nOOeyu/ hBaKIvsE+CdaOjCsAgdMPjpD7jz479IEpiRwDNdYzGWMrjlaya3rwa0qYlm3rRmIUzBz flpJ0VwmsEPKmR3bn7leyMce6U0aWT+USwkGBBGXrfWrWeH8MIxFgHvAHVO/EU1c30vr 4UlYnDHos/Sf4jv0WUAHEMTjX5EIdQRcXLx3n8dncXZK6XtOYf4wamKsNO2MXU0GfnPJ kH2kXLpZrLo7dI37MhJLDPstJ7A2p7+CvJnDkIOikmoS9yNaUNFsvQfO32ZgoXxpA8ao u5Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:from:to:cc:subject:date:in-reply-to :references; bh=tDXi2Fm2p8TTSrdd/mptvYdGpRpSr3uHZbF9Uo1DhpI=; b=dYoWOsJ5DxwT6BWbZT2CKss4OiUacJkgW+5rWFLJMHTysLQa4SmTurrJjDAEZt+SeI HnP5qiBHPrvVOOWxkpbqvz0veeaJiUGIiSBh4n10lB4edluOGI/MfhhzzDRkcVqJ+mAk 7rx1DzDHG7SRVQi9k7TLcsz48xOxQiIFhqzacUkW0grB/JSCkTspH4d4Zq9DnF0d8WM+ +O4biKWB4p1eCB6eiLI6IUGc6CrDxwMJisR+Oua3PDZontMsKWcLNDUgOpXUlqCFEG1R fbPPIswjqffyUTkkXJuuoCZYqOG2zAfhqJ7iasO4jr25wrM/9HslKTePXEip0UZhDdFv Q7rA== X-Gm-Message-State: ABUngvc1YCDXqq9h9aWcXx4OOSTR2ef0IVwPNKmKKnUvBEQfUbCjVhLAEXdRgcCqmGKSsQ== X-Received: by 10.98.11.71 with SMTP id t68mr35593092pfi.136.1479126800159; Mon, 14 Nov 2016 04:33:20 -0800 (PST) Received: from localhost.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id xg4sm35177845pac.39.2016.11.14.04.33.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Nov 2016 04:33:19 -0800 (PST) Message-ID: <5829af0f.84f4420a.a436f.4a73@mx.google.com> X-Google-Original-Message-ID: <1479126778-125867-3-git-send-email-Qiang(liqiang6-s@360.cn)> From: Li Qiang X-Google-Original-From: Li Qiang(liqiang6-s@360.cn) To: groug@kaod.org, qemu-devel@nongnu.org Date: Mon, 14 Nov 2016 07:32:57 -0500 X-Mailer: git-send-email 1.8.3.1 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)> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.192.196 Subject: [Qemu-devel] [PATCH 2/3] 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Li Qiang 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,