[Libguestfs] [PATCH] v2v: -i vmx: Use scp -T option if available to unbreak scp (RHBZ#1733168).

Richard W.M. Jones rjones at redhat.com
Thu Jul 25 14:01:59 UTC 2019


Tested using:

cd v2v
LIBGUESTFS_BACKEND=direct ../run virt-v2v -i vmx -it ssh "ssh://localhost/$PWD/test-v2v-i-vmx-1.vmx" -o null -v -x

and manually examining the debug output.

Thanks: Ming Xie, Jakub Jelen.
---
 v2v/input_vmx.ml | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/v2v/input_vmx.ml b/v2v/input_vmx.ml
index 5441bccb9..4a82a867f 100644
--- a/v2v/input_vmx.ml
+++ b/v2v/input_vmx.ml
@@ -61,6 +61,13 @@ let server_of_uri { Xml.uri_server } =
 let path_of_uri { Xml.uri_path } =
   match uri_path with None -> assert false | Some p -> p
 
+let scp_supports_T_option = lazy (
+  let cmd = "LANG=C scp -T |& grep \"unknown option\"" in
+  if verbose () then
+    eprintf "%s\n%!" cmd;
+  Sys.command cmd <> 0
+)
+
 (* 'scp' a remote file into a temporary local file, returning the path
  * of the temporary local file.
  *)
@@ -68,8 +75,9 @@ let scp_from_remote_to_temporary uri tmpdir filename =
   let localfile = tmpdir // filename in
 
   let cmd =
-    sprintf "scp%s%s %s%s:%s %s"
+    sprintf "scp%s%s%s %s%s:%s %s"
             (if verbose () then "" else " -q")
+            (if Lazy.force scp_supports_T_option then " -T" else "")
             (match port_of_uri uri with
              | None -> ""
              | Some port -> sprintf " -P %d" port)
-- 
2.22.0




More information about the Libguestfs mailing list