Received: from eggs.gnu.org ([2001:4830:134:3::10]:39915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBKSU-0002dV-T2 for qemu-devel@nongnu.org; Wed, 14 Jan 2015 04:41:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YBKSL-00005t-2w for qemu-devel@nongnu.org; Wed, 14 Jan 2015 04:41:50 -0500 Received: from mail-wi0-x22d.google.com ([2a00:1450:400c:c05::22d]:55822) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBKSK-00005m-S5 for qemu-devel@nongnu.org; Wed, 14 Jan 2015 04:41:41 -0500 Received: by mail-wi0-f173.google.com with SMTP id hi2so3987528wib.0 for ; Wed, 14 Jan 2015 01:41:40 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 14 Jan 2015 10:41:18 +0100 Message-Id: <1421228492-19856-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1421228492-19856-1-git-send-email-pbonzini@redhat.com> References: <1421228492-19856-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 01/15] char: restore stdio echo on resume from suspend. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gal Hammer From: Gal Hammer 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 Signed-off-by: Paolo Bonzini --- 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; -- 1.8.3.1