From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:53845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QyTJn-00046N-77 for qemu-devel@nongnu.org; Tue, 30 Aug 2011 14:45:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QyTJj-0007rA-07 for qemu-devel@nongnu.org; Tue, 30 Aug 2011 14:45:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6182) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QyTJi-0007r6-JI for qemu-devel@nongnu.org; Tue, 30 Aug 2011 14:45:46 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7UIji28030225 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 30 Aug 2011 14:45:45 -0400 Date: Tue, 30 Aug 2011 15:45:42 -0300 From: Luiz Capitulino Message-ID: <20110830154542.337a3f96@doriath> In-Reply-To: <1312964409-10698-1-git-send-email-alevy@redhat.com> References: <1312964409-10698-1-git-send-email-alevy@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC] monitor: fix segfault from uninitialized lexer->emit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alon Levy Cc: Amit Shah , Paolo Bonzini , qemu-devel@nongnu.org On Wed, 10 Aug 2011 11:20:09 +0300 Alon Levy wrote: > The following triggers a call to monitor_control_read before > monitor_control_event has been called. This patch is misplaced but > fixes the problem by moving the json_message_parser_init call before > setting the chardev handlers. > > (echo '{"execute": "qmp_capabilities"}'; echo '{"execute":"query-spice"}'; echo '{ "execute": "quit" }') | qemu-system-x86_64 -spice port=9999 -qmp stdio What's happening is that the CHR_EVENT_OPENED event is not being emitted. I took a look at the code and it's not clear to me why. Does anyone know if this is expected or is it a bug in the chardev layer? > > Signed-off-by: Alon Levy > --- > monitor.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/monitor.c b/monitor.c > index 1b8ba2c..6e3d970 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -5190,8 +5190,6 @@ static void monitor_control_event(void *opaque, int event) > > switch (event) { > case CHR_EVENT_OPENED: > - mon->mc->command_mode = 0 > - json_message_parser_init(&mon->mc->parser, handle_qmp_command); > data = get_qmp_greeting(); > monitor_json_emitter(mon, data); > qobject_decref(data); > @@ -5272,6 +5270,8 @@ void monitor_init(CharDriverState *chr, int flags) > > if (monitor_ctrl_mode(mon)) { > mon->mc = qemu_mallocz(sizeof(MonitorControl)); > + mon->mc->command_mode = 0; > + json_message_parser_init(&mon->mc->parser, handle_qmp_command); > /* Control mode requires special handlers */ > qemu_chr_add_handlers(chr, monitor_can_read, monitor_control_read, > monitor_control_event, mon);