All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] char: drop data written to a disconnected pty
@ 2017-01-31 13:45 Ed Swierk
  2017-01-31 14:06 ` Marc-André Lureau
  2017-02-06  9:51 ` Paolo Bonzini
  0 siblings, 2 replies; 6+ messages in thread
From: Ed Swierk @ 2017-01-31 13:45 UTC (permalink / raw)
  To: qemu-devel
  Cc: libvir-list, berrange, pbonzini, marcandre.lureau, eblake, ben,
	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 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.

Signed-off-by: Ed Swierk <eswierk@skyportsystems.com>
---
 qemu-char.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qemu-char.c b/qemu-char.c
index 676944a..ccb6923 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -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);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] char: drop data written to a disconnected pty
  2017-01-31 13:45 [Qemu-devel] [PATCH] char: drop data written to a disconnected pty Ed Swierk
@ 2017-01-31 14:06 ` Marc-André Lureau
  2017-01-31 14:07   ` Marc-André Lureau
  2017-01-31 22:19   ` Ed Swierk
  2017-02-06  9:51 ` Paolo Bonzini
  1 sibling, 2 replies; 6+ messages in thread
From: Marc-André Lureau @ 2017-01-31 14:06 UTC (permalink / raw)
  To: Ed Swierk
  Cc: qemu-devel, libvir-list, berrange, pbonzini, marcandre lureau,
	eblake, ben

Hi

----- Original Message -----
> 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.
> 
> Signed-off-by: Ed Swierk <eswierk@skyportsystems.com>
> ---
>  qemu-char.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/qemu-char.c b/qemu-char.c
> index 676944a..ccb6923 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -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)

>          }
>      }
>      return io_channel_send(s->ioc, buf, len);
> --
> 1.9.1
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] char: drop data written to a disconnected pty
  2017-01-31 14:06 ` Marc-André Lureau
@ 2017-01-31 14:07   ` Marc-André Lureau
  2017-01-31 22:19   ` Ed Swierk
  1 sibling, 0 replies; 6+ messages in thread
From: Marc-André Lureau @ 2017-01-31 14:07 UTC (permalink / raw)
  To: Ed Swierk
  Cc: qemu-devel, libvir-list, berrange, pbonzini, marcandre lureau,
	eblake, ben

Hi

----- Original Message -----
> Hi
> 
> ----- Original Message -----
> > 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.
> > 
> > Signed-off-by: Ed Swierk <eswierk@skyportsystems.com>
> > ---
> >  qemu-char.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/qemu-char.c b/qemu-char.c
> > index 676944a..ccb6923 100644
> > --- a/qemu-char.c
> > +++ b/qemu-char.c
> > @@ -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...

> >          }
> >      }
> >      return io_channel_send(s->ioc, buf, len);
> > --
> > 1.9.1
> > 
> > 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] char: drop data written to a disconnected pty
  2017-01-31 14:06 ` Marc-André Lureau
  2017-01-31 14:07   ` Marc-André Lureau
@ 2017-01-31 22:19   ` Ed Swierk
  2017-02-02  1:11     ` Paolo Bonzini
  1 sibling, 1 reply; 6+ messages in thread
From: Ed Swierk @ 2017-01-31 22:19 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, libvir-list, Daniel P. Berrange, Paolo Bonzini,
	marcandre lureau, Eric Blake, Benjamin Warren

On Tue, Jan 31, 2017 at 6:06 AM, Marc-André Lureau <mlureau@redhat.com> wrote:
> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] char: drop data written to a disconnected pty
  2017-01-31 22:19   ` Ed Swierk
@ 2017-02-02  1:11     ` Paolo Bonzini
  0 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2017-02-02  1:11 UTC (permalink / raw)
  To: Ed Swierk, Marc-André Lureau
  Cc: qemu-devel, libvir-list, Daniel P. Berrange, marcandre lureau,
	Eric Blake, Benjamin Warren



On 31/01/2017 14:19, Ed Swierk wrote:
> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] char: drop data written to a disconnected pty
  2017-01-31 13:45 [Qemu-devel] [PATCH] char: drop data written to a disconnected pty Ed Swierk
  2017-01-31 14:06 ` Marc-André Lureau
@ 2017-02-06  9:51 ` Paolo Bonzini
  1 sibling, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2017-02-06  9:51 UTC (permalink / raw)
  To: Ed Swierk, qemu-devel
  Cc: libvir-list, berrange, marcandre.lureau, eblake, ben



On 31/01/2017 14:45, Ed Swierk wrote:
> 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.
> 
> Signed-off-by: Ed Swierk <eswierk@skyportsystems.com>
> ---
>  qemu-char.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/qemu-char.c b/qemu-char.c
> index 676944a..ccb6923 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-02-06  9:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-31 13:45 [Qemu-devel] [PATCH] char: drop data written to a disconnected pty Ed Swierk
2017-01-31 14:06 ` Marc-André Lureau
2017-01-31 14:07   ` Marc-André Lureau
2017-01-31 22:19   ` Ed Swierk
2017-02-02  1:11     ` Paolo Bonzini
2017-02-06  9:51 ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.