* [Qemu-devel] [PATCH] gtk: use qemu_chr_alloc() to allocate CharDriverState
@ 2016-01-21 11:56 Daniel P. Berrange
2016-01-21 16:42 ` Eric Blake
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Daniel P. Berrange @ 2016-01-21 11:56 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, Hervé Poussineau, 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=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 <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: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
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;
--
2.5.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] gtk: use qemu_chr_alloc() to allocate CharDriverState
2016-01-21 11:56 [Qemu-devel] [PATCH] gtk: use qemu_chr_alloc() to allocate CharDriverState Daniel P. Berrange
@ 2016-01-21 16:42 ` Eric Blake
2016-01-21 17:55 ` Peter Maydell
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Eric Blake @ 2016-01-21 16:42 UTC (permalink / raw)
To: Daniel P. Berrange, qemu-devel
Cc: Paolo Bonzini, Hervé Poussineau, Gerd Hoffmann
[-- Attachment #1: Type: text/plain, Size: 1184 bytes --]
On 01/21/2016 04:56 AM, Daniel P. Berrange wrote:
> 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 <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: Hervé Poussineau <hpoussin@reactos.org>
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
> ui/gtk.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] gtk: use qemu_chr_alloc() to allocate CharDriverState
2016-01-21 11:56 [Qemu-devel] [PATCH] gtk: use qemu_chr_alloc() to allocate CharDriverState Daniel P. Berrange
2016-01-21 16:42 ` Eric Blake
@ 2016-01-21 17:55 ` Peter Maydell
2016-01-21 18:38 ` Hervé Poussineau
2016-01-26 11:39 ` Gerd Hoffmann
3 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2016-01-21 17:55 UTC (permalink / raw)
To: Daniel P. Berrange
Cc: Paolo Bonzini, Hervé Poussineau, QEMU Developers,
Gerd Hoffmann
On 21 January 2016 at 11:56, Daniel P. Berrange <berrange@redhat.com> wrote:
> 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
A quick check with coccinelle:
@@
typedef CharDriverState;
CharDriverState *x;
@@
- x = g_malloc0(...)
+ x = qemu_chr_alloc(foo)
revealed only this ui/gtk.c allocation plus the actual
implementation of qemu_chr_alloc() as places where we try
to do a manual g_malloc0() of a CharDriverState. So I
think this is the only bit that needs changing.
thanks
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] gtk: use qemu_chr_alloc() to allocate CharDriverState
2016-01-21 11:56 [Qemu-devel] [PATCH] gtk: use qemu_chr_alloc() to allocate CharDriverState Daniel P. Berrange
2016-01-21 16:42 ` Eric Blake
2016-01-21 17:55 ` Peter Maydell
@ 2016-01-21 18:38 ` Hervé Poussineau
2016-01-26 11:39 ` Gerd Hoffmann
3 siblings, 0 replies; 5+ messages in thread
From: Hervé Poussineau @ 2016-01-21 18:38 UTC (permalink / raw)
To: Daniel P. Berrange, qemu-devel; +Cc: Paolo Bonzini, Gerd Hoffmann
Le 21/01/2016 12:56, Daniel P. Berrange a écrit :
> 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 <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: Hervé Poussineau <hpoussin@reactos.org>
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Tested-by: Hervé Poussineau <hpoussin@reactos.org>
Hervé
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] gtk: use qemu_chr_alloc() to allocate CharDriverState
2016-01-21 11:56 [Qemu-devel] [PATCH] gtk: use qemu_chr_alloc() to allocate CharDriverState Daniel P. Berrange
` (2 preceding siblings ...)
2016-01-21 18:38 ` Hervé Poussineau
@ 2016-01-26 11:39 ` Gerd Hoffmann
3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2016-01-26 11:39 UTC (permalink / raw)
To: Daniel P. Berrange; +Cc: Paolo Bonzini, Hervé Poussineau, qemu-devel
On Do, 2016-01-21 at 11:56 +0000, Daniel P. Berrange wrote:
> 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.
added to patch queue.
thanks,
Gerd
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-01-26 11:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-21 11:56 [Qemu-devel] [PATCH] gtk: use qemu_chr_alloc() to allocate CharDriverState Daniel P. Berrange
2016-01-21 16:42 ` Eric Blake
2016-01-21 17:55 ` Peter Maydell
2016-01-21 18:38 ` Hervé Poussineau
2016-01-26 11:39 ` Gerd Hoffmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).