[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 07/23] Replace qemu_pipe() with g_unix_open_pipe()
From: |
marcandre . lureau |
Subject: |
[PULL 07/23] Replace qemu_pipe() with g_unix_open_pipe() |
Date: |
Tue, 3 May 2022 17:00:07 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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>
---
include/qemu/osdep.h | 4 ----
qemu-nbd.c | 5 +++--
util/event_notifier-posix.c | 2 +-
util/oslib-posix.c | 22 ----------------------
4 files changed, 4 insertions(+), 29 deletions(-)
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 52d81c027ba0..1c1e7eca9898 100644
--- a/include/qemu/osdep.h
+++ b/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
diff --git a/qemu-nbd.c b/qemu-nbd.c
index db63980df1e4..2382b5042adf 100644
--- a/qemu-nbd.c
+++ b/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);
}
diff --git a/util/event_notifier-posix.c b/util/event_notifier-posix.c
index 2aa14eabb38e..76420c5b560c 100644
--- a/util/event_notifier-posix.c
+++ b/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)) {
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 289efca3fae1..2a6f6248ad03 100644
--- a/util/oslib-posix.c
+++ b/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)
{
--
2.36.0.44.g0f828332d5ac
- [PULL 22/23] tests: replace qemu_set_nonblock(), (continued)
- [PULL 22/23] tests: replace qemu_set_nonblock(), marcandre . lureau, 2022/05/03
- [PULL 14/23] Replace fcntl(O_NONBLOCK) with g_unix_set_fd_nonblocking(), marcandre . lureau, 2022/05/03
- [PULL 04/23] libqtest: split QMP part in libqmp, marcandre . lureau, 2022/05/03
- [PULL 13/23] io: replace pipe() with g_unix_open_pipe(CLOEXEC), marcandre . lureau, 2022/05/03
- [PULL 08/23] util: replace pipe()+cloexec with g_unix_open_pipe(), marcandre . lureau, 2022/05/03
- [PULL 05/23] Use g_unix_set_fd_nonblocking(), marcandre . lureau, 2022/05/03
- [PULL 02/23] Use QEMU_SANITIZE_ADDRESS, marcandre . lureau, 2022/05/03
- [PULL 12/23] virtiofsd: replace pipe() with g_unix_open_pipe(CLOEXEC), marcandre . lureau, 2022/05/03
- [PULL 10/23] tests: replace pipe() with g_unix_open_pipe(CLOEXEC), marcandre . lureau, 2022/05/03
- [PULL 01/23] Use QEMU_SANITIZE_THREAD, marcandre . lureau, 2022/05/03
- [PULL 07/23] Replace qemu_pipe() with g_unix_open_pipe(),
marcandre . lureau <=
- [PULL 19/23] hw: replace qemu_set_nonblock(), marcandre . lureau, 2022/05/03
- [PULL 06/23] block: move fcntl_setfl(), marcandre . lureau, 2022/05/03
- [PULL 09/23] qga: replace pipe() with g_unix_open_pipe(CLOEXEC), marcandre . lureau, 2022/05/03
- [PULL 20/23] ui: replace qemu_set_nonblock(), marcandre . lureau, 2022/05/03
- [PULL 03/23] tests: move libqtest.h back under qtest/, marcandre . lureau, 2022/05/03
- [PULL 17/23] io: replace qemu_set{_non}block(), marcandre . lureau, 2022/05/03
- [PULL 23/23] util: rename qemu_*block() socket functions, marcandre . lureau, 2022/05/03
- [PULL 21/23] net: replace qemu_set_nonblock(), marcandre . lureau, 2022/05/03
- [PULL 18/23] qga: replace qemu_set_nonblock(), marcandre . lureau, 2022/05/03
- [PULL 15/23] io: make qio_channel_command_new_pid() static, marcandre . lureau, 2022/05/03