Consolidate the libvirt XML serial code.

There were two places that we doing essentially the same
thing; consolidate them here.

Signed-off-by: Chris Lalancette <clalancette@gmail.com>
Do an up-front ssh check to make sure we can login.

On any OS with parallel startup, it could be the case that
the operating system sets an IP address and runs reportip
*before* ssh key generation has completed (or sshd has
started).  We don't generally see this problem, as I
think most of the time KVM is too fast, but it is a
problem in theory.  This commit tries to connect to the
guest several times with a dummy command just to ensure
the connection is up.  Once it is confirmed to be up,
the rest of the code runs.

Thanks to Geert Jansen for the heads up.

Signed-off-by: Chris Lalancette <clalancette@gmail.com>