Message ID | 20220422083639.3156978-7-marcandre.lureau@redhat.com |
---|---|
State | New |
Headers | show |
Series | Misc cleanups | expand |
On Fri, Apr 22, 2022 at 12:36:35PM +0400, marcandre.lureau@redhat.com wrote: > 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> > --- > 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(-) There are a bunch of places still using 'pipe'instead of 'qemu_pipe' that should be switched also. With regards, Daniel
Hi On Fri, Apr 22, 2022 at 1:00 PM Daniel P. Berrangé <berrange@redhat.com> wrote: > > On Fri, Apr 22, 2022 at 12:36:35PM +0400, marcandre.lureau@redhat.com wrote: > > 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> > > --- > > 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(-) > > There are a bunch of places still using 'pipe'instead of 'qemu_pipe' > that should be switched also. > Ok, that would be a different patch though. Can you ack this one for now? > > With regards, > Daniel > -- > |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| > |: https://libvirt.org -o- https://fstop138.berrange.com :| > |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| >
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 220b44f710e5..241d249d7e5b 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); void fips_set_state(bool requested); diff --git a/qemu-nbd.c b/qemu-nbd.c index 397ffa64d768..a184c6b9992f 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -902,13 +902,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 8dc30c51414d..df21c2583e1f 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; } ret = fcntl_setfl(fds[0], O_NONBLOCK); diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 03d97741562c..543c9944b083 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) {