qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: Alexander Graf <agraf@suse.de>
Cc: waldi@debian.org, Carsten Otte <carsteno@de.ibm.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 4/6] Always notify consumers of char devices if they're open
Date: Fri, 9 Apr 2010 22:09:16 +0200	[thread overview]
Message-ID: <20100409200916.GL21042@volta.aurel32.net> (raw)
In-Reply-To: <1270140161-17216-5-git-send-email-agraf@suse.de>

On Thu, Apr 01, 2010 at 06:42:39PM +0200, Alexander Graf wrote:
> When using virtio-console on s390, the input doesn't work.
> 
> The root of the problem is rather simple. What happens is the following:
> 
>  1) create character device for stdio
>  2) char device is done creating, sends OPENED event
>  3) virtio-console adds handlers
>  4) no event comes because the char device is open already
>  5) virtio-console doesn't accept input because it didn't
>     receive an OPENED event
> 
> To make that sure virtio-console gets notified that the character device
> is open even when it's been open from the beginning, this patch introduces
> a variable that keeps track of the opened state. If the device is open when
> the event handlers get installed, we just notify the handler.
>
> This fixes input with virtio-console on s390.

Thanks, applied.

> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  qemu-char.c |   20 ++++++++++++++++++++
>  qemu-char.h |    1 +
>  2 files changed, 21 insertions(+), 0 deletions(-)
> 
> diff --git a/qemu-char.c b/qemu-char.c
> index 6ad6609..a9d9442 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -109,6 +109,16 @@ static QTAILQ_HEAD(CharDriverStateHead, CharDriverState) chardevs =
>  
>  static void qemu_chr_event(CharDriverState *s, int event)
>  {
> +    /* Keep track if the char device is open */
> +    switch (event) {
> +        case CHR_EVENT_OPENED:
> +            s->opened = 1;
> +            break;
> +        case CHR_EVENT_CLOSED:
> +            s->opened = 0;
> +            break;
> +    }
> +
>      if (!s->chr_event)
>          return;
>      s->chr_event(s->handler_opaque, event);
> @@ -193,6 +203,12 @@ void qemu_chr_add_handlers(CharDriverState *s,
>      s->handler_opaque = opaque;
>      if (s->chr_update_read_handler)
>          s->chr_update_read_handler(s);
> +
> +    /* We're connecting to an already opened device, so let's make sure we
> +       also get the open event */
> +    if (s->opened) {
> +        qemu_chr_generic_open(s);
> +    }
>  }
>  
>  static int null_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
> @@ -475,6 +491,10 @@ static CharDriverState *qemu_chr_open_mux(CharDriverState *drv)
>      chr->chr_write = mux_chr_write;
>      chr->chr_update_read_handler = mux_chr_update_read_handler;
>      chr->chr_accept_input = mux_chr_accept_input;
> +
> +    /* Muxes are always open on creation */
> +    qemu_chr_generic_open(chr);
> +
>      return chr;
>  }
>  
> diff --git a/qemu-char.h b/qemu-char.h
> index 3a9427b..e3a0783 100644
> --- a/qemu-char.h
> +++ b/qemu-char.h
> @@ -67,6 +67,7 @@ struct CharDriverState {
>      QEMUBH *bh;
>      char *label;
>      char *filename;
> +    int opened;
>      QTAILQ_ENTRY(CharDriverState) next;
>  };
>  
> -- 
> 1.6.0.2
> 
> 
> 
> 

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

  parent reply	other threads:[~2010-04-09 21:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-01 16:42 [Qemu-devel] [PATCH 0/6] S390 April patch round Alexander Graf
2010-04-01 16:42 ` [Qemu-devel] [PATCH 1/6] S390: Add stub for cpu_get_phys_page_debug Alexander Graf
2010-04-01 16:42 ` [Qemu-devel] [PATCH 2/6] S390: Tell user why VM creation failed Alexander Graf
2010-04-01 16:42 ` [Qemu-devel] [PATCH 3/6] Make char muxer more robust wrt small FIFOs Alexander Graf
2010-04-05  3:40   ` Amit Shah
2010-04-07 14:32     ` Alexander Graf
2010-04-07 14:43       ` Amit Shah
2010-04-01 16:42 ` [Qemu-devel] [PATCH 4/6] Always notify consumers of char devices if they're open Alexander Graf
2010-04-05  3:43   ` Amit Shah
2010-04-09 20:09   ` Aurelien Jarno [this message]
2010-04-01 16:42 ` [Qemu-devel] [PATCH 5/6] [S390] Implement virtio reset Alexander Graf
2010-04-09 20:09   ` Aurelien Jarno
2010-04-01 16:42 ` [Qemu-devel] [PATCH 6/6] [S390] Add firmware code Alexander Graf
2010-04-01 21:18   ` [Qemu-devel] " Bastian Blank
2010-04-01 22:10     ` Alexander Graf
2010-04-09 20:17   ` [Qemu-devel] " Aurelien Jarno
2010-04-09 23:29     ` Alexander Graf
2010-04-10  0:00       ` Aurelien Jarno
2010-04-10  9:22         ` Alexander Graf
2010-04-10 15:03           ` Aurelien Jarno
2010-04-12  8:43     ` Carsten Otte

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=20100409200916.GL21042@volta.aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=agraf@suse.de \
    --cc=carsteno@de.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=waldi@debian.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).