vzmigrate: speed up by reusing ssh connection

Add option --ssh-mux that enables ssh connection multiplexing.

vzmigrate calls ssh a dozen or so times, each time establishing
a new connection. This is especially critical while a container
is frozen. Multiplexing subsequent ssh connections over a single
channel helps to eliminate those connection delays.

Surprizingly, it shaves off about half a second from the container
frozen time (and I guess about a second from vzmigrate execution time).
Surely YMMV, here's what I measured:

Without --ssh-mux:
        Suspend + Dump:   0.32
   Pcopy after suspend:   0.31
        Copy dump file:   0.64
       Undump + Resume:   0.57
                        ------
  Total suspended time:   1.84

With --ssh-mux:
        Suspend + Dump:   0.34
   Pcopy after suspend:   0.31
        Copy dump file:   0.48
       Undump + Resume:   0.25
                        ------
  Total suspended time:   1.38

Unfortunately, in OpenSSH 5.3 which is available on RHEL/CentOS 6
this is implemented rather ugly (ControlPersist only appears in 5.6),
so we have to do some trickery -- run 'sleep 3600' for the first
session, redirecting ssh input and output to /dev/null.

TODO: document, enable by default

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
1 file changed