From 13401ba0b982024b62a99388032bbb889dc98b43 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Thu, 14 Nov 2013 11:54:16 +0100 Subject: osdep: add qemu_set_tty_echo() Using stdin with readline.c requires disabling echo and line buffering. Add a portable wrapper to set the terminal attributes under Linux and Windows. Signed-off-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- util/oslib-posix.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'util/oslib-posix.c') diff --git a/util/oslib-posix.c b/util/oslib-posix.c index e00a44c86f..f5c401646f 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 +#include + #include #include "config-host.h" @@ -251,3 +254,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); +} -- cgit 1.4.1 From e5354657a626b325c31888f33de88ac6d39e2fcb Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Fri, 29 Nov 2013 21:29:17 +0100 Subject: qemu_memalign: Allow small alignments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The functions used by qemu_memalign() require an alignment that is at least sizeof(void*). Adjust it if it is too small. Signed-off-by: Kevin Wolf Reviewed-by: Wenchao Xia Reviewed-by: Max Reitz Reviewed-by: BenoƮt Canet --- util/oslib-posix.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'util/oslib-posix.c') diff --git a/util/oslib-posix.c b/util/oslib-posix.c index f5c401646f..d5dca4729a 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -88,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); -- cgit 1.4.1