On Friday, 13 October 2017 18:27:21 CEST Richard W.M. Jones wrote:
diff --git a/v2v/vCenter.ml b/v2v/vCenter.ml
index c96ebdb8b..8e0795c3c 100644
--- a/v2v/vCenter.ml
+++ b/v2v/vCenter.ml
@@ -33,6 +33,7 @@ type remote_resource = {
}
let source_re = PCRE.compile "^\\[(.*)\\] (.*)\\.vmdk$"
+let snapshot_re = PCRE.compile "^(.*)-\\d+(\\.vmdk)$"
let rec map_source ?readahead ?password dcPath uri scheme server path =
(* If no_verify=1 was passed in the libvirt URI, then we have to
@@ -45,7 +46,28 @@ let rec map_source ?readahead ?password dcPath uri scheme server path
=
(* XXX only works if the query string is not URI-quoted *)
String.find query "no_verify=1" = -1 in
- let https_url = get_https_url dcPath uri server path in
+ let https_url =
+ let https_url = get_https_url dcPath uri server path in
+ (* Check the URL exists. *)
+ let status, _, _ =
+ fetch_headers_from_url password scheme uri sslverify https_url in
+ (* If a disk is actually a snapshot image it will have '-00000n'
+ * appended to its name, e.g.:
+ * [yellow:storage1] RHEL4-X/RHEL4-X-000003.vmdk
+ * The flat storage is still called RHEL4-X-flat, however. If we got
+ * a 404 and the vmdk name looks like it might be a snapshot, try
+ * again without the snapshot suffix.
+ *)
+ if status = "404" && PCRE.matches snapshot_re path then (
+ let path = PCRE.sub 1 ^ PCRE.sub 2 in
+ get_https_url dcPath uri server path
+ )
IMHO snapshot_re is a bit too generic, and it matches also guests named
like "fedora-26" or so. If the '-00000n' suffix is always made by
6 digits, then maybe "^(.*)-\\d{6}(\\.vmdk)$" avoids a number of false
positives.
--
Pino Toscano