From: Roman Penyaev <r.peniaev@gmail.com>
Cc: "Roman Penyaev" <r.peniaev@gmail.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
qemu-devel@nongnu.org
Subject: [PATCH v9 1/4] chardev/char-pty: send CHR_EVENT_CLOSED on disconnect
Date: Thu, 23 Jan 2025 09:53:21 +0100 [thread overview]
Message-ID: <20250123085327.965501-2-r.peniaev@gmail.com> (raw)
In-Reply-To: <20250123085327.965501-1-r.peniaev@gmail.com>
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.peniaev@gmail.com>
Reviewed-by: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Reviewed-by: "Alex Bennée" <alex.bennee@linaro.org>
Cc: qemu-devel@nongnu.org
---
chardev/char-pty.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/chardev/char-pty.c b/chardev/char-pty.c
index cbb21b76ae8d..6a2c1dc13a3f 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 +218,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);
}
#if defined HAVE_PTY_H
--
2.43.0
next prev parent reply other threads:[~2025-01-23 8:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-23 8:53 [PATCH v9 0/4] chardev: implement backend chardev multiplexing Roman Penyaev
2025-01-23 8:53 ` Roman Penyaev [this message]
2025-01-23 8:53 ` [PATCH v9 2/4] chardev/char-hub: implement backend chardev aggregator Roman Penyaev
2025-02-18 7:54 ` Markus Armbruster
2025-02-18 7:57 ` Markus Armbruster
2025-02-19 9:07 ` Roman Penyaev
2025-01-23 8:53 ` [PATCH v9 3/4] tests/unit/test-char: add unit tests for hub chardev backend Roman Penyaev
2025-01-23 8:53 ` [PATCH v9 4/4] qemu-options.hx: describe hub chardev and aggregation of several backends Roman Penyaev
2025-02-03 9:06 ` [PATCH v9 0/4] chardev: implement backend chardev multiplexing Roman Penyaev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250123085327.965501-2-r.peniaev@gmail.com \
--to=r.peniaev@gmail.com \
--cc=alex.bennee@linaro.org \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).