From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MlTCw-00050S-Br for qemu-devel@nongnu.org; Wed, 09 Sep 2009 15:51:58 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MlTCr-0004xJ-9B for qemu-devel@nongnu.org; Wed, 09 Sep 2009 15:51:57 -0400 Received: from [199.232.76.173] (port=56871 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlTCr-0004xE-1j for qemu-devel@nongnu.org; Wed, 09 Sep 2009 15:51:53 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:58896) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MlTCq-0001GP-9L for qemu-devel@nongnu.org; Wed, 09 Sep 2009 15:51:52 -0400 Message-ID: <4AA8075E.2090102@web.de> Date: Wed, 09 Sep 2009 21:51:58 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <1252339585-27797-1-git-send-email-kraxel@redhat.com> <1252339585-27797-23-git-send-email-kraxel@redhat.com> In-Reply-To: <1252339585-27797-23-git-send-email-kraxel@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig5794F4834C10E3CA720D1287" Sender: jan.kiszka@web.de Subject: [Qemu-devel] Re: [PATCH 22/23] monitor: fix muxing List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig5794F4834C10E3CA720D1287 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Gerd Hoffmann wrote: > make the mux driver send mux_in and mux_out events when switching > focus while hooking up more handlers. >=20 > stop using CharDriverState->focus in monitor.c, track state using > the mux events instead. This also removes the implicit assumtion > that a muxed monitor allways has mux channel 0. Nice patch in the right direction, but it comes with a regression: When you enable the monitor on mux'ed stdio via CTRL-A C, you don't get a prompt until pressing some key. >=20 > Signed-off-by: Gerd Hoffmann > --- > monitor.c | 33 ++++++++++++++++++++++----------- > qemu-char.c | 3 +++ > 2 files changed, 25 insertions(+), 11 deletions(-) >=20 > diff --git a/monitor.c b/monitor.c > index f5f4d0e..edf48f3 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -85,6 +85,8 @@ struct mon_fd_t { > =20 > struct Monitor { > CharDriverState *chr; > + int mux_out; > + int reset_seen; > int flags; > int suspend_cnt; > uint8_t outbuf[1024]; > @@ -129,7 +131,7 @@ static int monitor_read_password(Monitor *mon, Read= LineFunc *readline_func, > =20 > void monitor_flush(Monitor *mon) > { > - if (mon && mon->outbuf_index !=3D 0 && mon->chr->focus =3D=3D 0) {= > + if (mon && mon->outbuf_index !=3D 0 && !mon->mux_out) { > qemu_chr_write(mon->chr, mon->outbuf, mon->outbuf_index); > mon->outbuf_index =3D 0; > } > @@ -3111,23 +3113,34 @@ static void monitor_event(void *opaque, int eve= nt) > =20 > switch (event) { > case CHR_EVENT_MUX_IN: > - readline_restart(mon->rs); > - monitor_resume(mon); > - monitor_flush(mon); > + if (mon->reset_seen) { > + readline_restart(mon->rs); > + monitor_resume(mon); > + monitor_flush(mon); > + } else { > + mon->suspend_cnt =3D 0; > + } > + mon->mux_out =3D 0; > break; > =20 > case CHR_EVENT_MUX_OUT: > - if (mon->suspend_cnt =3D=3D 0) > - monitor_printf(mon, "\n"); > - monitor_flush(mon); > - monitor_suspend(mon); > + if (mon->reset_seen) { > + if (mon->suspend_cnt =3D=3D 0) > + monitor_printf(mon, "\n"); > + monitor_flush(mon); > + monitor_suspend(mon); > + } else { > + mon->suspend_cnt++; > + } > + mon->mux_out =3D 1; > break; > =20 > case CHR_EVENT_RESET: > monitor_printf(mon, "QEMU %s monitor - type 'help' for more " > "information\n", QEMU_VERSION); > - if (mon->chr->focus =3D=3D 0) > + if (!mon->mux_out) > readline_show_prompt(mon->rs); Please add braces at this chance. > + mon->reset_seen =3D 1; > break; > } > } > @@ -3155,8 +3168,6 @@ void monitor_init(CharDriverState *chr, int flags= ) > =20 > mon->chr =3D chr; > mon->flags =3D flags; > - if (mon->chr->focus !=3D 0) > - mon->suspend_cnt =3D 1; /* mux'ed monitors start suspended */ > if (flags & MONITOR_USE_READLINE) { > mon->rs =3D readline_init(mon, monitor_find_completion); > monitor_read_command(mon, 0); > diff --git a/qemu-char.c b/qemu-char.c > index 2e71038..daa8587 100644 > --- a/qemu-char.c > +++ b/qemu-char.c > @@ -456,8 +456,11 @@ static void mux_chr_update_read_handler(CharDriver= State *chr) > qemu_chr_add_handlers(d->drv, mux_chr_can_read, mux_chr_read, > mux_chr_event, chr); > } > + if (-1 !=3D chr->focus) > + mux_chr_send_event(d, chr->focus, CHR_EVENT_MUX_OUT); { } > chr->focus =3D d->mux_cnt; > d->mux_cnt++; > + mux_chr_send_event(d, chr->focus, CHR_EVENT_MUX_IN); > } > =20 > static CharDriverState *qemu_chr_open_mux(CharDriverState *drv) Jan --------------enig5794F4834C10E3CA720D1287 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkqoB2IACgkQniDOoMHTA+mQiACeKobkOyudFXKy1eWazaApKGOX QBgAn0QGp9ST2JMH5ctVBEEbX1UvDbTf =HV15 -----END PGP SIGNATURE----- --------------enig5794F4834C10E3CA720D1287--