diff options
Diffstat (limited to 'util/oslib-posix.c')
-rw-r--r-- | util/oslib-posix.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/util/oslib-posix.c b/util/oslib-posix.c index e00a44c..d5dca47 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -47,6 +47,9 @@ extern int daemon(int, int); # define QEMU_VMALLOC_ALIGN getpagesize() #endif +#include <termios.h> +#include <unistd.h> + #include <glib/gprintf.h> #include "config-host.h" @@ -85,6 +88,11 @@ void *qemu_oom_check(void *ptr) void *qemu_memalign(size_t alignment, size_t size) { void *ptr; + + if (alignment < sizeof(void*)) { + alignment = sizeof(void*); + } + #if defined(_POSIX_C_SOURCE) && !defined(__sun__) int ret; ret = posix_memalign(&ptr, alignment, size); @@ -251,3 +259,18 @@ qemu_get_local_state_pathname(const char *relative_pathname) return g_strdup_printf("%s/%s", CONFIG_QEMU_LOCALSTATEDIR, relative_pathname); } + +void qemu_set_tty_echo(int fd, bool echo) +{ + struct termios tty; + + tcgetattr(fd, &tty); + + if (echo) { + tty.c_lflag |= ECHO | ECHONL | ICANON | IEXTEN; + } else { + tty.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN); + } + + tcsetattr(fd, TCSANOW, &tty); +} |