Richard W.M. Jones
2019-Jul-25 14:01 UTC
[Libguestfs] [PATCH] 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.
---
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
Pino Toscano
2019-Aug-01 15:56 UTC
Re: [Libguestfs] [PATCH] v2v: -i vmx: Use scp -T option if available to unbreak scp (RHBZ#1733168).
On Thursday, 25 July 2019 16:01:59 CEST Richard W.M. Jones wrote:> 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. > ---This (the issue, and the solution) is rather ugly, although I do not see an easier solution than either a) switch to the sftp(1) utility (and thus switch from scp to sftp) b) use a ssh library (libssh) for fetching the vmx file So for now I'd say to go with this, with the following fixes:> +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 <> 0There is already Tools_utils.shell_command that does the 3 lines above. Also, the Lazy is not needed here, as the vmx file is downloaded using scp_from_remote_to_temporary only once. So I'd move the scp_supports_T_option helper within scp_from_remote_to_temporary. -- Pino Toscano
Maybe Matching Threads
- Re: [PATCH v2 2/2] v2v: -i vmx: Enhance VMX support with ability to use ‘-it ssh’ transport.
- [PATCH v2 2/2] v2v: -i vmx: Enhance VMX support with ability to use ‘-it ssh’ transport.
- Re: [PATCH] v2v: Preserve VM Generation ID (RHBZ#1598350).
- [PATCH] v2v: Preserve VM Generation ID (RHBZ#1598350).
- [PATCH] mllib: Bind %identity C primitive to Common_utils.identity.