From patchwork Wed Aug 11 21:56:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 61509 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 05D81B70AF for ; Thu, 12 Aug 2010 07:57:58 +1000 (EST) Received: from localhost ([127.0.0.1]:56742 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OjJJ4-0007Mr-Sa for incoming@patchwork.ozlabs.org; Wed, 11 Aug 2010 17:57:54 -0400 Received: from [140.186.70.92] (port=58797 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OjJHV-0006n3-6M for qemu-devel@nongnu.org; Wed, 11 Aug 2010 17:56:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OjJHT-0005Rr-K1 for qemu-devel@nongnu.org; Wed, 11 Aug 2010 17:56:17 -0400 Received: from mail-qy0-f173.google.com ([209.85.216.173]:64742) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OjJHT-0005Rl-GY for qemu-devel@nongnu.org; Wed, 11 Aug 2010 17:56:15 -0400 Received: by qyk33 with SMTP id 33so669047qyk.4 for ; Wed, 11 Aug 2010 14:56:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:cc:subject :date:message-id:x-mailer; bh=wYWZfSKucWQU8ifB7UL9CspLLzdk0wajm4c+f4tnilo=; b=l1Ab2isvzBx4Mmufd8/vs8QHDWAwZkAj8oRbrYao4HLZ8jCyzbV6SnCCngvWeSlpbY nWqAJZi53djbvBtWoBqCxnD0Gl3WccMiNQ96s2deGJPghWviTxpirHJsikOA+G3stmPg pmy4kYI7+hllwMgRj12PS8mhSO+EGH015dcaI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer; b=wkQJipJgvx82wRk+DEfGGcllCIi1ShPtBP3agiD1SAEwhj8GskiflKFTHoChaWYXkL 5pHQZM7s5fEGBwGFtEZw8swcPsRuK8MkXF3WFJTxxmdAzqK26HyveASbwD936rDNxR+D Cai7t87AO+U61srGf1qhxeUx0vfTXxZnSRaOc= Received: by 10.229.175.167 with SMTP id ba39mr10021444qcb.181.1281563774973; Wed, 11 Aug 2010 14:56:14 -0700 (PDT) Received: from localhost.localdomain ([12.198.177.3]) by mx.google.com with ESMTPS id l8sm788604qck.30.2010.08.11.14.56.13 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 11 Aug 2010 14:56:13 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 11 Aug 2010 17:56:06 -0400 Message-Id: <1281563766-19391-1-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: Kevin Wolf Subject: [Qemu-devel] [PATCH] make -qmp stdio usable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. 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);