|
|
62f9b7 |
From e04f4d6aa0e94a61b40fa6b10a5274ea89cd96a1 Mon Sep 17 00:00:00 2001
|
|
|
62f9b7 |
From: Pino Toscano <ptoscano@redhat.com>
|
|
|
62f9b7 |
Date: Mon, 25 May 2020 16:52:07 +0200
|
|
|
62f9b7 |
Subject: [PATCH] -i libvirt: print URI without connecting (RHBZ#1839917)
|
|
|
62f9b7 |
|
|
|
62f9b7 |
Pass (again) around the libvirt URI string in the various input_libvirt
|
|
|
62f9b7 |
subclasses so that input_libvirt#as_options does not need to connect to
|
|
|
62f9b7 |
print the connection URI.
|
|
|
62f9b7 |
|
|
|
62f9b7 |
As related change: pass input_conn as non-optional string parameter in
|
|
|
62f9b7 |
classes that require one (all but input_libvirt_other, basically). This
|
|
|
62f9b7 |
avoids the need for extra checks.
|
|
|
62f9b7 |
|
|
|
62f9b7 |
(cherry picked from commit 86d87563ee03e86ca9abdcad4f674af66a883006)
|
|
|
62f9b7 |
---
|
|
|
62f9b7 |
v2v/input_libvirt.ml | 10 +++++-----
|
|
|
62f9b7 |
v2v/input_libvirt_other.ml | 12 ++++++++----
|
|
|
62f9b7 |
v2v/input_libvirt_other.mli | 4 ++--
|
|
|
62f9b7 |
v2v/input_libvirt_vcenter_https.ml | 4 ++--
|
|
|
62f9b7 |
v2v/input_libvirt_vcenter_https.mli | 2 +-
|
|
|
62f9b7 |
v2v/input_libvirt_vddk.ml | 9 ++-------
|
|
|
62f9b7 |
v2v/input_libvirt_vddk.mli | 4 ++--
|
|
|
62f9b7 |
v2v/input_libvirt_xen_ssh.ml | 4 ++--
|
|
|
62f9b7 |
v2v/input_libvirt_xen_ssh.mli | 2 +-
|
|
|
62f9b7 |
9 files changed, 25 insertions(+), 26 deletions(-)
|
|
|
62f9b7 |
|
|
|
62f9b7 |
diff --git a/v2v/input_libvirt.ml b/v2v/input_libvirt.ml
|
|
|
62f9b7 |
index cd5f351c..352fae94 100644
|
|
|
62f9b7 |
--- a/v2v/input_libvirt.ml
|
|
|
62f9b7 |
+++ b/v2v/input_libvirt.ml
|
|
|
62f9b7 |
@@ -53,22 +53,22 @@ let input_libvirt input_conn input_password input_transport guest =
|
|
|
62f9b7 |
|
|
|
62f9b7 |
| Some _, None, _ (* No scheme? *)
|
|
|
62f9b7 |
| Some _, Some "", _ ->
|
|
|
62f9b7 |
- Input_libvirt_other.input_libvirt_other libvirt_conn guest
|
|
|
62f9b7 |
+ Input_libvirt_other.input_libvirt_other libvirt_conn ?input_conn guest
|
|
|
62f9b7 |
|
|
|
62f9b7 |
(* vCenter over https. *)
|
|
|
62f9b7 |
| Some server, Some ("esx"|"gsx"|"vpx"), None ->
|
|
|
62f9b7 |
Input_libvirt_vcenter_https.input_libvirt_vcenter_https
|
|
|
62f9b7 |
- libvirt_conn input_password parsed_uri server guest
|
|
|
62f9b7 |
+ libvirt_conn orig_uri input_password parsed_uri server guest
|
|
|
62f9b7 |
|
|
|
62f9b7 |
(* vCenter or ESXi using nbdkit vddk plugin *)
|
|
|
62f9b7 |
| Some server, Some ("esx"|"gsx"|"vpx"), Some (`VDDK vddk_options) ->
|
|
|
62f9b7 |
Input_libvirt_vddk.input_libvirt_vddk
|
|
|
62f9b7 |
- libvirt_conn input_conn input_password vddk_options parsed_uri guest
|
|
|
62f9b7 |
+ libvirt_conn orig_uri input_password vddk_options parsed_uri guest
|
|
|
62f9b7 |
|
|
|
62f9b7 |
(* Xen over SSH *)
|
|
|
62f9b7 |
| Some server, Some "xen+ssh", _ ->
|
|
|
62f9b7 |
Input_libvirt_xen_ssh.input_libvirt_xen_ssh
|
|
|
62f9b7 |
- libvirt_conn input_password parsed_uri server guest
|
|
|
62f9b7 |
+ libvirt_conn orig_uri input_password parsed_uri server guest
|
|
|
62f9b7 |
|
|
|
62f9b7 |
(* Old virt-v2v also supported qemu+ssh://. However I am
|
|
|
62f9b7 |
* deliberately not supporting this in new virt-v2v. Don't
|
|
|
62f9b7 |
@@ -79,6 +79,6 @@ let input_libvirt input_conn input_password input_transport guest =
|
|
|
62f9b7 |
| Some _, Some _, _ ->
|
|
|
62f9b7 |
warning (f_"no support for remote libvirt connections to '-ic %s'. The conversion may fail when it tries to read the source disks.")
|
|
|
62f9b7 |
orig_uri;
|
|
|
62f9b7 |
- Input_libvirt_other.input_libvirt_other libvirt_conn guest
|
|
|
62f9b7 |
+ Input_libvirt_other.input_libvirt_other libvirt_conn ?input_conn guest
|
|
|
62f9b7 |
|
|
|
62f9b7 |
let () = Modules_list.register_input_module "libvirt"
|
|
|
62f9b7 |
diff --git a/v2v/input_libvirt_other.ml b/v2v/input_libvirt_other.ml
|
|
|
62f9b7 |
index e00944db..6a19ae52 100644
|
|
|
62f9b7 |
--- a/v2v/input_libvirt_other.ml
|
|
|
62f9b7 |
+++ b/v2v/input_libvirt_other.ml
|
|
|
62f9b7 |
@@ -40,12 +40,16 @@ let error_if_libvirt_does_not_support_json_backingfile () =
|
|
|
62f9b7 |
error (f_"because of libvirt bug https://bugzilla.redhat.com/1134878 you must EITHER upgrade to libvirt >= 2.1.0 OR set this environment variable:\n\nexport LIBGUESTFS_BACKEND=direct\n\nand then rerun the virt-v2v command.")
|
|
|
62f9b7 |
|
|
|
62f9b7 |
(* Superclass. *)
|
|
|
62f9b7 |
-class virtual input_libvirt libvirt_conn guest =
|
|
|
62f9b7 |
+class virtual input_libvirt libvirt_conn ?input_conn guest =
|
|
|
62f9b7 |
object (self)
|
|
|
62f9b7 |
inherit input
|
|
|
62f9b7 |
|
|
|
62f9b7 |
method as_options =
|
|
|
62f9b7 |
- sprintf "-i libvirt -ic %s %s" (Libvirt.Connect.get_uri self#conn) guest
|
|
|
62f9b7 |
+ sprintf "-i libvirt%s %s"
|
|
|
62f9b7 |
+ (match input_conn with
|
|
|
62f9b7 |
+ | None -> ""
|
|
|
62f9b7 |
+ | Some uri -> " -ic " ^ uri)
|
|
|
62f9b7 |
+ guest
|
|
|
62f9b7 |
|
|
|
62f9b7 |
method private conn : Libvirt.rw Libvirt.Connect.t =
|
|
|
62f9b7 |
Lazy.force libvirt_conn
|
|
|
62f9b7 |
@@ -54,9 +58,9 @@ end
|
|
|
62f9b7 |
(* Subclass specialized for handling anything that's *not* VMware vCenter
|
|
|
62f9b7 |
* or Xen.
|
|
|
62f9b7 |
*)
|
|
|
62f9b7 |
-class input_libvirt_other libvirt_conn guest =
|
|
|
62f9b7 |
+class input_libvirt_other libvirt_conn ?input_conn guest =
|
|
|
62f9b7 |
object (self)
|
|
|
62f9b7 |
- inherit input_libvirt libvirt_conn guest
|
|
|
62f9b7 |
+ inherit input_libvirt libvirt_conn ?input_conn guest
|
|
|
62f9b7 |
|
|
|
62f9b7 |
method source ?bandwidth () =
|
|
|
62f9b7 |
debug "input_libvirt_other: source ()";
|
|
|
62f9b7 |
diff --git a/v2v/input_libvirt_other.mli b/v2v/input_libvirt_other.mli
|
|
|
62f9b7 |
index c528c3ee..ae2c0c6d 100644
|
|
|
62f9b7 |
--- a/v2v/input_libvirt_other.mli
|
|
|
62f9b7 |
+++ b/v2v/input_libvirt_other.mli
|
|
|
62f9b7 |
@@ -20,11 +20,11 @@
|
|
|
62f9b7 |
|
|
|
62f9b7 |
val error_if_libvirt_does_not_support_json_backingfile : unit -> unit
|
|
|
62f9b7 |
|
|
|
62f9b7 |
-class virtual input_libvirt : Libvirt.rw Libvirt.Connect.t Lazy.t -> string -> object
|
|
|
62f9b7 |
+class virtual input_libvirt : Libvirt.rw Libvirt.Connect.t Lazy.t -> ?input_conn:string -> string -> object
|
|
|
62f9b7 |
method precheck : unit -> unit
|
|
|
62f9b7 |
method as_options : string
|
|
|
62f9b7 |
method virtual source : ?bandwidth:Types.bandwidth -> unit -> Types.source * Types.source_disk list
|
|
|
62f9b7 |
method private conn : Libvirt.rw Libvirt.Connect.t
|
|
|
62f9b7 |
end
|
|
|
62f9b7 |
|
|
|
62f9b7 |
-val input_libvirt_other : Libvirt.rw Libvirt.Connect.t Lazy.t -> string -> Types.input
|
|
|
62f9b7 |
+val input_libvirt_other : Libvirt.rw Libvirt.Connect.t Lazy.t -> ?input_conn:string -> string -> Types.input
|
|
|
62f9b7 |
diff --git a/v2v/input_libvirt_vcenter_https.ml b/v2v/input_libvirt_vcenter_https.ml
|
|
|
62f9b7 |
index 77bc315d..ed2e5eed 100644
|
|
|
62f9b7 |
--- a/v2v/input_libvirt_vcenter_https.ml
|
|
|
62f9b7 |
+++ b/v2v/input_libvirt_vcenter_https.ml
|
|
|
62f9b7 |
@@ -32,9 +32,9 @@ open Printf
|
|
|
62f9b7 |
|
|
|
62f9b7 |
(* Subclass specialized for handling VMware vCenter over https. *)
|
|
|
62f9b7 |
class input_libvirt_vcenter_https
|
|
|
62f9b7 |
- libvirt_conn input_password parsed_uri server guest =
|
|
|
62f9b7 |
+ libvirt_conn input_conn input_password parsed_uri server guest =
|
|
|
62f9b7 |
object (self)
|
|
|
62f9b7 |
- inherit input_libvirt libvirt_conn guest
|
|
|
62f9b7 |
+ inherit input_libvirt libvirt_conn ~input_conn guest
|
|
|
62f9b7 |
|
|
|
62f9b7 |
val mutable dcPath = ""
|
|
|
62f9b7 |
|
|
|
62f9b7 |
diff --git a/v2v/input_libvirt_vcenter_https.mli b/v2v/input_libvirt_vcenter_https.mli
|
|
|
62f9b7 |
index c2e0f3fe..a12a9815 100644
|
|
|
62f9b7 |
--- a/v2v/input_libvirt_vcenter_https.mli
|
|
|
62f9b7 |
+++ b/v2v/input_libvirt_vcenter_https.mli
|
|
|
62f9b7 |
@@ -18,4 +18,4 @@
|
|
|
62f9b7 |
|
|
|
62f9b7 |
(** [-i libvirt] when the source is VMware vCenter *)
|
|
|
62f9b7 |
|
|
|
62f9b7 |
-val input_libvirt_vcenter_https : Libvirt.rw Libvirt.Connect.t Lazy.t -> string option -> Xml.uri -> string -> string -> Types.input
|
|
|
62f9b7 |
+val input_libvirt_vcenter_https : Libvirt.rw Libvirt.Connect.t Lazy.t -> string -> string option -> Xml.uri -> string -> string -> Types.input
|
|
|
62f9b7 |
diff --git a/v2v/input_libvirt_vddk.ml b/v2v/input_libvirt_vddk.ml
|
|
|
62f9b7 |
index fbd1e0c6..75fd146e 100644
|
|
|
62f9b7 |
--- a/v2v/input_libvirt_vddk.ml
|
|
|
62f9b7 |
+++ b/v2v/input_libvirt_vddk.ml
|
|
|
62f9b7 |
@@ -99,7 +99,7 @@ class input_libvirt_vddk libvirt_conn input_conn input_password vddk_options
|
|
|
62f9b7 |
in
|
|
|
62f9b7 |
|
|
|
62f9b7 |
object (self)
|
|
|
62f9b7 |
- inherit input_libvirt libvirt_conn guest as super
|
|
|
62f9b7 |
+ inherit input_libvirt libvirt_conn ~input_conn guest as super
|
|
|
62f9b7 |
|
|
|
62f9b7 |
method precheck () =
|
|
|
62f9b7 |
error_unless_thumbprint ()
|
|
|
62f9b7 |
@@ -138,12 +138,7 @@ object (self)
|
|
|
62f9b7 |
match parsed_uri.Xml.uri_server with
|
|
|
62f9b7 |
| Some server -> server
|
|
|
62f9b7 |
| None ->
|
|
|
62f9b7 |
- match input_conn with
|
|
|
62f9b7 |
- | Some input_conn ->
|
|
|
62f9b7 |
- error (f_"‘-ic %s’ URL does not contain a host name field")
|
|
|
62f9b7 |
- input_conn
|
|
|
62f9b7 |
- | None ->
|
|
|
62f9b7 |
- error (f_"you must use the ‘-ic’ parameter. See the virt-v2v-input-vmware(1) manual.") in
|
|
|
62f9b7 |
+ error (f_"‘-ic %s’ URL does not contain a host name field") input_conn in
|
|
|
62f9b7 |
|
|
|
62f9b7 |
let user = parsed_uri.Xml.uri_user in
|
|
|
62f9b7 |
|
|
|
62f9b7 |
diff --git a/v2v/input_libvirt_vddk.mli b/v2v/input_libvirt_vddk.mli
|
|
|
62f9b7 |
index 2fc6e9cf..f37d88e7 100644
|
|
|
62f9b7 |
--- a/v2v/input_libvirt_vddk.mli
|
|
|
62f9b7 |
+++ b/v2v/input_libvirt_vddk.mli
|
|
|
62f9b7 |
@@ -25,7 +25,7 @@ val print_input_options : unit -> unit
|
|
|
62f9b7 |
val parse_input_options : (string * string) list -> vddk_options
|
|
|
62f9b7 |
(** Print and parse vddk -io options. *)
|
|
|
62f9b7 |
|
|
|
62f9b7 |
-val input_libvirt_vddk : Libvirt.rw Libvirt.Connect.t Lazy.t -> string option -> string option -> vddk_options -> Xml.uri -> string -> Types.input
|
|
|
62f9b7 |
-(** [input_libvirt_vddk libvirt_conn vddk_options parsed_uri guest]
|
|
|
62f9b7 |
+val input_libvirt_vddk : Libvirt.rw Libvirt.Connect.t Lazy.t -> string -> string option -> vddk_options -> Xml.uri -> string -> Types.input
|
|
|
62f9b7 |
+(** [input_libvirt_vddk libvirt_conn input_conn vddk_options parsed_uri guest]
|
|
|
62f9b7 |
creates and returns a {!Types.input} object specialized for reading
|
|
|
62f9b7 |
the guest disks using the nbdkit vddk plugin. *)
|
|
|
62f9b7 |
diff --git a/v2v/input_libvirt_xen_ssh.ml b/v2v/input_libvirt_xen_ssh.ml
|
|
|
62f9b7 |
index bd1235a6..ec366b4a 100644
|
|
|
62f9b7 |
--- a/v2v/input_libvirt_xen_ssh.ml
|
|
|
62f9b7 |
+++ b/v2v/input_libvirt_xen_ssh.ml
|
|
|
62f9b7 |
@@ -30,9 +30,9 @@ open Input_libvirt_other
|
|
|
62f9b7 |
open Printf
|
|
|
62f9b7 |
|
|
|
62f9b7 |
(* Subclass specialized for handling Xen over SSH. *)
|
|
|
62f9b7 |
-class input_libvirt_xen_ssh libvirt_conn input_password parsed_uri server guest =
|
|
|
62f9b7 |
+class input_libvirt_xen_ssh libvirt_conn input_conn input_password parsed_uri server guest =
|
|
|
62f9b7 |
object (self)
|
|
|
62f9b7 |
- inherit input_libvirt libvirt_conn guest
|
|
|
62f9b7 |
+ inherit input_libvirt libvirt_conn ~input_conn guest
|
|
|
62f9b7 |
|
|
|
62f9b7 |
method precheck () =
|
|
|
62f9b7 |
if backend_is_libvirt () then
|
|
|
62f9b7 |
diff --git a/v2v/input_libvirt_xen_ssh.mli b/v2v/input_libvirt_xen_ssh.mli
|
|
|
62f9b7 |
index 120a52f7..3cbca9d7 100644
|
|
|
62f9b7 |
--- a/v2v/input_libvirt_xen_ssh.mli
|
|
|
62f9b7 |
+++ b/v2v/input_libvirt_xen_ssh.mli
|
|
|
62f9b7 |
@@ -18,4 +18,4 @@
|
|
|
62f9b7 |
|
|
|
62f9b7 |
(** [-i libvirt] when the source is Xen *)
|
|
|
62f9b7 |
|
|
|
62f9b7 |
-val input_libvirt_xen_ssh : Libvirt.rw Libvirt.Connect.t Lazy.t -> string option -> Xml.uri -> string -> string -> Types.input
|
|
|
62f9b7 |
+val input_libvirt_xen_ssh : Libvirt.rw Libvirt.Connect.t Lazy.t -> string -> string option -> Xml.uri -> string -> string -> Types.input
|
|
|
62f9b7 |
--
|
|
|
0602f3 |
2.31.1
|
|
|
62f9b7 |
|