From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53393) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V93ot-0007lK-LW for qemu-devel@nongnu.org; Mon, 12 Aug 2013 21:54:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V93oo-0003YS-M0 for qemu-devel@nongnu.org; Mon, 12 Aug 2013 21:54:47 -0400 Received: from mail-ob0-x22e.google.com ([2607:f8b0:4003:c01::22e]:50998) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V93oo-0003YL-Gy for qemu-devel@nongnu.org; Mon, 12 Aug 2013 21:54:42 -0400 Received: by mail-ob0-f174.google.com with SMTP id wd6so7294417obb.19 for ; Mon, 12 Aug 2013 18:54:41 -0700 (PDT) Sender: fluxion Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Roth In-Reply-To: <1375960178-10882-1-git-send-email-james.hogan@imgtec.com> References: <1375960178-10882-1-git-send-email-james.hogan@imgtec.com> Message-ID: <20130813015438.15605.35907@loki> Date: Mon, 12 Aug 2013 20:54:38 -0500 Subject: Re: [Qemu-devel] [PATCH] qemu-char: fix infinite recursion connecting to monitor pty List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: James Hogan , qemu-devel Cc: Anthony Liguori Quoting James Hogan (2013-08-08 06:09:38) > Since commit bd5c51e (qemu-char: don't issue CHR_EVENT_OPEN in a BH), an > infinite recursion occurs when putting the monitor on a pty (-monitor > pty) and connecting a terminal to the slave port. > = > This is because of the qemu_chr_be_event(s, CHR_EVENT_OPENED) added to > qemu_chr_be_generic_open(). This event is captured by monitor_event() > which prints a welcome message to the character device. The flush of > that welcome message retriggers another open event in pty_chr_state() > because it checks s->connected, but only sets it to 1 after calling > qemu_chr_be_generic_open(). > = > I've fixed this by setting s->connected =3D 1 before the call to > qemu_chr_be_generic_open() instead of after, so that the recursive > pty_chr_state() doesn't call it again. > = > An example snippet of repeating backtrace: > ... > #107486 0x007aec58 in monitor_flush (mon=3D0xf418b0) at qemu/monitor.c:2= 88 > #107487 0x007aee7c in monitor_puts (mon=3D0xf418b0, str=3D0x1176d07 "") = at qemu/monitor.c:322 > #107488 0x007aef20 in monitor_vprintf (mon=3D0xf418b0, fmt=3D0x8d4820 "Q= EMU %s monitor - type 'help' for more information\n", > ap=3D0x7f432be0) at qemu/monitor.c:339 > #107489 0x007aefac in monitor_printf (mon=3D0xf418b0, fmt=3D0x8d4820 "QE= MU %s monitor - type 'help' for more information\n") > at qemu/monitor.c:347 > #107490 0x007ba4bc in monitor_event (opaque=3D0xf418b0, event=3D2) at qe= mu/monitor.c:4699 > #107491 0x00684c28 in qemu_chr_be_event (s=3D0xf37788, event=3D2) at qem= u/qemu-char.c:108 > #107492 0x00684c70 in qemu_chr_be_generic_open (s=3D0xf37788) at qemu/qe= mu-char.c:113 > #107493 0x006880a4 in pty_chr_state (chr=3D0xf37788, connected=3D1) at q= emu/qemu-char.c:1145 > #107494 0x00687fa4 in pty_chr_update_read_handler (chr=3D0xf37788) at qe= mu/qemu-char.c:1121 > #107495 0x00687c9c in pty_chr_write (chr=3D0xf37788, buf=3D0x70b3c008 , len=3D538720) > at qemu/qemu-char.c:1063 > #107496 0x00684cc4 in qemu_chr_fe_write (s=3D0xf37788, buf=3D0x70b3c008 =
, len=3D538720) > at qemu/qemu-char.c:118 > ... > = > Signed-off-by: James Hogan > Cc: Michael Roth > Cc: Anthony Liguori > --- > Note the commit I mentioned Cc's gnu-stable@nongnu.org. Assuming this > patch is acceptable it probably makes sense for it to follow the other > patch into stable too. Ping. Looking to pull this in for stable. > = > qemu-char.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > = > diff --git a/qemu-char.c b/qemu-char.c > index 16f3ad7..1be1cf6 100644 > --- a/qemu-char.c > +++ b/qemu-char.c > @@ -1142,8 +1142,8 @@ static void pty_chr_state(CharDriverState *chr, int= connected) > s->timer_tag =3D 0; > } > if (!s->connected) { > - qemu_chr_be_generic_open(chr); > s->connected =3D 1; > + qemu_chr_be_generic_open(chr); > s->fd_tag =3D io_add_watch_poll(s->fd, pty_chr_read_poll, pt= y_chr_read, chr); > } > } > -- = > 1.8.1.2