From: Samuel Thibault <samuel.thibault@gnu.org>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org, Jan Kiszka <jan.kiszka@siemens.com>,
Jason Wang <jasowang@redhat.com>
Subject: Re: [Qemu-devel] [PATCH for-3.2 02/13] slirp: remove do_pty from fork_exec()
Date: Sat, 10 Nov 2018 15:21:10 +0100 [thread overview]
Message-ID: <20181110142110.ric56fw4dpsd22xq@function> (raw)
In-Reply-To: <20181110134548.14741-3-marcandre.lureau@redhat.com>
Marc-André Lureau, le sam. 10 nov. 2018 17:45:37 +0400, a ecrit:
> QEMU uses fork_exec() with do_pty values 0 or 3.
> Let's clean up some unused code.
Applied to my tree, thanks!
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> slirp/misc.h | 2 +-
> slirp/misc.c | 55 ++++++++++++++----------------------------------
> slirp/tcp_subr.c | 2 +-
> 3 files changed, 18 insertions(+), 41 deletions(-)
>
> diff --git a/slirp/misc.h b/slirp/misc.h
> index 5211bbd30a..897650aea1 100644
> --- a/slirp/misc.h
> +++ b/slirp/misc.h
> @@ -53,6 +53,6 @@ struct slirp_quehead {
> void slirp_insque(void *, void *);
> void slirp_remque(void *);
> int add_exec(struct ex_list **, int, char *, struct in_addr, int);
> -int fork_exec(struct socket *so, const char *ex, int do_pty);
> +int fork_exec(struct socket *so, const char *ex);
>
> #endif
> diff --git a/slirp/misc.c b/slirp/misc.c
> index 260187b6b6..ec5d5ec073 100644
> --- a/slirp/misc.c
> +++ b/slirp/misc.c
> @@ -63,7 +63,7 @@ int add_exec(struct ex_list **ex_ptr, int do_pty, char *exec,
> #ifdef _WIN32
>
> int
> -fork_exec(struct socket *so, const char *ex, int do_pty)
> +fork_exec(struct socket *so, const char *ex)
> {
> /* not implemented */
> return 0;
> @@ -77,13 +77,9 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
> * process, which connects to this socket, after which we
> * exec the wanted program. If something (strange) happens,
> * the accept() call could block us forever.
> - *
> - * do_pty = 0 Fork/exec inetd style
> - * do_pty = 1 Fork/exec using slirp.telnetd
> - * do_ptr = 2 Fork/exec using pty
> */
> int
> -fork_exec(struct socket *so, const char *ex, int do_pty)
> +fork_exec(struct socket *so, const char *ex)
> {
> int s;
> struct sockaddr_in addr;
> @@ -99,26 +95,20 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
> DEBUG_CALL("fork_exec");
> DEBUG_ARG("so = %p", so);
> DEBUG_ARG("ex = %p", ex);
> - DEBUG_ARG("do_pty = %x", do_pty);
> -
> - if (do_pty == 2) {
> - return 0;
> - } else {
> - addr.sin_family = AF_INET;
> - addr.sin_port = 0;
> - addr.sin_addr.s_addr = INADDR_ANY;
>
> - if ((s = qemu_socket(AF_INET, SOCK_STREAM, 0)) < 0 ||
> - bind(s, (struct sockaddr *)&addr, addrlen) < 0 ||
> - listen(s, 1) < 0) {
> - error_report("Error: inet socket: %s", strerror(errno));
> - if (s >= 0) {
> - closesocket(s);
> - }
> + addr.sin_family = AF_INET;
> + addr.sin_port = 0;
> + addr.sin_addr.s_addr = INADDR_ANY;
>
> - return 0;
> - }
> - }
> + s = qemu_socket(AF_INET, SOCK_STREAM, 0);
> + if (s < 0 || bind(s, (struct sockaddr *)&addr, addrlen) < 0 ||
> + listen(s, 1) < 0) {
> + error_report("Error: inet socket: %s", strerror(errno));
> + if (s >= 0) {
> + closesocket(s);
> + }
> + return 0;
> + }
>
> pid = fork();
> switch(pid) {
> @@ -151,13 +141,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
>
> i = 0;
> bptr = g_strdup(ex); /* No need to free() this */
> - if (do_pty == 1) {
> - /* Setup "slirp.telnetd -x" */
> - argv[i++] = "slirp.telnetd";
> - argv[i++] = "-x";
> - argv[i++] = bptr;
> - } else
> - do {
> + do {
> /* Change the string into argv[] */
> curarg = bptr;
> while (*bptr != ' ' && *bptr != (char)0)
> @@ -165,7 +149,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
> c = *bptr;
> *bptr++ = (char)0;
> argv[i++] = g_strdup(curarg);
> - } while (c);
> + } while (c);
>
> argv[i] = NULL;
> execvp(argv[0], (char **)argv);
> @@ -193,13 +177,6 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
> opt = 1;
> qemu_setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));
> qemu_set_nonblock(so->s);
> -
> - /* Append the telnet options now */
> - if (so->so_m != NULL && do_pty == 1) {
> - sbappend(so, so->so_m);
> - so->so_m = NULL;
> - }
> -
> return 1;
> }
> }
> diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
> index 8d0f94b75f..a82efe78d7 100644
> --- a/slirp/tcp_subr.c
> +++ b/slirp/tcp_subr.c
> @@ -973,7 +973,7 @@ int tcp_ctl(struct socket *so)
> }
> do_pty = ex_ptr->ex_pty;
> DEBUG_MISC((dfd, " executing %s\n", ex_ptr->ex_exec));
> - return fork_exec(so, ex_ptr->ex_exec, do_pty);
> + return fork_exec(so, ex_ptr->ex_exec);
> }
> }
> }
> --
> 2.19.1.708.g4ede3d42df
>
--
Samuel
gawk; talk; nice; date; wine; grep; touch; unzip; strip; \
touch; gasp; finger; gasp; lyx; gasp; latex; mount; fsck; \
more; yes; gasp; umount; make clean; make mrproper; sleep
next prev parent reply other threads:[~2018-11-10 14:21 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-10 13:45 [Qemu-devel] [PATCH for-3.2 00/13] slirp: cleanups Marc-André Lureau
2018-11-10 13:45 ` [Qemu-devel] [PATCH for-3.2 01/13] slirp: associate slirp_output callback with the Slirp context Marc-André Lureau
2018-11-10 14:11 ` Samuel Thibault
2018-11-10 13:45 ` [Qemu-devel] [PATCH for-3.2 02/13] slirp: remove do_pty from fork_exec() Marc-André Lureau
2018-11-10 14:21 ` Samuel Thibault [this message]
2018-11-10 13:45 ` [Qemu-devel] [PATCH for-3.2 03/13] slirp: replace ex_pty with ex_chardev Marc-André Lureau
2018-11-10 14:26 ` Samuel Thibault
2018-11-10 13:45 ` [Qemu-devel] [PATCH for-3.2 04/13] slirp: use a dedicated field for chardev pointer Marc-André Lureau
2018-11-10 14:28 ` Samuel Thibault
2018-11-15 13:13 ` Paolo Bonzini
2018-11-10 13:45 ` [Qemu-devel] [PATCH for-3.2 05/13] slirp: remove unused EMU_RSH Marc-André Lureau
2018-11-10 14:30 ` Samuel Thibault
2018-11-15 13:15 ` Paolo Bonzini
2018-11-10 13:45 ` [Qemu-devel] [PATCH for-3.2 06/13] slirp: rename /extra/chardev Marc-André Lureau
2018-11-10 14:30 ` Samuel Thibault
2018-11-10 13:45 ` [Qemu-devel] [PATCH for-3.2 07/13] slirp: move internal function declarations Marc-André Lureau
2018-11-10 14:31 ` Samuel Thibault
2018-11-10 13:45 ` [Qemu-devel] [PATCH for-3.2 08/13] slirp: remove Monitor dependency, return a string for info Marc-André Lureau
2018-11-10 14:35 ` Samuel Thibault
2018-11-10 13:45 ` [Qemu-devel] [PATCH for-3.2 09/13] slirp: fix slirp_add_exec() leaks Marc-André Lureau
2018-11-10 14:37 ` Samuel Thibault
2018-11-10 13:45 ` [Qemu-devel] [PATCH for-3.2 10/13] slirp: improve subprocess socket creation Marc-André Lureau
2018-11-10 13:53 ` Samuel Thibault
2018-11-10 14:04 ` Peter Maydell
2018-11-10 14:07 ` Samuel Thibault
2018-11-10 13:45 ` [Qemu-devel] [PATCH for-3.2 11/13] slirp: replace the poor-man string split with g_strsplit() Marc-André Lureau
2018-11-10 14:42 ` Samuel Thibault
2018-11-10 13:45 ` [Qemu-devel] [PATCH for-3.2 12/13] glib-compat: add g_spawn_async_with_fds() fallback Marc-André Lureau
2018-11-10 13:45 ` [Qemu-devel] [PATCH for-3.2 13/13] slirp: simplify fork_exec() Marc-André Lureau
2018-11-10 13:54 ` Samuel Thibault
2018-11-10 20:19 ` [Qemu-devel] [PATCH for-3.2 00/13] slirp: cleanups no-reply
2018-11-10 20:48 ` no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181110142110.ric56fw4dpsd22xq@function \
--to=samuel.thibault@gnu.org \
--cc=jan.kiszka@siemens.com \
--cc=jasowang@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.