Blame SOURCES/0002-i-libvirt-print-URI-without-connecting-RHBZ-1839917.patch

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