From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=33427 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OnIR4-0007rO-6M for qemu-devel@nongnu.org; Sun, 22 Aug 2010 17:53:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OnIQZ-00089W-4u for qemu-devel@nongnu.org; Sun, 22 Aug 2010 17:50:08 -0400 Received: from mail-yx0-f173.google.com ([209.85.213.173]:64163) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OnIQZ-00089Q-2Z for qemu-devel@nongnu.org; Sun, 22 Aug 2010 17:50:07 -0400 Received: by yxn35 with SMTP id 35so2056689yxn.4 for ; Sun, 22 Aug 2010 14:50:06 -0700 (PDT) Message-ID: <4C719B8D.1010208@codemonkey.ws> Date: Sun, 22 Aug 2010 16:50:05 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] make -qmp stdio usable References: <1281563766-19391-1-git-send-email-pbonzini@redhat.com> In-Reply-To: <1281563766-19391-1-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Kevin Wolf , qemu-devel@nongnu.org On 08/11/2010 04:56 PM, Paolo Bonzini wrote: > Currently -qmp stdio (or the equivalent -mon/-chardev combination) sets > up the terminal attributes even though it does not go through readline > to actually do I/O. As a result, echo is disabled and you cannot see > anything you type. This patch fixes it by adding a "cooked" option to > the stdio chardev backend, that when set will disable switching the tty > to raw mode. > cooked doesn't make a whole lot of sense to me (and it's not documented anywhere). Maybe raw=on|off or even echo=on|off would make more sense? Regards, Anthony Liguori > Cc: Kevin Wolf > Signed-off-by: Paolo Bonzini > --- > qemu-char.c | 26 ++++++++++++++------------ > qemu-config.c | 3 +++ > vl.c | 3 +++ > 3 files changed, 20 insertions(+), 12 deletions(-) > > diff --git a/qemu-char.c b/qemu-char.c > index 6a3952c..15e1891 100644 > --- a/qemu-char.c > +++ b/qemu-char.c > @@ -735,19 +735,21 @@ static void term_init(QemuOpts *opts) > oldtty = tty; > old_fd0_flags = fcntl(0, F_GETFL); > > - tty.c_iflag&= ~(IGNBRK|BRKINT|PARMRK|ISTRIP > + if (!qemu_opt_get_bool(opts, "cooked", 0)) { > + tty.c_iflag&= ~(IGNBRK|BRKINT|PARMRK|ISTRIP > |INLCR|IGNCR|ICRNL|IXON); > - tty.c_oflag |= OPOST; > - tty.c_lflag&= ~(ECHO|ECHONL|ICANON|IEXTEN); > - /* if graphical mode, we allow Ctrl-C handling */ > - if (!qemu_opt_get_bool(opts, "signal", display_type != DT_NOGRAPHIC)) > - tty.c_lflag&= ~ISIG; > - tty.c_cflag&= ~(CSIZE|PARENB); > - tty.c_cflag |= CS8; > - tty.c_cc[VMIN] = 1; > - tty.c_cc[VTIME] = 0; > - > - tcsetattr (0, TCSANOW,&tty); > + tty.c_oflag |= OPOST; > + tty.c_lflag&= ~(ECHO|ECHONL|ICANON|IEXTEN); > + /* if graphical mode, we allow Ctrl-C handling */ > + if (!qemu_opt_get_bool(opts, "signal", display_type != DT_NOGRAPHIC)) > + tty.c_lflag&= ~ISIG; > + tty.c_cflag&= ~(CSIZE|PARENB); > + tty.c_cflag |= CS8; > + tty.c_cc[VMIN] = 1; > + tty.c_cc[VTIME] = 0; > + > + tcsetattr (0, TCSANOW,&tty); > + } > > if (!term_atexit_done++) > atexit(term_exit); > diff --git a/qemu-config.c b/qemu-config.c > index 95abe61..8c525b0 100644 > --- a/qemu-config.c > +++ b/qemu-config.c > @@ -146,6 +146,9 @@ QemuOptsList qemu_chardev_opts = { > },{ > .name = "signal", > .type = QEMU_OPT_BOOL, > + },{ > + .name = "cooked", > + .type = QEMU_OPT_BOOL, > }, > { /* end if list */ } > }, > diff --git a/vl.c b/vl.c > index b3e3676..be122e7 100644 > --- a/vl.c > +++ b/vl.c > @@ -1596,6 +1596,9 @@ static void monitor_parse(const char *optarg, const char *mode) > fprintf(stderr, "parse error: %s\n", optarg); > exit(1); > } > + if (!strcmp(mode, "control")) { > + qemu_opt_set(opts, "cooked", "on"); > + } > } > > opts = qemu_opts_create(&qemu_mon_opts, label, 1); >