From 6ee7781d8464dc3298b1157389df9785e20ce041 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Fri, 11 May 2018 23:54:05 +0200 Subject: slirp: clean up guestfwd command execution The previous guestfwd command execution functionality created a TCP socket for communication with the child. Besides being convoluted, this also had a practical performance issue: communications with the child process (e.g. netcat) could stall for 40ms due to delayed ack. As fork_exec has a lot of cruft (unused telnetd/pty code, whitespace issues, racy connect/accept logic) and a buffer overflow while building argv in the child ("guestfwd=tcp:0.0.0.0:80-cmd:$(printf %300s)"), just rewrite the whole thing to use socketpair with a local socket. Tested with a Windows 7 guest, using guestfwd (+netcat) to connect to a SMB server. Executing an installer from the share now does not take ages and a packet capture shows no 40ms latency in the guest. Signed-off-by: Peter Wu --- slirp/misc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'slirp/misc.h') diff --git a/slirp/misc.h b/slirp/misc.h index 26f3f69a8a..457ba5a97d 100644 --- a/slirp/misc.h +++ b/slirp/misc.h @@ -9,7 +9,7 @@ #define MISC_H struct ex_list { - int ex_pty; /* Do we want a pty? */ + int ex_pty; /* 0 for chardev, 3 for command */ struct in_addr ex_addr; /* Server address */ int ex_fport; /* Port to telnet to */ const char *ex_exec; /* Command line of what to exec */ @@ -54,6 +54,6 @@ void slirp_insque(void *, void *); void slirp_remque(void *); int add_exec(struct ex_list **, int, char *, struct in_addr, int); void slirp_destroy_exec_list(struct ex_list *exec_list); -int fork_exec(struct socket *so, const char *ex, int do_pty); +int fork_exec(struct socket *so, const char *command); #endif -- cgit v1.2.1