]> Git Repo - qemu.git/commitdiff
qemu-char: Permit only a single "stdio" character device
authorLi Liu <[email protected]>
Tue, 9 Sep 2014 11:19:48 +0000 (19:19 +0800)
committerMichael Tokarev <[email protected]>
Sat, 20 Sep 2014 13:55:53 +0000 (17:55 +0400)
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 <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
qemu-char.c

index 2a3cb9fb05ef4fe2ae34260aeccf28d3f132e667..8623c7096446a32e2b3e37c78cb9640e9827b25f 100644 (file)
@@ -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);
 
This page took 0.031885 seconds and 4 git commands to generate.