Commit 919e11f3 authored by Daniel P. Berrangé's avatar Daniel P. Berrangé Committed by Gerd Hoffmann
Browse files

gtk: use qemu_chr_alloc() to allocate CharDriverState



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 d0d7708b
  Author: Daniel P. Berrange <berrange@redhat.com>
  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: default avatarHervé Poussineau <hpoussin@reactos.org>
Signed-off-by: default avatarDaniel P. Berrange <berrange@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Tested-by: default avatarHervé Poussineau <hpoussin@reactos.org>
Message-id: 1453377386-10190-1-git-send-email-berrange@redhat.com
Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent 10ae9d76
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -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;