[Libguestfs] [PATCH] v2v: Fix parsing of OVA files and documentation for --network and --bridge (RHBZ#1559027).

Richard W.M. Jones rjones at redhat.com
Thu Mar 22 16:05:27 UTC 2018


When parsing OVA files we have to work backwards to whether the
original VMware object was a network or a bridge.  It seems as if the
presence of <rasd:Connection> is sufficient.  I dropped the use of
<rasd:ElementName> since it is literally just an internal name for the
network element, and is not significant in how the network is used.

Also update documentation because you must use ‘--bridge’ when
converting VMware guests to RHV.

For a full explanation see:

  https://bugzilla.redhat.com/show_bug.cgi?id=1559027#c2
---
 v2v/parse_ovf_from_ova.ml |  9 +++++----
 v2v/virt-v2v.pod          | 31 +++++++++++++------------------
 2 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/v2v/parse_ovf_from_ova.ml b/v2v/parse_ovf_from_ova.ml
index d8de0cea1..82d7adf8c 100644
--- a/v2v/parse_ovf_from_ova.ml
+++ b/v2v/parse_ovf_from_ova.ml
@@ -230,16 +230,17 @@ let parse_ovf_from_ova ovf_filename =
     for i = 0 to nr_nodes-1 do
       let n = Xml.xpathobj_node obj i in
       Xml.xpathctx_set_current_context xpathctx n;
-      let vnet =
-        Option.default (sprintf"eth%d" i)
-                       (xpath_string "rasd:ElementName/text()") in
+      let vnet, vnet_type =
+        match xpath_string "rasd:Connection/text()" with
+        | Some connection -> connection, Bridge
+        | None -> sprintf"eth%d" i, Network in
       let mac = xpath_string "rasd:Address/text()" in
       let nic = {
         s_mac = mac;
         s_nic_model = None;
         s_vnet = vnet;
         s_vnet_orig = vnet;
-        s_vnet_type = Network;
+        s_vnet_type = vnet_type;
       } in
       List.push_front nic nics
     done;
diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod
index caf9c983e..097bab453 100644
--- a/v2v/virt-v2v.pod
+++ b/v2v/virt-v2v.pod
@@ -16,7 +16,7 @@ virt-v2v - Convert a guest to use KVM
    -o rhv-upload -oc https://ovirt-engine.example.com/ovirt-engine/api \
    -os ovirt-data -op /tmp/ovirt-admin-password \
    -oo rhv-cafile=/tmp/ca.pem -oo rhv-direct \
-   --network ovirtmgmt
+   --bridge ovirtmgmt
 
  virt-v2v -ic qemu:///system qemu_guest --in-place
 
@@ -62,7 +62,7 @@ interface(s) are connected to the target network called C<ovirtmgmt>.
    -o rhv-upload -oc https://ovirt-engine.example.com/ovirt-engine/api \
    -os ovirt-data -op /tmp/ovirt-admin-password \
    -oo rhv-cafile=/tmp/ca.pem -oo rhv-direct \
-   --network ovirtmgmt
+   --bridge ovirtmgmt
 
 In this case the host running virt-v2v acts as a B<conversion server>.
 
@@ -1134,27 +1134,22 @@ guest’s Network Interface Cards (NICs):
  NICs:
      Network "default" mac: 52:54:00:d0:cf:0e
 
-This is typical of a libvirt guest: It has a single network interface
-connected to a network called C<default>.
-
-To map a specific network to a target network, for example C<default>
-on the source to C<ovirtmgmt> on the target, use:
-
- virt-v2v [...] --network default:ovirtmgmt
-
-To map every network to a target network, use:
-
- virt-v2v [...] --network ovirtmgmt
-
-Bridges are handled in the same way, but you have to use the
-I<--bridge> option instead.  For example:
+Bridges are special classes of network devices which are attached to a
+named external network on the source hypervisor, for example:
 
  $ virt-v2v [-i ...] --print-source name
  [...]
  NICs:
      Bridge "br0"
- 
- $ virt-v2v [...] --bridge br0:targetbr
+
+To map a specific bridge to a target network, for example C<br0> on
+the source to C<ovirtmgmt> on the target, use:
+
+ virt-v2v [...] --bridge br0:ovirtmgmt
+
+To map every bridge to a target network, use:
+
+ virt-v2v [...] --bridge ovirtmgmt
 
 =head1 INPUT FROM VMWARE VCENTER SERVER
 
-- 
2.13.2




More information about the Libguestfs mailing list