From patchwork Tue Nov 15 02:13:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 694790 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 3tHrfY0M6xz9t15 for ; Tue, 15 Nov 2016 13:18:45 +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="X/imK9wX"; dkim-atps=neutral Received: from localhost ([::1]:43651 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6TKc-0008RE-3X for incoming@patchwork.ozlabs.org; Mon, 14 Nov 2016 21:18:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58875) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6TGQ-0004xr-Vu for qemu-devel@nongnu.org; Mon, 14 Nov 2016 21:14:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c6TGN-0006lr-11 for qemu-devel@nongnu.org; Mon, 14 Nov 2016 21:14:22 -0500 Received: from mail-it0-x242.google.com ([2607:f8b0:4001:c0b::242]:33847) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c6TGM-0006l7-SW for qemu-devel@nongnu.org; Mon, 14 Nov 2016 21:14:18 -0500 Received: by mail-it0-x242.google.com with SMTP id q124so18735831itd.1 for ; Mon, 14 Nov 2016 18:14:18 -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=8ezKdQ6JMaaa42681hWOJwPh1nl/jHWCJkSijUh8gfA=; b=X/imK9wXVHPyk72+EvIg9pdz6REle9F085ho1y4z3hB+LBIZxBV39D9H7jpGXk+BHc 5YjvCAu3dbNMBpVc/mCPudgG9pVseM3SNN8cWApjpfblCRcN9ca5UxZNm2s7PJcaNN6S cBb7vqz3jrHnOkWY3N3spB38SfbwqLDRYD9ZF6NJZoCXVOCgeOGUdNxwSCKzgfQ8Nv/y vAeDrvUVClsGzUDn7pf7t511YrWvs1v+2XdBjcRLGQtM9GzFdiYCGpL1kXAL4M4ZD2ni xNXEXyX5E/LdrIX/WpzX62HNdDSIiiWe+Fjf1Si/POOGKB8TrTbb3xOteeD8ruEn5QcU urZw== 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=8ezKdQ6JMaaa42681hWOJwPh1nl/jHWCJkSijUh8gfA=; b=dUz3PiOFoQnXxH636VDWSsNlTb5mRdbaYQkFdX7QPGpF0m3Y3flB/QYRb2oNCQI7jR m7GEw3JhXS+vFDnTF+tggZb9XZrbnJfFdOkJB9EFbP6mlSXUvooD54/9Aovyxg9hnYI8 pfOwJVlO1DqXVSo8Fxv1m/0sqOBfjQLh64Gza7ziiSmjqIC3tTzAMbzoDKudngp6X6RJ SD2nUCjyix2JM91yn2AZP/aDhwOrZnA7dAed08JZh0u+/zooIA2MHfP7tU+DpOzwjOw9 ttZ9x/aIK8FVc5YgbP6xPRrrXvoZC/sB4I6fBXi9PCh0ao8Ywa6/a0cO1pFlNnGhM3Bk KlXQ== X-Gm-Message-State: ABUngvdW0qjKrFELduZWNvV0I6pvLhlVIXZ6Tot0rtKrhumNn0umXjtoY+xAUF4euFsDmg== X-Received: by 10.107.26.80 with SMTP id a77mr27452457ioa.109.1479176058316; Mon, 14 Nov 2016 18:14:18 -0800 (PST) Received: from localhost.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id x99sm10496707ioi.17.2016.11.14.18.14.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Nov 2016 18:14:17 -0800 (PST) From: Li Qiang To: groug@kaod.org, qemu-devel@nongnu.org Date: Mon, 14 Nov 2016 21:13:53 -0500 Message-Id: <1479176033-36604-4-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1479176033-36604-1-git-send-email-liq3ea@gmail.com> References: <1479176033-36604-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 v2 3/3] 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 --- 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,