On 02/11/2010 12:20 PM, Guido Günther wrote: > On Thu, Feb 11, 2010 at 12:05:06PM -0500, Cole Robinson wrote: >> I've got something working at the moment which basically passes a shell >> script as the 'ssh' command that tries to detect the nc -q option and >> use it if necc. Working on cleaning it up a bit. I'll post back here >> when the patch is in good shape, for further testing. > That sounds great! We have the same issue in libvirt though so in order > to make connecting work again we'll need something similar in libvirt. > It's slightly more trick since we share the same with trans_ext. > Cheers, > -- Guido >
Okay, I've attached the patch that seems to be working so far: connecting to fedora, rhel, and debian all work, no hanging nc instances (spawned by virt-manager at least). Probably only applies against upstream. I'll take a look at making a similar change in libvirt. Will also help to detect the nc '-U' option for libvirt which has been a user annoyance for quite a while.
diff -r dfcf2a86ca24 src/virtManager/console.py --- a/src/virtManager/console.py Thu Feb 11 15:25:41 2010 -0500 +++ b/src/virtManager/console.py Thu Feb 11 15:32:12 2010 -0500 @@ -503,7 +503,26 @@ argv += [ server ] # Build 'nc' command run on the remote host - nc_cmd = [ "nc", vncaddr, str(vncport) ] + # + # 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 VNC tunnel. If it doesn't go away, subsequent + # VNC connection attempts will hang. + # + # Fedora's 'nc' doesn't have this option, and apparently defaults + # to the desired behavior. + # + nc_params = "%s %s" % (vncaddr, str(vncport)) + nc_cmd = [\ + "nc -q 2>&1 | grep -q 'requires an argument';" + "if [ $? -eq 0 ] ; then" + " CMD='nc -q 0 %(nc_params)s';" + "else" + " CMD='nc %(nc_params)s';" + "fi;" + "$CMD;" % {'nc_params': nc_params} + ] argv += nc_cmd