From patchwork Thu Feb 7 14:03:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 10801321 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EB7AE1390 for ; Thu, 7 Feb 2019 14:14:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6FE62DA32 for ; Thu, 7 Feb 2019 14:14:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D305C2DA34; Thu, 7 Feb 2019 14:14:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 39E032DA2A for ; Thu, 7 Feb 2019 14:14:32 +0000 (UTC) Received: from localhost ([127.0.0.1]:40725 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grkRj-0002Sr-Sf for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Feb 2019 09:14:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grkHY-0002Ba-S5 for qemu-devel@nongnu.org; Thu, 07 Feb 2019 09:04:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1grkHS-00010G-07 for qemu-devel@nongnu.org; Thu, 07 Feb 2019 09:04:00 -0500 Received: from hera.aquilenet.fr ([185.233.100.1]:41898) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grkHR-0000ya-1U for qemu-devel@nongnu.org; Thu, 07 Feb 2019 09:03:53 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id C3B24CD34; Thu, 7 Feb 2019 15:03:36 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr 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 joyuvxcg6ZbX; Thu, 7 Feb 2019 15:03:36 +0100 (CET) Received: from function (unknown [160.40.205.85]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 830E1CD38; Thu, 7 Feb 2019 15:03:20 +0100 (CET) Received: from samy by function with local (Exim 4.92-RC4) (envelope-from ) id 1grkGr-0004Dw-W3; Thu, 07 Feb 2019 15:03:17 +0100 From: Samuel Thibault To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Thu, 7 Feb 2019 16:03:08 +0200 Message-Id: <20190207140316.16103-25-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190207140316.16103-1-samuel.thibault@ens-lyon.org> References: <20190207140316.16103-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 185.233.100.1 Subject: [Qemu-devel] [PULLv4 24/32] 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 , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , stefanha@redhat.com, jan.kiszka@siemens.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Only slirp actually needs it, and will need it along in libslirp. Signed-off-by: Samuel Thibault Reviewed-by: Marc-André Lureau --- include/glib-compat.h | 57 --------------------------------------- slirp/misc.c | 62 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 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) -#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 = (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_fd, - error); -#else - QemuGSpawnFds setup = { - .child_setup = child_setup, - .user_data = user_data, - .stdin_fd = stdin_fd, - .stdout_fd = stdout_fd, - .stderr_fd = 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, err) \ - 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 a77cc34b30..ee77aff337 100644 --- a/slirp/misc.c +++ b/slirp/misc.c @@ -122,6 +122,68 @@ fork_exec_child_setup(gpointer data) #endif } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + +#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 = (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_fd, + error); +#else + SlirpGSpawnFds setup = { + .child_setup = child_setup, + .user_data = user_data, + .stdin_fd = stdin_fd, + .stdout_fd = stdout_fd, + .stderr_fd = 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, err) \ + g_spawn_async_with_fds_slirp(wd, argv, env, f, c, d, p, ifd, ofd, efd, err) + +#pragma GCC diagnostic pop + int fork_exec(struct socket *so, const char *ex) {