Blame SOURCES/0018-v2v-i-vmx-Use-scp-T-option-if-available-to-unbreak-s.patch

46b2f6
From d74842f209b5461692a2d283d622157862bdc230 Mon Sep 17 00:00:00 2001
46b2f6
From: "Richard W.M. Jones" <rjones@redhat.com>
46b2f6
Date: Thu, 25 Jul 2019 14:52:42 +0100
46b2f6
Subject: [PATCH] v2v: -i vmx: Use scp -T option if available to unbreak scp
46b2f6
 (RHBZ#1733168).
46b2f6
46b2f6
Tested using:
46b2f6
46b2f6
cd v2v
46b2f6
LIBGUESTFS_BACKEND=direct ../run virt-v2v -i vmx -it ssh "ssh://localhost/$PWD/test-v2v-i-vmx-1.vmx" -o null -v -x
46b2f6
46b2f6
and manually examining the debug output.
46b2f6
46b2f6
Thanks: Ming Xie, Jakub Jelen.
46b2f6
(cherry picked from commit 7692c31494f7b1d37e380eed9eb99c5952940dbf)
46b2f6
---
46b2f6
 v2v/input_vmx.ml | 8 +++++++-
46b2f6
 1 file changed, 7 insertions(+), 1 deletion(-)
46b2f6
46b2f6
diff --git a/v2v/input_vmx.ml b/v2v/input_vmx.ml
46b2f6
index b169b2537..e3469308d 100644
46b2f6
--- a/v2v/input_vmx.ml
46b2f6
+++ b/v2v/input_vmx.ml
46b2f6
@@ -61,6 +61,11 @@ let server_of_uri { Xml.uri_server } =
46b2f6
 let path_of_uri { Xml.uri_path } =
46b2f6
   match uri_path with None -> assert false | Some p -> p
46b2f6
 
46b2f6
+let scp_supports_T_option = lazy (
46b2f6
+  let cmd = "LANG=C scp -T |& grep \"unknown option\"" in
46b2f6
+  shell_command cmd <> 0
46b2f6
+)
46b2f6
+
46b2f6
 (* 'scp' a remote file into a temporary local file, returning the path
46b2f6
  * of the temporary local file.
46b2f6
  *)
46b2f6
@@ -68,8 +73,9 @@ let scp_from_remote_to_temporary uri tmpdir filename =
46b2f6
   let localfile = tmpdir // filename in
46b2f6
 
46b2f6
   let cmd =
46b2f6
-    sprintf "scp%s%s %s%s:%s %s"
46b2f6
+    sprintf "scp%s%s%s %s%s:%s %s"
46b2f6
             (if verbose () then "" else " -q")
46b2f6
+            (if Lazy.force scp_supports_T_option then " -T" else "")
46b2f6
             (match port_of_uri uri with
46b2f6
              | None -> ""
46b2f6
              | Some port -> sprintf " -P %d" port)
46b2f6
-- 
b155d0
2.26.2
46b2f6