diff options
author | Marc-André Lureau | 2018-11-10 14:45:39 +0100 |
---|---|---|
committer | Samuel Thibault | 2019-01-14 00:40:54 +0100 |
commit | 3ed9f823c688c0dd5dd8d2c936329168c4859d02 (patch) | |
tree | ecb05a808d31a1a7713257ddf5393a85430bbea4 /slirp | |
parent | slirp: replace ex_pty with ex_chardev (diff) | |
download | qemu-3ed9f823c688c0dd5dd8d2c936329168c4859d02.tar.gz qemu-3ed9f823c688c0dd5dd8d2c936329168c4859d02.tar.xz qemu-3ed9f823c688c0dd5dd8d2c936329168c4859d02.zip |
slirp: use a dedicated field for chardev pointer
Let's not mix command line and chardev pointers.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Diffstat (limited to 'slirp')
-rw-r--r-- | slirp/libslirp.h | 2 | ||||
-rw-r--r-- | slirp/misc.c | 11 | ||||
-rw-r--r-- | slirp/misc.h | 4 | ||||
-rw-r--r-- | slirp/slirp.c | 5 | ||||
-rw-r--r-- | slirp/tcp_subr.c | 2 |
5 files changed, 14 insertions, 10 deletions
diff --git a/slirp/libslirp.h b/slirp/libslirp.h index 52dbb9feb5..3e88dbaa01 100644 --- a/slirp/libslirp.h +++ b/slirp/libslirp.h @@ -35,7 +35,7 @@ int slirp_add_hostfwd(Slirp *slirp, int is_udp, struct in_addr guest_addr, int guest_port); int slirp_remove_hostfwd(Slirp *slirp, int is_udp, struct in_addr host_addr, int host_port); -int slirp_add_exec(Slirp *slirp, int do_pty, const void *args, +int slirp_add_exec(Slirp *slirp, void *chardev, const char *cmdline, struct in_addr *guest_addr, int guest_port); void slirp_connection_info(Slirp *slirp, Monitor *mon); diff --git a/slirp/misc.c b/slirp/misc.c index 8f0b6004bd..2784fc420f 100644 --- a/slirp/misc.c +++ b/slirp/misc.c @@ -37,7 +37,7 @@ remque(void *a) element->qh_rlink = NULL; } -int add_exec(struct ex_list **ex_ptr, int do_pty, char *exec, +int add_exec(struct ex_list **ex_ptr, void *chardev, const char *cmdline, struct in_addr addr, int port) { struct ex_list *tmp_ptr; @@ -50,11 +50,14 @@ int add_exec(struct ex_list **ex_ptr, int do_pty, char *exec, } tmp_ptr = *ex_ptr; - *ex_ptr = g_new(struct ex_list, 1); + *ex_ptr = g_new0(struct ex_list, 1); (*ex_ptr)->ex_fport = port; (*ex_ptr)->ex_addr = addr; - (*ex_ptr)->ex_chardev = do_pty == 3; - (*ex_ptr)->ex_exec = (do_pty == 3) ? exec : g_strdup(exec); + if (chardev) { + (*ex_ptr)->ex_chardev = chardev; + } else { + (*ex_ptr)->ex_exec = g_strdup(cmdline); + } (*ex_ptr)->ex_next = tmp_ptr; return 0; } diff --git a/slirp/misc.h b/slirp/misc.h index 1f8d11def6..64ca88c3b7 100644 --- a/slirp/misc.h +++ b/slirp/misc.h @@ -9,7 +9,7 @@ #define MISC_H struct ex_list { - int ex_chardev; + void *ex_chardev; struct in_addr ex_addr; /* Server address */ int ex_fport; /* Port to telnet to */ const char *ex_exec; /* Command line of what to exec */ @@ -52,7 +52,7 @@ 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 add_exec(struct ex_list **, void *, const char *, struct in_addr, int); int fork_exec(struct socket *so, const char *ex); #endif diff --git a/slirp/slirp.c b/slirp/slirp.c index 0498a092b9..0de46084c0 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -1068,7 +1068,7 @@ int slirp_add_hostfwd(Slirp *slirp, int is_udp, struct in_addr host_addr, return 0; } -int slirp_add_exec(Slirp *slirp, int do_pty, const void *args, +int slirp_add_exec(Slirp *slirp, void *chardev, const char *cmdline, struct in_addr *guest_addr, int guest_port) { if (!guest_addr->s_addr) { @@ -1081,7 +1081,8 @@ int slirp_add_exec(Slirp *slirp, int do_pty, const void *args, guest_addr->s_addr == slirp->vnameserver_addr.s_addr) { return -1; } - return add_exec(&slirp->exec_list, do_pty, (char *)args, *guest_addr, + + return add_exec(&slirp->exec_list, chardev, cmdline, *guest_addr, htons(guest_port)); } diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c index dc19eea55a..e7b2baa087 100644 --- a/slirp/tcp_subr.c +++ b/slirp/tcp_subr.c @@ -962,7 +962,7 @@ int tcp_ctl(struct socket *so) so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr) { if (ex_ptr->ex_chardev) { so->s = -1; - so->extra = (void *)ex_ptr->ex_exec; + so->extra = ex_ptr->ex_chardev; return 1; } DEBUG_MISC((dfd, " executing %s\n", ex_ptr->ex_exec)); |