Browse Source

Replace qemu_pipe() with g_unix_open_pipe()

GLib g_unix_open_pipe() is essentially like qemu_pipe(), available since
2.30.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
pull/213/head
Marc-André Lureau 4 years ago
parent
commit
a7241974ce
  1. 4
      include/qemu/osdep.h
  2. 5
      qemu-nbd.c
  3. 2
      util/event_notifier-posix.c
  4. 22
      util/oslib-posix.c

4
include/qemu/osdep.h

@ -547,10 +547,6 @@ static inline void qemu_timersub(const struct timeval *val1,
ssize_t qemu_write_full(int fd, const void *buf, size_t count)
G_GNUC_WARN_UNUSED_RESULT;
#ifndef _WIN32
int qemu_pipe(int pipefd[2]);
#endif
void qemu_set_cloexec(int fd);
/* Return a dynamically allocated directory path that is appropriate for storing

5
qemu-nbd.c

@ -909,13 +909,14 @@ int main(int argc, char **argv)
if ((device && !verbose) || fork_process) {
#ifndef WIN32
g_autoptr(GError) err = NULL;
int stderr_fd[2];
pid_t pid;
int ret;
if (qemu_pipe(stderr_fd) < 0) {
if (!g_unix_open_pipe(stderr_fd, FD_CLOEXEC, &err)) {
error_report("Error setting up communication pipe: %s",
strerror(errno));
err->message);
exit(EXIT_FAILURE);
}

2
util/event_notifier-posix.c

@ -49,7 +49,7 @@ int event_notifier_init(EventNotifier *e, int active)
if (errno != ENOSYS) {
return -errno;
}
if (qemu_pipe(fds) < 0) {
if (!g_unix_open_pipe(fds, FD_CLOEXEC, NULL)) {
return -errno;
}
if (!g_unix_set_fd_nonblocking(fds[0], true, NULL)) {

22
util/oslib-posix.c

@ -274,28 +274,6 @@ void qemu_set_cloexec(int fd)
assert(f != -1);
}
/*
* Creates a pipe with FD_CLOEXEC set on both file descriptors
*/
int qemu_pipe(int pipefd[2])
{
int ret;
#ifdef CONFIG_PIPE2
ret = pipe2(pipefd, O_CLOEXEC);
if (ret != -1 || errno != ENOSYS) {
return ret;
}
#endif
ret = pipe(pipefd);
if (ret == 0) {
qemu_set_cloexec(pipefd[0]);
qemu_set_cloexec(pipefd[1]);
}
return ret;
}
char *
qemu_get_local_state_dir(void)
{

Loading…
Cancel
Save