From: Yuriy Pudgorodskiy Date: Wed, 6 Apr 2016 05:43:30 +0000 (+0300) Subject: qga: fix fd leak with guest-exec i/o channels X-Git-Tag: v2.6.0-rc2~16^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3005c2c2fa2875a3413af97e9db368856d3330fd;p=thirdparty%2Fqemu.git qga: fix fd leak with guest-exec i/o channels 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 --- diff --git a/qga/commands.c b/qga/commands.c index 95d8b04a163..b653a460b98 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,