[virt-tools-list] [PATCH virt-viewer] replace nc with socat

Daniel P. Berrange berrange at redhat.com
Tue Sep 2 15:40:20 UTC 2014

On Tue, Sep 02, 2014 at 05:32:45PM +0200, Marc-André Lureau wrote:
> 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

Hmm, there's some talk in libvirt code about this kind of issue

     * This ugly thing is a shell script to detect availability of
     * the -q option for 'nc': debian and suse based distros need this
     * flag to ensure the remote nc will exit on EOF, so it will go away
     * when we close the connection tunnel. If it doesn't go away, subsequent
     * connection attempts will hang.
     * Fedora's 'nc' doesn't have this option, and defaults to the desired
     * behavior.
         "'if '%s' -q 2>&1 | grep \"requires an argument\" >/dev/null 2>&1; then "
         "else "
         "'%s' $ARG -U %s'",
         quoted, quoted, path);

but it looks like this is referring to the client end of the connection.
So possibly server side is handled differently.

The problem with just switching to 'socat' is that we don't have any
way to guarantee it is installed on the server that we're connecting
to.  With 'nc', the RPM containing the libvirt daemon will ensure the
nc RPM is installed. The same isn't true for socat and there's nothing
else we can rely on to pull it in indirectly. Adding a dep on socat
from virt-viewer RPM doesn't help since obviously virt-viewer is only
installed on the client, not the server.

So I don't think we can make this change to socat. Or at least if we
do, then we must make sure it silently falls back to 'nc' if socat
is not present.

|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

More information about the virt-tools-list mailing list