From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMDr1-0004e2-T8 for qemu-devel@nongnu.org; Thu, 21 Jan 2016 06:56:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aMDqw-0008JC-NM for qemu-devel@nongnu.org; Thu, 21 Jan 2016 06:56:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39981) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMDqw-0008J5-Hi for qemu-devel@nongnu.org; Thu, 21 Jan 2016 06:56:38 -0500 From: "Daniel P. Berrange" Date: Thu, 21 Jan 2016 11:56:26 +0000 Message-Id: <1453377386-10190-1-git-send-email-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH] gtk: use qemu_chr_alloc() to allocate CharDriverState List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Gerd Hoffmann The gd_vc_handler() callback is using g_malloc0() to allocate the CharDriverState struct. As a result the logfd field is getting initialized to 0, instead of -1 when no logfile is requested. The result is that when running $ qemu-system-i386 -nodefaults -chardev vc,id=3Dmon0 -mon chardev=3Dmon0 qemu duplicates all monitor output to stdout as well as the GTK window. Not using qemu_chr_alloc() was already a bug, but harmless until this commit commit d0d7708ba29cbcc343364a46bff981e0ff88366f Author: Daniel P. Berrange Date: Mon Jan 11 12:44:41 2016 +0000 qemu-char: add logfile facility to all chardev backends which exposed the problem as a behaviour regression Reported-by: Herv=C3=A9 Poussineau Signed-off-by: Daniel P. Berrange --- ui/gtk.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index ce7018e..c8dbd5c 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1598,11 +1598,16 @@ static void gd_vc_chr_set_echo(CharDriverState *c= hr, bool echo) static int nb_vcs; static CharDriverState *vcs[MAX_VCS]; =20 -static CharDriverState *gd_vc_handler(ChardevVC *unused, Error **errp) +static CharDriverState *gd_vc_handler(ChardevVC *vc, Error **errp) { + ChardevCommon *common =3D qapi_ChardevVC_base(vc); CharDriverState *chr; =20 - chr =3D g_malloc0(sizeof(*chr)); + chr =3D qemu_chr_alloc(common, errp); + if (!chr) { + return NULL; + } + chr->chr_write =3D gd_vc_chr_write; chr->chr_set_echo =3D gd_vc_chr_set_echo; =20 --=20 2.5.0