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

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.
(cherry picked from commit 7692c31494)
This commit is contained in:
Richard W.M. Jones
2019-07-25 14:52:42 +01:00
committed by Pino Toscano
parent c7942097bf
commit 06e5cfb90b

View File

@@ -61,6 +61,11 @@ 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
shell_command cmd <> 0
)
(* 'scp' a remote file into a temporary local file, returning the path
* of the temporary local file.
*)
@@ -68,8 +73,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)