[Libguestfs] [PATCH 1/5] v2v: Remove --dcpath parameter and related functionality.

Pino Toscano ptoscano at redhat.com
Mon Oct 16 10:01:34 UTC 2017


On Friday, 13 October 2017 18:27:17 CEST Richard W.M. Jones wrote:
> diff --git a/v2v/copy_to_local.ml b/v2v/copy_to_local.ml
> index 8a64f3a58..63e1ea310 100644
> --- a/v2v/copy_to_local.ml
> +++ b/v2v/copy_to_local.ml
> @@ -245,8 +245,10 @@ and parse_libvirt_xml guest_name xml =
>                          "vmware" "http://libvirt.org/schemas/domain/vmware/1.0";
>    let xpath_string = xpath_string xpathctx in
>  
> -  (* Get the dcpath, only present for libvirt >= 1.2.20 so use a
> -   * sensible default for older versions.
> +  (* Get the dcpath, present in libvirt >= 1.2.20.
> +   * XXX Unfortunately when testing virt-v2v-copy-to-local against a
> +   * local libvirt test XML file, we cannot pass in the vmware namespace.
> +   * So we must keep the default here until we can resolve that somehow.
>     *)
>    let dcpath =
>      Option.default "ha-datacenter"

An option here could be to make parse_libvirt_xml return the
"string option" for the dcpath (instead of string), and enforce it
it exists only when, in main, the disks are mapped for an ESXi source.

Something like the following patch on top of this:

diff --git a/v2v/copy_to_local.ml b/v2v/copy_to_local.ml
index f22e1cd86..58ef9d238 100644
--- a/v2v/copy_to_local.ml
+++ b/v2v/copy_to_local.ml
@@ -145,6 +145,11 @@ read the man page virt-v2v-copy-to-local(1).
   let disks =
     match source with
     | ESXi server ->
+       let dcpath =
+         match dcpath with
+         | Some dcpath -> dcpath
+         | None ->
+            error (f_"vcenter: <vmware:datacenterpath> was not found in the XML.  You need to upgrade to libvirt ≥ 1.2.20.") in
        List.map (
          fun (remote_disk, local_disk) ->
            let url, sslverify =
@@ -245,14 +250,8 @@ and parse_libvirt_xml guest_name xml =
                         "vmware" "http://libvirt.org/schemas/domain/vmware/1.0";
   let xpath_string = xpath_string xpathctx in
 
-  (* Get the dcpath, present in libvirt >= 1.2.20.
-   * XXX Unfortunately when testing virt-v2v-copy-to-local against a
-   * local libvirt test XML file, we cannot pass in the vmware namespace.
-   * So we must keep the default here until we can resolve that somehow.
-   *)
-  let dcpath =
-    Option.default "ha-datacenter"
-                   (xpath_string "/domain/vmware:datacenterpath") in
+  (* Get the dcpath, present in libvirt >= 1.2.20. *)
+  let dcpath = xpath_string "/domain/vmware:datacenterpath" in
 
   (* Parse the disks. *)
   let get_disks, add_disk =

-- 
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20171016/8766c664/attachment.sig>


More information about the Libguestfs mailing list