[PATCH virt-viewer] replace nc with socat

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list




[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux