Roman Penyaev <r.peni...@gmail.com> writes: > Change makes code symmetric to the code, which handles > the "connected" state, i.e. send CHR_EVENT_CLOSED when > state changes from "connected" to "disconnected". > > This behavior is similar to char-socket, for example. > > Signed-off-by: Roman Penyaev <r.peni...@gmail.com> > Cc: "Marc-André Lureau" <marcandre.lur...@redhat.com> > Cc: qemu-devel@nongnu.org > --- > chardev/char-pty.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/chardev/char-pty.c b/chardev/char-pty.c > index cbb21b76ae8d..10a6ee94d55c 100644 > --- a/chardev/char-pty.c > +++ b/chardev/char-pty.c > @@ -181,6 +181,9 @@ static void pty_chr_state(Chardev *chr, int connected) > > if (!connected) { > remove_fd_in_watch(chr); > + if (s->connected) { > + qemu_chr_be_event(chr, CHR_EVENT_CLOSED); > + } > s->connected = 0; > /* (re-)connect poll interval for idle guests: once per second. > * We check more frequently in case the guests sends data to > @@ -215,7 +217,6 @@ static void char_pty_finalize(Object *obj) > pty_chr_state(chr, 0); > object_unref(OBJECT(s->ioc)); > pty_chr_timer_cancel(s); > - qemu_chr_be_event(chr, CHR_EVENT_CLOSED); > }
It would be nice to clean up connected/s->connected to bools at some point. However this is fine: Reviewed-by: Alex Bennée <alex.ben...@linaro.org> -- Alex Bennée Virtualisation Tech Lead @ Linaro