Used by the followin patch. Signed-off-by: Alon Levy <al...@redhat.com> --- include/qemu-common.h | 1 + util/oslib-posix.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+)
diff --git a/include/qemu-common.h b/include/qemu-common.h index cb82ef3..c24d75c 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -232,6 +232,7 @@ ssize_t qemu_recv_full(int fd, void *buf, size_t count, int flags) #ifndef _WIN32 int qemu_pipe(int pipefd[2]); +int qemu_pipe_non_block(int pipefd[2]); #endif #ifdef _WIN32 diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 3dc8b1b..bc2ce2e 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -188,6 +188,25 @@ int qemu_pipe(int pipefd[2]) return ret; } +int qemu_pipe_non_block(int pipefd[2]) +{ + int ret; + + ret = qemu_pipe(pipefd); + if (ret) { + return ret; + } + if (fcntl(card->pipe[0], F_SETFL, O_NONBLOCK) == -1) { + return -errno; + } + if (fcntl(card->pipe[1], F_SETFL, O_NONBLOCK) == -1) { + return -errno; + } + if (fcntl(card->pipe[0], F_SETOWN, getpid()) == -1) { + return -errno; + } +} + int qemu_utimens(const char *path, const struct timespec *times) { struct timeval tv[2], tv_now; -- 1.8.2.1