sos-code-article10/extra/patch-qemu-pty.diff

43 lines
1.3 KiB
Diff
Raw Permalink Normal View History

2018-07-13 17:13:10 +02:00
By default, with qemu version < 0.8.0 and with the command line
qemu -monitor pty or -serial pty, local echo is
enabled for the qemu side of the pty. This can result in infinite
write/read loops and/or slowness of the simulation. Attached is a very
small patch (against today's cvs) solving the problem. The 3 lines
adjusting the tty fields could be replaced by "cfmakeraw(&tty)" if
available on the host platform.
-- David Decotigny (Dec 9 2005)
Index: vl.c
===================================================================
RCS file: /cvsroot/qemu/qemu/vl.c,v
retrieving revision 1.152
diff -u -r1.152 vl.c
--- vl.c 5 Dec 2005 20:31:52 -0000 1.152
+++ vl.c 9 Dec 2005 15:07:46 -0000
@@ -1396,6 +1396,7 @@
#if defined(__linux__)
CharDriverState *qemu_chr_open_pty(void)
{
+ struct termios tty;
char slave_name[1024];
int master_fd, slave_fd;
@@ -1403,6 +1404,14 @@
if (openpty(&master_fd, &slave_fd, slave_name, NULL, NULL) < 0) {
return NULL;
}
+
+ /* Disabling local echo and line-buffered output */
+ tcgetattr (master_fd, &tty);
+ tty.c_lflag &= ~(ECHO|ICANON|ISIG);
+ tty.c_cc[VMIN] = 1;
+ tty.c_cc[VTIME] = 0;
+ tcsetattr (master_fd, TCSAFLUSH, &tty);
+
fprintf(stderr, "char device redirected to %s\n", slave_name);
return qemu_chr_open_fd(master_fd, master_fd);
}