All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/1] serial: Open non-block
@ 2018-02-26 13:04 Dr. David Alan Gilbert (git)
  2018-02-26 13:57 ` Paolo Bonzini
  2018-06-29 14:36 ` Paolo Bonzini
  0 siblings, 2 replies; 4+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2018-02-26 13:04 UTC (permalink / raw)
  To: qemu-devel, pbonzini, marcandre.lureau

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

On a real serial device, the open can block if the handshake
lines are in a particular state.  If a QEMU is passing the serial
device to the guest, the QEMU startup is blocked opening the device
(with a symptom seen as a timeout from libvirt).

Open the serial port with O_NONBLOCK.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 chardev/char-serial.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/chardev/char-serial.c b/chardev/char-serial.c
index feb52e559d..97be5d4a63 100644
--- a/chardev/char-serial.c
+++ b/chardev/char-serial.c
@@ -265,7 +265,8 @@ static void qmp_chardev_open_serial(Chardev *chr,
     ChardevHostdev *serial = backend->u.serial.data;
     int fd;
 
-    fd = qmp_chardev_open_file_source(serial->device, O_RDWR, errp);
+    fd = qmp_chardev_open_file_source(serial->device, O_RDWR | O_NONBLOCK,
+                                      errp);
     if (fd < 0) {
         return;
     }
-- 
2.14.3

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

* Re: [Qemu-devel] [PATCH 1/1] serial: Open non-block
  2018-02-26 13:04 [Qemu-devel] [PATCH 1/1] serial: Open non-block Dr. David Alan Gilbert (git)
@ 2018-02-26 13:57 ` Paolo Bonzini
  2018-02-26 15:13   ` Dr. David Alan Gilbert
  2018-06-29 14:36 ` Paolo Bonzini
  1 sibling, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2018-02-26 13:57 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git), qemu-devel, marcandre.lureau

On 26/02/2018 14:04, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> 
> On a real serial device, the open can block if the handshake
> lines are in a particular state.  If a QEMU is passing the serial
> device to the guest, the QEMU startup is blocked opening the device
> (with a symptom seen as a timeout from libvirt).
> 
> Open the serial port with O_NONBLOCK.
> 
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

Socket chardevs have "nowait" for that.  Should serial have something
similar?

Thanks,

Paolo

> ---
>  chardev/char-serial.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/chardev/char-serial.c b/chardev/char-serial.c
> index feb52e559d..97be5d4a63 100644
> --- a/chardev/char-serial.c
> +++ b/chardev/char-serial.c
> @@ -265,7 +265,8 @@ static void qmp_chardev_open_serial(Chardev *chr,
>      ChardevHostdev *serial = backend->u.serial.data;
>      int fd;
>  
> -    fd = qmp_chardev_open_file_source(serial->device, O_RDWR, errp);
> +    fd = qmp_chardev_open_file_source(serial->device, O_RDWR | O_NONBLOCK,
> +                                      errp);
>      if (fd < 0) {
>          return;
>      }
> 

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

* Re: [Qemu-devel] [PATCH 1/1] serial: Open non-block
  2018-02-26 13:57 ` Paolo Bonzini
@ 2018-02-26 15:13   ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 4+ messages in thread
From: Dr. David Alan Gilbert @ 2018-02-26 15:13 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel, marcandre.lureau

* Paolo Bonzini (pbonzini@redhat.com) wrote:
> On 26/02/2018 14:04, Dr. David Alan Gilbert (git) wrote:
> > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> > 
> > On a real serial device, the open can block if the handshake
> > lines are in a particular state.  If a QEMU is passing the serial
> > device to the guest, the QEMU startup is blocked opening the device
> > (with a symptom seen as a timeout from libvirt).
> > 
> > Open the serial port with O_NONBLOCK.
> > 
> > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> 
> Socket chardevs have "nowait" for that.  Should serial have something
> similar?

Hmm, maybe, although I think for real serial the nonblocking open should
be the default.
I've not got any more complex tests though for it.
stty -F uses the same trick of opening non-blocking.

Dave

> Thanks,
> 
> Paolo
> 
> > ---
> >  chardev/char-serial.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/chardev/char-serial.c b/chardev/char-serial.c
> > index feb52e559d..97be5d4a63 100644
> > --- a/chardev/char-serial.c
> > +++ b/chardev/char-serial.c
> > @@ -265,7 +265,8 @@ static void qmp_chardev_open_serial(Chardev *chr,
> >      ChardevHostdev *serial = backend->u.serial.data;
> >      int fd;
> >  
> > -    fd = qmp_chardev_open_file_source(serial->device, O_RDWR, errp);
> > +    fd = qmp_chardev_open_file_source(serial->device, O_RDWR | O_NONBLOCK,
> > +                                      errp);
> >      if (fd < 0) {
> >          return;
> >      }
> > 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

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

* Re: [Qemu-devel] [PATCH 1/1] serial: Open non-block
  2018-02-26 13:04 [Qemu-devel] [PATCH 1/1] serial: Open non-block Dr. David Alan Gilbert (git)
  2018-02-26 13:57 ` Paolo Bonzini
@ 2018-06-29 14:36 ` Paolo Bonzini
  1 sibling, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2018-06-29 14:36 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git), qemu-devel, marcandre.lureau

On 26/02/2018 14:04, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> 
> On a real serial device, the open can block if the handshake
> lines are in a particular state.  If a QEMU is passing the serial
> device to the guest, the QEMU startup is blocked opening the device
> (with a symptom seen as a timeout from libvirt).
> 
> Open the serial port with O_NONBLOCK.
> 
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
>  chardev/char-serial.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/chardev/char-serial.c b/chardev/char-serial.c
> index feb52e559d..97be5d4a63 100644
> --- a/chardev/char-serial.c
> +++ b/chardev/char-serial.c
> @@ -265,7 +265,8 @@ static void qmp_chardev_open_serial(Chardev *chr,
>      ChardevHostdev *serial = backend->u.serial.data;
>      int fd;
>  
> -    fd = qmp_chardev_open_file_source(serial->device, O_RDWR, errp);
> +    fd = qmp_chardev_open_file_source(serial->device, O_RDWR | O_NONBLOCK,
> +                                      errp);
>      if (fd < 0) {
>          return;
>      }
> 

Queued, thanks.

Paolo

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

end of thread, other threads:[~2018-06-29 14:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-26 13:04 [Qemu-devel] [PATCH 1/1] serial: Open non-block Dr. David Alan Gilbert (git)
2018-02-26 13:57 ` Paolo Bonzini
2018-02-26 15:13   ` Dr. David Alan Gilbert
2018-06-29 14:36 ` 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.