diff options
author | Li Liu <john.liuli@huawei.com> | 2014-09-09 19:19:48 +0800 |
---|---|---|
committer | Michael Tokarev <mjt@tls.msk.ru> | 2014-09-20 17:55:53 +0400 |
commit | c88930a6866e74953e931ae749781e98e486e5c8 (patch) | |
tree | 9bb00517d6cf4bf55a84edc6147c8329ae95b9a4 | |
parent | 07e2863d0271ac6c05206d8ce9e4f4c39b25d3ea (diff) |
qemu-char: Permit only a single "stdio" character device
When more than one is used, the terminal settings aren't restored
correctly on exit. Fixable. However, such usage makes no sense,
because the users race for input, so outlaw it instead.
If you want to connect multiple things to stdio, use the mux
chardev.
Signed-off-by: Li Liu <john.liuli@huawei.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
-rw-r--r-- | qemu-char.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/qemu-char.c b/qemu-char.c index 2a3cb9fb05..8623c70964 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -1017,6 +1017,7 @@ static CharDriverState *qemu_chr_open_pipe(ChardevHostdev *opts) /* init terminal so that we can grab keys */ static struct termios oldtty; static int old_fd0_flags; +static bool stdio_in_use; static bool stdio_allow_signal; static void term_exit(void) @@ -1060,8 +1061,15 @@ static CharDriverState *qemu_chr_open_stdio(ChardevStdio *opts) error_report("cannot use stdio with -daemonize"); return NULL; } + + if (stdio_in_use) { + error_report("cannot use stdio by multiple character devices"); + exit(1); + } + + stdio_in_use = true; old_fd0_flags = fcntl(0, F_GETFL); - tcgetattr (0, &oldtty); + tcgetattr(0, &oldtty); qemu_set_nonblock(0); atexit(term_exit); |