[virt-tools-list] [PATCH virt-viewer] replace nc with socat
Marc-André Lureau
marcandre.lureau at gmail.com
Tue Sep 2 15:32:45 UTC 2014
It turns out that nc does not leave on server disconnect, and there
doesn't seem to be any option to do that, leaving client open, and
a bunch of idle processes.
Replacing nc with socat solves that, client is disconnected when
the VM is shut down, when the sever connection is closed.
https://bugzilla.redhat.com/show_bug.cgi?id=1030487
---
src/virt-viewer-app.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index b60ce2d..971a5fe 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -626,6 +626,7 @@ virt_viewer_app_open_tunnel_ssh(const char *sshhost,
{
const char *cmd[10];
char portstr[50];
+ gchar *dst;
int n = 0;
cmd[n++] = "ssh";
@@ -639,17 +640,21 @@ virt_viewer_app_open_tunnel_ssh(const char *sshhost,
cmd[n++] = sshuser;
}
cmd[n++] = sshhost;
- cmd[n++] = "nc";
- if (port) {
- cmd[n++] = host;
- cmd[n++] = port;
- } else {
- cmd[n++] = "-U";
- cmd[n++] = unixsock;
- }
+
+ cmd[n++] = "socat";
+ cmd[n++] = "-";
+ if (port)
+ dst = g_strdup_printf("TCP:%s:%s", host, port);
+ else
+ dst = g_strdup_printf("UNIX-CONNECT:%s", unixsock);
+
+ cmd[n++] = dst;
cmd[n++] = NULL;
- return virt_viewer_app_open_tunnel(cmd);
+ n = virt_viewer_app_open_tunnel(cmd);
+ g_free(dst);
+
+ return n;
}
static int
--
1.9.3
More information about the virt-tools-list
mailing list