|
|
ffd6ed |
From 6cf100edb097dda74619e65b50d312a9c5eb8d5d Mon Sep 17 00:00:00 2001
|
|
|
ffd6ed |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
ffd6ed |
Date: Thu, 10 Sep 2015 12:07:31 +0100
|
|
|
ffd6ed |
Subject: [PATCH] v2v: Add --dcpath parameter to allow dcPath to be overridden
|
|
|
ffd6ed |
(RHBZ#1256823).
|
|
|
ffd6ed |
|
|
|
ffd6ed |
It's currently impossible to correctly predict the dcPath parameter
|
|
|
ffd6ed |
from the data that libvirt gives us. So allow the user to override
|
|
|
ffd6ed |
--dcpath themselves.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
Eventually we will get better support in libvirt for this, and this
|
|
|
ffd6ed |
option will no longer be needed:
|
|
|
ffd6ed |
|
|
|
ffd6ed |
https://www.redhat.com/archives/libvir-list/2015-September/thread.html#00201
|
|
|
ffd6ed |
|
|
|
ffd6ed |
This enhances commit 51bc573d0c4e78104a682e7c42d63d701aedd093
|
|
|
ffd6ed |
and commit 20f1eb400b13be8733b6586769c4845b99a70722.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
(cherry picked from commit 0ed38550981fdde0a5fa5393b42b35c4131eea6f)
|
|
|
ffd6ed |
---
|
|
|
ffd6ed |
v2v/cmdline.ml | 8 +++++++-
|
|
|
ffd6ed |
v2v/input_libvirt.ml | 4 ++--
|
|
|
ffd6ed |
v2v/input_libvirt.mli | 4 ++--
|
|
|
ffd6ed |
v2v/input_libvirt_vcenter_https.ml | 22 ++++++++++++++++------
|
|
|
ffd6ed |
v2v/input_libvirt_vcenter_https.mli | 2 +-
|
|
|
ffd6ed |
v2v/virt-v2v.pod | 23 +++++++++++++----------
|
|
|
ffd6ed |
6 files changed, 41 insertions(+), 22 deletions(-)
|
|
|
ffd6ed |
|
|
|
ffd6ed |
diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml
|
|
|
ffd6ed |
index 30155a5..634d5ff 100644
|
|
|
ffd6ed |
--- a/v2v/cmdline.ml
|
|
|
ffd6ed |
+++ b/v2v/cmdline.ml
|
|
|
ffd6ed |
@@ -42,6 +42,7 @@ let parse_cmdline () =
|
|
|
ffd6ed |
let verbose = ref false in
|
|
|
ffd6ed |
let trace = ref false in
|
|
|
ffd6ed |
|
|
|
ffd6ed |
+ let dcpath = ref None in
|
|
|
ffd6ed |
let input_conn = ref None in
|
|
|
ffd6ed |
let input_format = ref None in
|
|
|
ffd6ed |
let output_conn = ref None in
|
|
|
ffd6ed |
@@ -155,6 +156,10 @@ let parse_cmdline () =
|
|
|
ffd6ed |
"-b", Arg.String add_bridge, "in:out " ^ s_"Map bridge 'in' to 'out'";
|
|
|
ffd6ed |
"--bridge", Arg.String add_bridge, "in:out " ^ ditto;
|
|
|
ffd6ed |
"--debug-gc",Arg.Set debug_gc, " " ^ s_"Debug GC and memory allocations";
|
|
|
ffd6ed |
+ "--dcpath", Arg.String (set_string_option_once "--dcpath" dcpath),
|
|
|
ffd6ed |
+ "path " ^ s_"Override dcPath (for vCenter)";
|
|
|
ffd6ed |
+ "--dcPath", Arg.String (set_string_option_once "--dcPath" dcpath),
|
|
|
ffd6ed |
+ "path " ^ ditto;
|
|
|
ffd6ed |
"--debug-overlay",Arg.Set debug_overlays,
|
|
|
ffd6ed |
" " ^ s_"Save overlay files";
|
|
|
ffd6ed |
"--debug-overlays",Arg.Set debug_overlays,
|
|
|
ffd6ed |
@@ -232,6 +237,7 @@ read the man page virt-v2v(1).
|
|
|
ffd6ed |
(* Dereference the arguments. *)
|
|
|
ffd6ed |
let args = List.rev !args in
|
|
|
ffd6ed |
let debug_gc = !debug_gc in
|
|
|
ffd6ed |
+ let dcpath = !dcpath in
|
|
|
ffd6ed |
let debug_overlays = !debug_overlays in
|
|
|
ffd6ed |
let do_copy = !do_copy in
|
|
|
ffd6ed |
let input_conn = !input_conn in
|
|
|
ffd6ed |
@@ -308,7 +314,7 @@ read the man page virt-v2v(1).
|
|
|
ffd6ed |
| [guest] -> guest
|
|
|
ffd6ed |
| _ ->
|
|
|
ffd6ed |
error (f_"expecting a libvirt guest name on the command line") in
|
|
|
ffd6ed |
- Input_libvirt.input_libvirt verbose password input_conn guest
|
|
|
ffd6ed |
+ Input_libvirt.input_libvirt verbose dcpath password input_conn guest
|
|
|
ffd6ed |
|
|
|
ffd6ed |
| `LibvirtXML ->
|
|
|
ffd6ed |
(* -i libvirtxml: Expecting a filename (XML file). *)
|
|
|
ffd6ed |
diff --git a/v2v/input_libvirt.ml b/v2v/input_libvirt.ml
|
|
|
ffd6ed |
index aff97ac..b27f0ab 100644
|
|
|
ffd6ed |
--- a/v2v/input_libvirt.ml
|
|
|
ffd6ed |
+++ b/v2v/input_libvirt.ml
|
|
|
ffd6ed |
@@ -27,7 +27,7 @@ open Types
|
|
|
ffd6ed |
open Utils
|
|
|
ffd6ed |
|
|
|
ffd6ed |
(* Choose the right subclass based on the URI. *)
|
|
|
ffd6ed |
-let input_libvirt verbose password libvirt_uri guest =
|
|
|
ffd6ed |
+let input_libvirt verbose dcpath password libvirt_uri guest =
|
|
|
ffd6ed |
match libvirt_uri with
|
|
|
ffd6ed |
| None ->
|
|
|
ffd6ed |
Input_libvirt_other.input_libvirt_other verbose password libvirt_uri guest
|
|
|
ffd6ed |
@@ -49,7 +49,7 @@ let input_libvirt verbose password libvirt_uri guest =
|
|
|
ffd6ed |
|
|
|
ffd6ed |
| Some server, Some ("esx"|"gsx"|"vpx" as scheme) -> (* vCenter over https *)
|
|
|
ffd6ed |
Input_libvirt_vcenter_https.input_libvirt_vcenter_https
|
|
|
ffd6ed |
- verbose password libvirt_uri parsed_uri scheme server guest
|
|
|
ffd6ed |
+ verbose dcpath password libvirt_uri parsed_uri scheme server guest
|
|
|
ffd6ed |
|
|
|
ffd6ed |
| Some server, Some ("xen+ssh" as scheme) -> (* Xen over SSH *)
|
|
|
ffd6ed |
Input_libvirt_xen_ssh.input_libvirt_xen_ssh
|
|
|
ffd6ed |
diff --git a/v2v/input_libvirt.mli b/v2v/input_libvirt.mli
|
|
|
ffd6ed |
index bdd40b6..b3df444 100644
|
|
|
ffd6ed |
--- a/v2v/input_libvirt.mli
|
|
|
ffd6ed |
+++ b/v2v/input_libvirt.mli
|
|
|
ffd6ed |
@@ -18,7 +18,7 @@
|
|
|
ffd6ed |
|
|
|
ffd6ed |
(** [-i libvirt] source. *)
|
|
|
ffd6ed |
|
|
|
ffd6ed |
-val input_libvirt : bool -> string option -> string option -> string -> Types.input
|
|
|
ffd6ed |
-(** [input_libvirt verbose password libvirt_uri guest] creates and returns a
|
|
|
ffd6ed |
+val input_libvirt : bool -> string option -> string option -> string option -> string -> Types.input
|
|
|
ffd6ed |
+(** [input_libvirt verbose dcpath password libvirt_uri guest] creates and returns a
|
|
|
ffd6ed |
new {!Types.input} object specialized for reading input from
|
|
|
ffd6ed |
libvirt sources. *)
|
|
|
ffd6ed |
diff --git a/v2v/input_libvirt_vcenter_https.ml b/v2v/input_libvirt_vcenter_https.ml
|
|
|
ffd6ed |
index dd02feb..684a7e4 100644
|
|
|
ffd6ed |
--- a/v2v/input_libvirt_vcenter_https.ml
|
|
|
ffd6ed |
+++ b/v2v/input_libvirt_vcenter_https.ml
|
|
|
ffd6ed |
@@ -110,7 +110,7 @@ let rec get_session_cookie =
|
|
|
ffd6ed |
|
|
|
ffd6ed |
if status = "404" then (
|
|
|
ffd6ed |
dump_response stderr;
|
|
|
ffd6ed |
- error (f_"vcenter: URL not found: %s") url
|
|
|
ffd6ed |
+ error (f_"vcenter: URL not found: %s\n\nThe '--dcpath' parameter may be useful. See the explanation in the virt-v2v(1) man page OPTIONS section.") url
|
|
|
ffd6ed |
);
|
|
|
ffd6ed |
|
|
|
ffd6ed |
if status <> "200" then (
|
|
|
ffd6ed |
@@ -235,7 +235,7 @@ let get_dcPath uri scheme =
|
|
|
ffd6ed |
*)
|
|
|
ffd6ed |
let source_re = Str.regexp "^\\[\\(.*\\)\\] \\(.*\\)\\.vmdk$"
|
|
|
ffd6ed |
|
|
|
ffd6ed |
-let map_source_to_uri ?readahead verbose password uri scheme server path =
|
|
|
ffd6ed |
+let map_source_to_uri ?readahead verbose dcPath password uri scheme server path =
|
|
|
ffd6ed |
if not (Str.string_match source_re path 0) then
|
|
|
ffd6ed |
path
|
|
|
ffd6ed |
else (
|
|
|
ffd6ed |
@@ -243,7 +243,17 @@ let map_source_to_uri ?readahead verbose password uri scheme server path =
|
|
|
ffd6ed |
and path = Str.matched_group 2 path in
|
|
|
ffd6ed |
|
|
|
ffd6ed |
(* Get the dcPath. *)
|
|
|
ffd6ed |
- let dcPath = get_dcPath uri scheme in
|
|
|
ffd6ed |
+ let dcPath =
|
|
|
ffd6ed |
+ match dcPath with
|
|
|
ffd6ed |
+ | None ->
|
|
|
ffd6ed |
+ let dcPath = get_dcPath uri scheme in
|
|
|
ffd6ed |
+ if verbose then
|
|
|
ffd6ed |
+ printf "vcenter: calculated dcPath as: %s\n" dcPath;
|
|
|
ffd6ed |
+ dcPath
|
|
|
ffd6ed |
+ | Some dcPath ->
|
|
|
ffd6ed |
+ if verbose then
|
|
|
ffd6ed |
+ printf "vcenter: using --dcpath from the command line: %s\n" dcPath;
|
|
|
ffd6ed |
+ dcPath in
|
|
|
ffd6ed |
|
|
|
ffd6ed |
let port =
|
|
|
ffd6ed |
match uri.uri_port with
|
|
|
ffd6ed |
@@ -307,7 +317,7 @@ let map_source_to_uri ?readahead verbose password uri scheme server path =
|
|
|
ffd6ed |
|
|
|
ffd6ed |
(* Subclass specialized for handling VMware vCenter over https. *)
|
|
|
ffd6ed |
class input_libvirt_vcenter_https
|
|
|
ffd6ed |
- verbose password libvirt_uri parsed_uri scheme server guest =
|
|
|
ffd6ed |
+ verbose dcPath password libvirt_uri parsed_uri scheme server guest =
|
|
|
ffd6ed |
object
|
|
|
ffd6ed |
inherit input_libvirt verbose password libvirt_uri guest
|
|
|
ffd6ed |
|
|
|
ffd6ed |
@@ -347,7 +357,7 @@ object
|
|
|
ffd6ed |
| { p_source_disk = disk; p_source = P_dont_rewrite } -> disk
|
|
|
ffd6ed |
| { p_source_disk = disk; p_source = P_source_file path } ->
|
|
|
ffd6ed |
let qemu_uri = map_source_to_uri ?readahead
|
|
|
ffd6ed |
- verbose password parsed_uri scheme server path in
|
|
|
ffd6ed |
+ verbose dcPath password parsed_uri scheme server path in
|
|
|
ffd6ed |
|
|
|
ffd6ed |
(* The libvirt ESX driver doesn't normally specify a format, but
|
|
|
ffd6ed |
* the format of the -flat file is *always* raw, so force it here.
|
|
|
ffd6ed |
@@ -368,7 +378,7 @@ object
|
|
|
ffd6ed |
let readahead = readahead_for_copying in
|
|
|
ffd6ed |
let backing_qemu_uri =
|
|
|
ffd6ed |
map_source_to_uri ?readahead
|
|
|
ffd6ed |
- verbose password parsed_uri scheme server orig_path in
|
|
|
ffd6ed |
+ verbose dcPath password parsed_uri scheme server orig_path in
|
|
|
ffd6ed |
|
|
|
ffd6ed |
(* Rebase the qcow2 overlay to adjust the readahead parameter. *)
|
|
|
ffd6ed |
let cmd =
|
|
|
ffd6ed |
diff --git a/v2v/input_libvirt_vcenter_https.mli b/v2v/input_libvirt_vcenter_https.mli
|
|
|
ffd6ed |
index 800c6ab..d6da89a 100644
|
|
|
ffd6ed |
--- a/v2v/input_libvirt_vcenter_https.mli
|
|
|
ffd6ed |
+++ b/v2v/input_libvirt_vcenter_https.mli
|
|
|
ffd6ed |
@@ -18,4 +18,4 @@
|
|
|
ffd6ed |
|
|
|
ffd6ed |
(** [-i libvirt] when the source is VMware vCenter *)
|
|
|
ffd6ed |
|
|
|
ffd6ed |
-val input_libvirt_vcenter_https : bool -> string option -> string option -> Xml.uri -> string -> string -> string -> Types.input
|
|
|
ffd6ed |
+val input_libvirt_vcenter_https : bool -> string option -> string option -> string option -> Xml.uri -> string -> string -> string -> Types.input
|
|
|
ffd6ed |
diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod
|
|
|
ffd6ed |
index eb7ee38..2e257de 100644
|
|
|
ffd6ed |
--- a/v2v/virt-v2v.pod
|
|
|
ffd6ed |
+++ b/v2v/virt-v2v.pod
|
|
|
ffd6ed |
@@ -153,6 +153,16 @@ Display help.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
See I<--network> below.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
+=item B<--dcpath> Folder/Datacenter
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
+For VMware vCenter, override the C<dcPath=...> parameter used to
|
|
|
ffd6ed |
+select the datacenter. Virt-v2v can usually calculate this from the
|
|
|
ffd6ed |
+C<vpx://> URI, but if it gets it wrong, then you can override it using
|
|
|
ffd6ed |
+this setting. Go to your vCenter web folder interface, eg.
|
|
|
ffd6ed |
+C<https://vcenter.example.com/folder> (I<without> a trailing slash),
|
|
|
ffd6ed |
+and examine the C<dcPath=> parameter in the URLs that appear on this
|
|
|
ffd6ed |
+page.
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
=item B<--debug-gc>
|
|
|
ffd6ed |
|
|
|
ffd6ed |
Debug garbage collection and memory allocation. This is only useful
|
|
|
ffd6ed |
@@ -835,18 +845,11 @@ added to the URI, eg:
|
|
|
ffd6ed |
|
|
|
ffd6ed |
vpx://user@server/Folder/Datacenter/esxi
|
|
|
ffd6ed |
|
|
|
ffd6ed |
-If the deployment uses a cluster before the hostname, then you
|
|
|
ffd6ed |
-may need to remove it, ie. change this:
|
|
|
ffd6ed |
-
|
|
|
ffd6ed |
- vpx://user@server/Folder/Datacenter/Cluster/esxi
|
|
|
ffd6ed |
-
|
|
|
ffd6ed |
-to this:
|
|
|
ffd6ed |
-
|
|
|
ffd6ed |
- vpx://user@server/Folder/Datacenter/esxi
|
|
|
ffd6ed |
-
|
|
|
ffd6ed |
Virt-v2v needs to calculate the C<dcPath> parameter from the URI, and
|
|
|
ffd6ed |
it does this by removing the final C</esxi> element, so in the above
|
|
|
ffd6ed |
-example C<dcPath=Folder/Datacenter>.
|
|
|
ffd6ed |
+example C<dcPath=Folder/Datacenter>. As it is not always possible to
|
|
|
ffd6ed |
+correctly calculate C<dcPath> from the URI, you can override this
|
|
|
ffd6ed |
+using the I<--dcpath> parameter.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
For full details of libvirt URIs, see: L<http://libvirt.org/drvesx.html>
|
|
|
ffd6ed |
|
|
|
ffd6ed |
--
|
|
|
ffd6ed |
1.8.3.1
|
|
|
ffd6ed |
|