vzmigrate: move code around

No functional change, just making the next patch smaller.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
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>
vzmigrate: improve ssh mux master hack

The problem of running 'sleep 3600' as a command to execute by first
ssh session is that sleep stays after vzmigrate is finished, since
terminating ssh itself doesn't lead to terminating what it started
remotely, so that 'sleep 3600' exists on remote host for an hour.
While not a big problem per se, it looks ugly and will cause some
questions.

The other problem is, if vzmigrate will take longer than 1 hour
(say due to very long rsyncs), by the time we start doing live
migration the master ssh connection will break.

To fix both problems, change sleep to echo and sleep 5 wrapped
in an endless loop.

* echo is needed for it to fail once ssh connection is broken
  and stdout is closed, so the loop will be terminated
  (rather than hanging around for too long after vzmigrate
  finishes).

* sleep is needed to not have too much \n traffic

The only downside is every few seconds a useless \n is sent
from remote host to local /dev/null. Should not have any impact.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
vzmigrate(8), vzmigrate --help: document --ssh-mux

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