char: drop data written to a disconnected pty
PATCH 1/1 char: drop data written to a disconnected pty
When a serial port writes data to a pty that's disconnected, drop the data and return the length dropped. This avoids triggering pointless retries in callers like the 16550A serial_xmit(), and causes qemu_chr_fe_write() to write all data to the log file, rather than logging only while a pty client like virsh console happens to be connected.
--- qemu-char.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
qemu-char.c +1 -1
@@ -1528,7 +1528,7 @@ static int pty_chr_write(CharDriverState *chr, const uint8_t *buf, int len)/* guest sends data, check for (re-)connect */ pty_chr_update_read_handler_locked (chr);if (!s->connected) { -return 0 ; +return len; } }return io_channel_send (s->ioc, buf, len);
Signature · 1 line
1.9.1
Hi
----- Original Message -----
Quoted 17 lines
When a serial port writes data to a pty that's disconnected, drop the data and return the length dropped. This avoids triggering pointless retries in callers like the 16550A
serial_xmit(), and causesqemu_chr_fe_write()to write all data to the log file, rather than logging only while a pty client like virsh console happens to be connected.Signed-off-by Ed Swierk <[email protected]>--- qemu-char.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)qemu-char.c +0
-0
qemu-char.c static int pty_chr_write(CharDriverState *chr, const · line 1532
Quoted 6 lines
qemu-char.c +1
-1@@ -1528,7 +1528,7 @@ static int pty_chr_write(CharDriverState *chr, const uint8_t *buf, int len)/* guest sends data, check for (re-)connect */ pty_chr_update_read_handler_locked (chr );if (!s->connected) { -return 0 ; +return len;
I think this can be confusing if some backends silently drop the data (under disconnected state), while other don't. Perhaps we should have instead a new common chardev property "hup-drop" ? (suggestions for better name welcome)
Quoted 7 lines
qemu-char.c +0
-0} }return io_channel_send(s->ioc, buf, len);--
1.9.1
Hi
----- Original Message -----
Quoted 15 lines
Hi
----- Original Message -----
Quoted 12 lines
When a serial port writes data to a pty that's disconnected, drop the data and return the length dropped. This avoids triggering pointless retries in callers like the 16550A
serial_xmit(), and causesqemu_chr_fe_write()to write all data to the log file, rather than logging only while a pty client like virsh console happens to be connected.Signed-off-by Ed Swierk <[email protected]>--- qemu-char.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
qemu-char.c static int pty_chr_write(CharDriverState *chr, const · line 1532
Quoted 11 lines
qemu-char.c +1
-1@@ -1528,7 +1528,7 @@ static int pty_chr_write(CharDriverState *chr, const uint8_t *buf, int len)/* guest sends data, check for (re-)connect */ pty_chr_update_read_handler_locked (chr );if (!s->connected) { -return 0 ; +return len;I think this can be confusing if some backends silently drop the data (under disconnected state), while other don't. Perhaps we should have instead a new common chardev property "hup-drop" ? (suggestions for better name welcome)
actually,tcp_chr_write() already drops data on disconnected state, so they would have different default value for backward compatibility...
Quoted 8 lines
Quoted 7 lines
qemu-char.c +0
-0} }return io_channel_send(s->ioc, buf, len);--
1.9.1
Quoted 1 line · Marc-André Lureau
I think this can be confusing if some backends silently drop the data (under disconnected state), while other don't. Perhaps we should have instead a new common chardev property "hup-drop" ? (suggestions for better name welcome)
Either way, when a pty is disconnected data will get dropped, whether by the pty backend (as proposed) or by the serial port device or other frontend (as currently).
The only difference from a user's perspective is whether the dropped data gets written to the log file, which is the main motivation for this change. The backward compatibility concern would be an existing application that relies on data not being logged when the pty is disconnected.
--Ed
Quoted 9 lines · Ed Swierk
Either way, when a pty is disconnected data will get dropped, whether by the pty backend (as proposed) or by the serial port device or other frontend (as currently).
The only difference from a user's perspective is whether the dropped data gets written to the log file, which is the main motivation for this change. The backward compatibility concern would be an existing application that relies on data not being logged when the pty is disconnected.
Which is clearly a bug and a pointless difference between TCP and pty backends, so the patch is okay.
Paolo
Quoted 18 lines · Ed Swierk
When a serial port writes data to a pty that's disconnected, drop the data and return the length dropped. This avoids triggering pointless retries in callers like the 16550A
serial_xmit(), and causesqemu_chr_fe_write()to write all data to the log file, rather than logging only while a pty client like virsh console happens to be connected.Signed-off-by Ed Swierk <[email protected]>--- qemu-char.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)qemu-char.c +0
-0
qemu-char.c static int pty_chr_write(CharDriverState *chr, const uint8_t *buf, int len) · line 1534
Quoted 8 lines
qemu-char.c +1
-1@@ -1528,7 +1528,7 @@ static int pty_chr_write(CharDriverState *chr, const uint8_t *buf, int len)/* guest sends data, check for (re-)connect */ pty_chr_update_read_handler_locked (chr);if (!s->connected) { -return 0 ; +return len; } }return io_channel_send (s->ioc, buf, len);
Rebased and queued, thanks.
Paolo