From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46402) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoDBP-0000E7-R4 for qemu-devel@nongnu.org; Thu, 07 Apr 2016 12:53:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoDBM-0002YZ-Fk for qemu-devel@nongnu.org; Thu, 07 Apr 2016 12:53:27 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:33867) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoDBM-0002YN-7u for qemu-devel@nongnu.org; Thu, 07 Apr 2016 12:53:24 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 7 Apr 2016 10:53:23 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 442403E40055 for ; Thu, 7 Apr 2016 10:53:21 -0600 (MDT) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u37GrLsA45088816 for ; Thu, 7 Apr 2016 09:53:21 -0700 Received: from d03av03.boulder.ibm.com (localhost [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u37GrKv7021019 for ; Thu, 7 Apr 2016 10:53:20 -0600 From: Michael Roth Date: Thu, 7 Apr 2016 11:53:08 -0500 Message-Id: <1460047989-31816-2-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1460047989-31816-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1460047989-31816-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PULL for-2.6 1/2] qga: fix fd leak with guest-exec i/o channels List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Yuriy Pudgorodskiy , Michael Roth , "Denis V. Lunev" From: Yuriy Pudgorodskiy Signed-off-by: Yuriy Pudgorodskiy Signed-off-by: Denis V. Lunev CC: Michael Roth * squashed in g_io_channel_shutdown() to match cleanup paths for input/output Signed-off-by: Michael Roth --- qga/commands.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qga/commands.c b/qga/commands.c index 95d8b04..b653a46 100644 --- a/qga/commands.c +++ b/qga/commands.c @@ -373,6 +373,7 @@ static gboolean guest_exec_output_watch(GIOChannel *ch, return true; close: + g_io_channel_shutdown(ch, true, NULL); g_io_channel_unref(ch); g_atomic_int_set(&p->closed, 1); return false; @@ -447,6 +448,7 @@ GuestExec *qmp_guest_exec(const char *path, g_io_channel_set_encoding(in_ch, NULL, NULL); g_io_channel_set_buffered(in_ch, false); g_io_channel_set_flags(in_ch, G_IO_FLAG_NONBLOCK, NULL); + g_io_channel_set_close_on_unref(in_ch, true); g_io_add_watch(in_ch, G_IO_OUT, guest_exec_input_watch, &gei->in); } @@ -462,6 +464,8 @@ GuestExec *qmp_guest_exec(const char *path, g_io_channel_set_encoding(err_ch, NULL, NULL); g_io_channel_set_buffered(out_ch, false); g_io_channel_set_buffered(err_ch, false); + g_io_channel_set_close_on_unref(out_ch, true); + g_io_channel_set_close_on_unref(err_ch, true); g_io_add_watch(out_ch, G_IO_IN | G_IO_HUP, guest_exec_output_watch, &gei->out); g_io_add_watch(err_ch, G_IO_IN | G_IO_HUP, -- 1.9.1