From nobody Sun May 5 02:13:05 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549204534599269.015501897313; Sun, 3 Feb 2019 06:35:34 -0800 (PST) Received: from localhost ([127.0.0.1]:56304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqIrm-0007fz-Nl for importer@patchew.org; Sun, 03 Feb 2019 09:35:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35558) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqIqD-0006hq-1m for qemu-devel@nongnu.org; Sun, 03 Feb 2019 09:33:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqIgz-0008Vt-F8 for qemu-devel@nongnu.org; Sun, 03 Feb 2019 09:24:18 -0500 Received: from hera.aquilenet.fr ([2a0c:e300::1]:52776) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gqIgz-0008PP-44 for qemu-devel@nongnu.org; Sun, 03 Feb 2019 09:24:17 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 18318B02B; Sun, 3 Feb 2019 15:24:04 +0100 (CET) Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9ReAYxE4jJe9; Sun, 3 Feb 2019 15:24:02 +0100 (CET) Received: from function (unknown [IPv6:2001:67c:1810:f051:9eb6:d0ff:fe88:c3c7]) by hera.aquilenet.fr (Postfix) with ESMTPSA id DC729B02A; Sun, 3 Feb 2019 15:24:01 +0100 (CET) Received: from samy by function with local (Exim 4.92-RC4) (envelope-from ) id 1gqIfC-0008PA-1X; Sun, 03 Feb 2019 15:22:26 +0100 X-Virus-Scanned: Debian amavisd-new at aquilenet.fr From: Samuel Thibault To: qemu-devel@nongnu.org, marcandre.lureau@redhat.com Date: Sun, 3 Feb 2019 15:22:25 +0100 Message-Id: <20190203142225.32268-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a0c:e300::1 Subject: [Qemu-devel] [PATCH] slirp: Move g_spawn_async_with_fds_qemu compatibility to slirp/ X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Thibault , stefanha@redhat.com, jan.kiszka@siemens.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Only slirp actually needs it, and will need it along in libslirp. Signed-off-by: Samuel Thibault Reviewed-by: Marc-Andr=C3=A9 Lureau --- include/glib-compat.h | 57 ------------------------------------------- slirp/misc.c | 57 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 57 deletions(-) diff --git a/include/glib-compat.h b/include/glib-compat.h index 8a078c5288..1291628e09 100644 --- a/include/glib-compat.h +++ b/include/glib-compat.h @@ -83,63 +83,6 @@ static inline gboolean g_strv_contains_qemu(const gchar = *const *strv, } #define g_strv_contains(a, b) g_strv_contains_qemu(a, b) =20 -#if !GLIB_CHECK_VERSION(2, 58, 0) -typedef struct QemuGSpawnFds { - GSpawnChildSetupFunc child_setup; - gpointer user_data; - gint stdin_fd; - gint stdout_fd; - gint stderr_fd; -} QemuGSpawnFds; - -static inline void -qemu_gspawn_fds_setup(gpointer user_data) -{ - QemuGSpawnFds *q =3D (QemuGSpawnFds *)user_data; - - dup2(q->stdin_fd, 0); - dup2(q->stdout_fd, 1); - dup2(q->stderr_fd, 2); - q->child_setup(q->user_data); -} -#endif - -static inline gboolean -g_spawn_async_with_fds_qemu(const gchar *working_directory, - gchar **argv, - gchar **envp, - GSpawnFlags flags, - GSpawnChildSetupFunc child_setup, - gpointer user_data, - GPid *child_pid, - gint stdin_fd, - gint stdout_fd, - gint stderr_fd, - GError **error) -{ -#if GLIB_CHECK_VERSION(2, 58, 0) - return g_spawn_async_with_fds(working_directory, argv, envp, flags, - child_setup, user_data, - child_pid, stdin_fd, stdout_fd, stderr_f= d, - error); -#else - QemuGSpawnFds setup =3D { - .child_setup =3D child_setup, - .user_data =3D user_data, - .stdin_fd =3D stdin_fd, - .stdout_fd =3D stdout_fd, - .stderr_fd =3D stderr_fd, - }; - - return g_spawn_async(working_directory, argv, envp, flags, - qemu_gspawn_fds_setup, &setup, - child_pid, error); -#endif -} - -#define g_spawn_async_with_fds(wd, argv, env, f, c, d, p, ifd, ofd, efd, e= rr) \ - g_spawn_async_with_fds_qemu(wd, argv, env, f, c, d, p, ifd, ofd, efd, = err) - #if defined(_WIN32) && !GLIB_CHECK_VERSION(2, 50, 0) /* * g_poll has a problem on Windows when using diff --git a/slirp/misc.c b/slirp/misc.c index edb0d187d7..18b25f93ac 100644 --- a/slirp/misc.c +++ b/slirp/misc.c @@ -120,6 +120,63 @@ fork_exec_child_setup(gpointer data) #endif } =20 +#if !GLIB_CHECK_VERSION(2, 58, 0) +typedef struct SlirpGSpawnFds { + GSpawnChildSetupFunc child_setup; + gpointer user_data; + gint stdin_fd; + gint stdout_fd; + gint stderr_fd; +} SlirpGSpawnFds; + +static inline void +slirp_gspawn_fds_setup(gpointer user_data) +{ + SlirpGSpawnFds *q =3D (SlirpGSpawnFds *)user_data; + + dup2(q->stdin_fd, 0); + dup2(q->stdout_fd, 1); + dup2(q->stderr_fd, 2); + q->child_setup(q->user_data); +} +#endif + +static inline gboolean +g_spawn_async_with_fds_slirp(const gchar *working_directory, + gchar **argv, + gchar **envp, + GSpawnFlags flags, + GSpawnChildSetupFunc child_setup, + gpointer user_data, + GPid *child_pid, + gint stdin_fd, + gint stdout_fd, + gint stderr_fd, + GError **error) +{ +#if GLIB_CHECK_VERSION(2, 58, 0) + return g_spawn_async_with_fds(working_directory, argv, envp, flags, + child_setup, user_data, + child_pid, stdin_fd, stdout_fd, stderr_f= d, + error); +#else + QemuGSpawnFds setup =3D { + .child_setup =3D child_setup, + .user_data =3D user_data, + .stdin_fd =3D stdin_fd, + .stdout_fd =3D stdout_fd, + .stderr_fd =3D stderr_fd, + }; + + return g_spawn_async(working_directory, argv, envp, flags, + slirp_gspawn_fds_setup, &setup, + child_pid, error); +#endif +} + +#define g_spawn_async_with_fds(wd, argv, env, f, c, d, p, ifd, ofd, efd, e= rr) \ + g_spawn_async_with_fds_slirp(wd, argv, env, f, c, d, p, ifd, ofd, efd,= err) + int fork_exec(struct socket *so, const char *ex) { --=20 2.20.1