mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-12-11 16:00:50 -07:00
create qemu_openpty_raw() helper function and move it to a separate file
In two places qemu uses openpty() which is very system-dependent, and in both places the pty is switched to raw mode as well. Make a wrapper function which does both steps, and move all the system-dependent complexity into a separate file, together with static/local implementations of openpty() and cfmakeraw() from qemu-char.c. It is in a separate file, not part of oslib-posix.c, because openpty() often resides in -lutil which is not linked to every program qemu builds. This change removes #including of <pty.h>, <termios.h> and other rather specific system headers out of qemu-common.h, which isn't a place for such specific headers really. This version has been verified to build correctly on Linux, OpenBSD, FreeBSD and OpenIndiana. On the latter it lets qemu to be built with gtk gui which were not possible there due to missing openpty() and cfmakeraw(). Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Tested-by: Andreas Färber <andreas.faerber@web.de>
This commit is contained in:
parent
520b6dd4d0
commit
4efeabbbe8
5 changed files with 146 additions and 95 deletions
12
ui/gtk.c
12
ui/gtk.c
|
|
@ -1160,8 +1160,7 @@ static GSList *gd_vc_init(GtkDisplayState *s, VirtualConsole *vc, int index, GSL
|
|||
GIOChannel *chan;
|
||||
GtkWidget *scrolled_window;
|
||||
GtkAdjustment *vadjustment;
|
||||
int master_fd, slave_fd, ret;
|
||||
struct termios tty;
|
||||
int master_fd, slave_fd;
|
||||
|
||||
snprintf(buffer, sizeof(buffer), "vc%d", index);
|
||||
snprintf(path, sizeof(path), "<QEMU>/View/VC%d", index);
|
||||
|
|
@ -1181,13 +1180,8 @@ static GSList *gd_vc_init(GtkDisplayState *s, VirtualConsole *vc, int index, GSL
|
|||
|
||||
vc->terminal = vte_terminal_new();
|
||||
|
||||
ret = openpty(&master_fd, &slave_fd, NULL, NULL, NULL);
|
||||
g_assert(ret != -1);
|
||||
|
||||
/* Set raw attributes on the pty. */
|
||||
tcgetattr(slave_fd, &tty);
|
||||
cfmakeraw(&tty);
|
||||
tcsetattr(slave_fd, TCSAFLUSH, &tty);
|
||||
master_fd = qemu_openpty_raw(&slave_fd, NULL);
|
||||
g_assert(master_fd != -1);
|
||||
|
||||
#if VTE_CHECK_VERSION(0, 26, 0)
|
||||
pty = vte_pty_new_foreign(master_fd, NULL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue