char: restore stdio echo on resume from suspend.

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>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Gal Hammer 2015-01-07 10:38:35 +02:00 committed by Paolo Bonzini
parent f1c5831ca3
commit e76d442043

View File

@ -1112,6 +1112,9 @@ static struct termios oldtty;
static int old_fd0_flags; static int old_fd0_flags;
static bool stdio_in_use; static bool stdio_in_use;
static bool stdio_allow_signal; 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) static void term_exit(void)
{ {
@ -1119,10 +1122,17 @@ static void term_exit(void)
fcntl(0, F_SETFL, old_fd0_flags); 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) static void qemu_chr_set_echo_stdio(CharDriverState *chr, bool echo)
{ {
struct termios tty; struct termios tty;
stdio_echo_state = echo;
tty = oldtty; tty = oldtty;
if (!echo) { if (!echo) {
tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP 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) static CharDriverState *qemu_chr_open_stdio(ChardevStdio *opts)
{ {
CharDriverState *chr; CharDriverState *chr;
struct sigaction act;
if (is_daemonized()) { if (is_daemonized()) {
error_report("cannot use stdio with -daemonize"); error_report("cannot use stdio with -daemonize");
@ -1166,6 +1177,10 @@ static CharDriverState *qemu_chr_open_stdio(ChardevStdio *opts)
qemu_set_nonblock(0); qemu_set_nonblock(0);
atexit(term_exit); 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 = qemu_chr_open_fd(0, 1);
chr->chr_close = qemu_chr_close_stdio; chr->chr_close = qemu_chr_close_stdio;
chr->chr_set_echo = qemu_chr_set_echo_stdio; chr->chr_set_echo = qemu_chr_set_echo_stdio;