All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Gal Hammer <ghammer@redhat.com>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, marcel.apfelbaum@gmail.com
Subject: Re: [Qemu-devel] [PATCH V2] char: restore stdio echo on resume from suspend.
Date: Wed, 07 Jan 2015 10:43:27 +0100	[thread overview]
Message-ID: <54ACFFBF.6010905@redhat.com> (raw)
In-Reply-To: <1420619915-8600-1-git-send-email-ghammer@redhat.com>



On 07/01/2015 09:38, Gal Hammer wrote:
> The monitor's auto-completion feature stopped working when stdio is used
> as an input and qemu was resumed after it was suspended (using ctrl-z).
> 
> Signed-off-by: Gal Hammer <ghammer@redhat.com>

Looks good, thanks Peter for reviewing v1.

Paolo

> ---
> V2 - restore old echo state rather than alway disable it.
>    - don't check signal identifier in the handler function.
>    - use sigaction() and not signal().
> ---
>  qemu-char.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/qemu-char.c b/qemu-char.c
> index ef84b53..5430b87 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -1112,6 +1112,9 @@ static struct termios oldtty;
>  static int old_fd0_flags;
>  static bool stdio_in_use;
>  static bool stdio_allow_signal;
> +static bool stdio_echo_state;
> +
> +static void qemu_chr_set_echo_stdio(CharDriverState *chr, bool echo);
>  
>  static void term_exit(void)
>  {
> @@ -1119,10 +1122,17 @@ static void term_exit(void)
>      fcntl(0, F_SETFL, old_fd0_flags);
>  }
>  
> +static void term_stdio_handler(int sig)
> +{
> +    /* restore echo after resume from suspend. */
> +    qemu_chr_set_echo_stdio(NULL, stdio_echo_state);
> +}
> +
>  static void qemu_chr_set_echo_stdio(CharDriverState *chr, bool echo)
>  {
>      struct termios tty;
>  
> +    stdio_echo_state = echo;
>      tty = oldtty;
>      if (!echo) {
>          tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
> @@ -1149,6 +1159,7 @@ static void qemu_chr_close_stdio(struct CharDriverState *chr)
>  static CharDriverState *qemu_chr_open_stdio(ChardevStdio *opts)
>  {
>      CharDriverState *chr;
> +    struct sigaction act;
>  
>      if (is_daemonized()) {
>          error_report("cannot use stdio with -daemonize");
> @@ -1166,6 +1177,10 @@ static CharDriverState *qemu_chr_open_stdio(ChardevStdio *opts)
>      qemu_set_nonblock(0);
>      atexit(term_exit);
>  
> +    memset(&act, 0, sizeof(act));
> +    act.sa_handler = term_stdio_handler;
> +    sigaction(SIGCONT, &act, NULL);
> +
>      chr = qemu_chr_open_fd(0, 1);
>      chr->chr_close = qemu_chr_close_stdio;
>      chr->chr_set_echo = qemu_chr_set_echo_stdio;
> 

      reply	other threads:[~2015-01-07 14:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-07  8:38 [Qemu-devel] [PATCH V2] char: restore stdio echo on resume from suspend Gal Hammer
2015-01-07  9:43 ` Paolo Bonzini [this message]

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=54ACFFBF.6010905@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=ghammer@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@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.