qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] terminal attributes is not restored when using /dev/tty monitor
@ 2010-02-20  8:30 Shahar Havivi
  2010-02-20 15:18 ` David S. Ahern
  0 siblings, 1 reply; 8+ messages in thread
From: Shahar Havivi @ 2010-02-20  8:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dor Laor

when exiting qemu that run with "-monitor /dev/tty", the launching
terminal get weird behaviour because no restore terminals action has
taken.
added chr_close and register atexit() code for tty devices (like stdio
does)

Signed-off-by: Shahar Havivi <shaharh@redhat.com>
---
 qemu-char.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index 75dbf66..de16883 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1002,6 +1002,7 @@ static void tty_serial_init(int fd, int speed,
            speed, parity, data_bits, stop_bits);
 #endif
     tcgetattr (fd, &tty);
+    oldtty = tty;
 
 #define check_speed(val) if (speed <= val) { spd = B##val; break; }
     speed = speed * 10 / 11;
@@ -1173,6 +1174,17 @@ static int tty_serial_ioctl(CharDriverState *chr, int cmd, void *arg)
     return 0;
 }
 
+static void tty_exit(void)
+{
+    tcsetattr(0, TCSANOW, &oldtty);
+}
+
+static void qemu_chr_close_tty(struct CharDriverState *chr)
+{
+    tty_exit();
+    fd_chr_close(chr);
+}
+
 static CharDriverState *qemu_chr_open_tty(QemuOpts *opts)
 {
     const char *filename = qemu_opt_get(opts, "path");
@@ -1190,6 +1202,8 @@ static CharDriverState *qemu_chr_open_tty(QemuOpts *opts)
         return NULL;
     }
     chr->chr_ioctl = tty_serial_ioctl;
+    chr->chr_close = qemu_chr_close_tty;
+    atexit(tty_exit);
     return chr;
 }
 #else  /* ! __linux__ && ! __sun__ */
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-02-21 15:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-20  8:30 [Qemu-devel] [PATCH] terminal attributes is not restored when using /dev/tty monitor Shahar Havivi
2010-02-20 15:18 ` David S. Ahern
2010-02-20 16:59   ` Shahar Havivi
2010-02-20 17:03   ` Anthony Liguori
2010-02-20 19:42     ` Shahar Havivi
2010-02-21 14:32       ` David S. Ahern
2010-02-21 15:06         ` Shahar Havivi
2010-02-21 14:26     ` David S. Ahern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).