Use rsync for sendfile if possible.

From: Mandeep Singh Baines <msb@google.com>

Here is a small patch which reimplements SSHHOST.sendfile() using
rsync. By using rsync, installs are much faster, especially when 
there is an existing installation already present.

Here are some performance numbers for a two machine test with autotest
previously installed on the machines.

Using scp:

msb@victoria:/usr/local/autotest/server$ time (./autoserv -m caca21,caca17 samples/run_barriertest > /dev/null)

real    1m30.255s
user    0m3.220s
sys     0m0.925s

Using rsync:

msb@victoria:/usr/local/autotest/server$ time (./autoserv -m caca21,caca17 samples/run_barriertest > /dev/null)

real    0m8.032s
user    0m8.129s
sys     0m0.841s



git-svn-id: http://test.kernel.org/svn/autotest/trunk@629 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/server/hosts/ssh_host.py b/server/hosts/ssh_host.py
index 7f825d9..21dad1a 100644
--- a/server/hosts/ssh_host.py
+++ b/server/hosts/ssh_host.py
@@ -202,11 +202,18 @@
 				format_string= '"%s"'
 			entry= format_string % (utils.sh_escape(os.path.abspath(entry)),)
 			processed_source.append(entry)
-		
-		utils.run('scp -rpq %s %s@%s:"%s"' % (
-			" ".join(processed_source), self.user, self.hostname, 
-			utils.scp_remote_escape(dest)))
 
+		result= utils.run('ssh %s rsync -h' % self.hostname,
+			ignore_status=True)
+
+		if result.exit_status == 0:
+			utils.run('rsync --rsh=ssh -avz %s %s@%s:"%s"' % (
+				" ".join(processed_source), self.user,
+				self.hostname, utils.scp_remote_escape(dest)))
+		else:
+			utils.run('scp -rpq %s %s@%s:"%s"' % (
+				" ".join(processed_source), self.user,
+				self.hostname, utils.scp_remote_escape(dest)))
 
 	def get_tmp_dir(self):
 		"""