All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: Ashley Jonathan <jonathan.ashley@altran.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "qemu-trivial@nongnu.org" <qemu-trivial@nongnu.org>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>
Subject: Re: [Qemu-trivial] [PATCH] Keep pty slave file descriptor open until the master is closed
Date: Mon, 11 Jan 2016 11:33:58 +0300	[thread overview]
Message-ID: <569368F6.3050704@msgid.tls.msk.ru> (raw)
In-Reply-To: <AC19797808C8D548ABDE0CA4A97AA30A30DEB409@XMB-DCFR-37.europe.corp.altran.com>

11.12.2015 14:29, Ashley Jonathan wrote:
> I have experienced a minor difficulty using QEMU with the "-serial pty" option:
> 
> If a process opens the slave pts device, writes data to it, then immediately closes it, the data doesn't reliably get delivered to the emulated serial port. This seems to be because a read of the master pty device returns EIO on Linux if no process has the pts device open, even when data is waiting "in the pipe".
> 
> A fix seems to be for QEMU to keep the pts file descriptor open until the pty is closed, as per the below patch.

The patch looks fine, so

Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>

but I'd love to have an ACK from the maintainer about this one,
or for it to pick it up.

Thanks,

/mjt

> ---
>  qemu-char.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/qemu-char.c b/qemu-char.c
> index 2969c44..ed03ba0 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -1198,6 +1198,7 @@ typedef struct {
>      int connected;
>      guint timer_tag;
>      guint open_tag;
> +    int slave_fd;
>  } PtyCharDriver;
>  
>  static void pty_chr_update_read_handler_locked(CharDriverState *chr);
> @@ -1373,6 +1374,7 @@ static void pty_chr_close(struct CharDriverState *chr)
>  
>      qemu_mutex_lock(&chr->chr_write_lock);
>      pty_chr_state(chr, 0);
> +    close(s->slave_fd);
>      fd = g_io_channel_unix_get_fd(s->fd);
>      g_io_channel_unref(s->fd);
>      close(fd);
> @@ -1401,7 +1403,6 @@ static CharDriverState *qemu_chr_open_pty(const char *id,
>          return NULL;
>      }
>  
> -    close(slave_fd);
>      qemu_set_nonblock(master_fd);
>  
>      chr = qemu_chr_alloc();
> @@ -1422,6 +1423,7 @@ static CharDriverState *qemu_chr_open_pty(const char *id,
>      chr->explicit_be_open = true;
>  
>      s->fd = io_channel_from_fd(master_fd);
> +    s->slave_fd = slave_fd;
>      s->timer_tag = 0;
>  
>      return chr;
> 



WARNING: multiple messages have this Message-ID (diff)
From: Michael Tokarev <mjt@tls.msk.ru>
To: Ashley Jonathan <jonathan.ashley@altran.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "qemu-trivial@nongnu.org" <qemu-trivial@nongnu.org>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] Keep pty slave file descriptor open until the master is closed
Date: Mon, 11 Jan 2016 11:33:58 +0300	[thread overview]
Message-ID: <569368F6.3050704@msgid.tls.msk.ru> (raw)
In-Reply-To: <AC19797808C8D548ABDE0CA4A97AA30A30DEB409@XMB-DCFR-37.europe.corp.altran.com>

11.12.2015 14:29, Ashley Jonathan wrote:
> I have experienced a minor difficulty using QEMU with the "-serial pty" option:
> 
> If a process opens the slave pts device, writes data to it, then immediately closes it, the data doesn't reliably get delivered to the emulated serial port. This seems to be because a read of the master pty device returns EIO on Linux if no process has the pts device open, even when data is waiting "in the pipe".
> 
> A fix seems to be for QEMU to keep the pts file descriptor open until the pty is closed, as per the below patch.

The patch looks fine, so

Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>

but I'd love to have an ACK from the maintainer about this one,
or for it to pick it up.

Thanks,

/mjt

> ---
>  qemu-char.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/qemu-char.c b/qemu-char.c
> index 2969c44..ed03ba0 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -1198,6 +1198,7 @@ typedef struct {
>      int connected;
>      guint timer_tag;
>      guint open_tag;
> +    int slave_fd;
>  } PtyCharDriver;
>  
>  static void pty_chr_update_read_handler_locked(CharDriverState *chr);
> @@ -1373,6 +1374,7 @@ static void pty_chr_close(struct CharDriverState *chr)
>  
>      qemu_mutex_lock(&chr->chr_write_lock);
>      pty_chr_state(chr, 0);
> +    close(s->slave_fd);
>      fd = g_io_channel_unix_get_fd(s->fd);
>      g_io_channel_unref(s->fd);
>      close(fd);
> @@ -1401,7 +1403,6 @@ static CharDriverState *qemu_chr_open_pty(const char *id,
>          return NULL;
>      }
>  
> -    close(slave_fd);
>      qemu_set_nonblock(master_fd);
>  
>      chr = qemu_chr_alloc();
> @@ -1422,6 +1423,7 @@ static CharDriverState *qemu_chr_open_pty(const char *id,
>      chr->explicit_be_open = true;
>  
>      s->fd = io_channel_from_fd(master_fd);
> +    s->slave_fd = slave_fd;
>      s->timer_tag = 0;
>  
>      return chr;
> 

  reply	other threads:[~2016-01-11  8:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-11 11:29 [Qemu-trivial] [PATCH] Keep pty slave file descriptor open until the master is closed Ashley Jonathan
2015-12-11 11:29 ` [Qemu-devel] " Ashley Jonathan
2016-01-11  8:33 ` Michael Tokarev [this message]
2016-01-11  8:33   ` Michael Tokarev
2016-01-11  9:13   ` [Qemu-trivial] " Paolo Bonzini
2016-01-11  9:13     ` [Qemu-devel] " Paolo Bonzini
2016-02-12  2:29     ` [Qemu-trivial] " Marc-André Lureau
2016-02-12  2:29       ` Marc-André Lureau
2016-02-12 13:51       ` [Qemu-trivial] " Marc-André Lureau
2016-02-12 13:51         ` Marc-André Lureau
2016-01-11  9:16 ` [Qemu-trivial] " Paolo Bonzini
2016-01-11  9:16   ` [Qemu-devel] " Paolo Bonzini
2016-01-11  9:29   ` [Qemu-trivial] " Ashley Jonathan
2016-01-11  9:29     ` [Qemu-devel] " Ashley Jonathan

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=569368F6.3050704@msgid.tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=jonathan.ashley@altran.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@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 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.