From patchwork Tue Feb 2 13:10:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 8190211 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CFA109FBE9 for ; Tue, 2 Feb 2016 13:13:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3ED1C202D1 for ; Tue, 2 Feb 2016 13:13:00 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 2971D201F5 for ; Tue, 2 Feb 2016 13:12:59 +0000 (UTC) Received: from localhost ([::1]:57065 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQalO-0007S8-HP for patchwork-qemu-devel@patchwork.kernel.org; Tue, 02 Feb 2016 08:12:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQakE-0007CY-15 for qemu-devel@nongnu.org; Tue, 02 Feb 2016 08:12:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQajI-0008KN-RM for qemu-devel@nongnu.org; Tue, 02 Feb 2016 08:11:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40756) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQajI-0008Jx-J6 for qemu-devel@nongnu.org; Tue, 02 Feb 2016 08:10:48 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 4F5308E37C for ; Tue, 2 Feb 2016 13:10:48 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u12DAlpI021343; Tue, 2 Feb 2016 08:10:47 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id E926381A6B; Tue, 2 Feb 2016 14:10:45 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 2 Feb 2016 14:10:43 +0100 Message-Id: <1454418644-15153-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1454418644-15153-1-git-send-email-kraxel@redhat.com> References: <1454418644-15153-1-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PULL 1/2] gtk: use qemu_chr_alloc() to allocate CharDriverState X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Daniel P. Berrange" 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=mon0 -mon chardev=mon0 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é Poussineau Signed-off-by: Daniel P. Berrange Reviewed-by: Eric Blake Tested-by: Hervé Poussineau Message-id: 1453377386-10190-1-git-send-email-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- 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 *chr, bool echo) static int nb_vcs; static CharDriverState *vcs[MAX_VCS]; -static CharDriverState *gd_vc_handler(ChardevVC *unused, Error **errp) +static CharDriverState *gd_vc_handler(ChardevVC *vc, Error **errp) { + ChardevCommon *common = qapi_ChardevVC_base(vc); CharDriverState *chr; - chr = g_malloc0(sizeof(*chr)); + chr = qemu_chr_alloc(common, errp); + if (!chr) { + return NULL; + } + chr->chr_write = gd_vc_chr_write; chr->chr_set_echo = gd_vc_chr_set_echo;