Received: from eggs.gnu.org ([2001:4830:134:3::10]:43688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XVyia-0006j6-AN for qemu-devel@nongnu.org; Mon, 22 Sep 2014 04:11:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XVyiT-000664-77 for qemu-devel@nongnu.org; Mon, 22 Sep 2014 04:11:32 -0400 From: Michael Tokarev Date: Mon, 22 Sep 2014 12:11:09 +0400 Message-Id: <1411373477-16938-2-git-send-email-mjt@msgid.tls.msk.ru> In-Reply-To: <1411373477-16938-1-git-send-email-mjt@tls.msk.ru> References: <1411373477-16938-1-git-send-email-mjt@tls.msk.ru> Subject: [Qemu-devel] [PULL 1/9] qemu-char: Permit only a single "stdio" character device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Li Liu , Michael Tokarev From: Li Liu 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 Reviewed-by: Markus Armbruster Signed-off-by: Michael Tokarev --- qemu-char.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qemu-char.c b/qemu-char.c index 2a3cb9f..8623c70 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); -- 1.7.10.4