[Libguestfs] [PATCH 3/5] v2v: -i libvirtxml: Map empty network or bridge name to default (RHBZ#1257895).

Richard W.M. Jones rjones at redhat.com
Fri Aug 28 13:19:08 UTC 2015


As with the -i ova driver, if an unnamed network is found, map it to
"eth0", "eth1" etc.
---
 v2v/input_libvirtxml.ml | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/v2v/input_libvirtxml.ml b/v2v/input_libvirtxml.ml
index b464857..8c913a5 100644
--- a/v2v/input_libvirtxml.ml
+++ b/v2v/input_libvirtxml.ml
@@ -336,9 +336,7 @@ let parse_libvirt_xml ?conn xml =
       match vnet_type with
       | None -> ()
       | Some vnet_type ->
-        match xpath_string "source/@network | source/@bridge" with
-        | None -> ()
-        | Some vnet ->
+         let add_nic vnet =
            let nic = {
              s_mac = mac;
              s_vnet = vnet;
@@ -346,6 +344,16 @@ let parse_libvirt_xml ?conn xml =
              s_vnet_type = vnet_type
            } in
            nics := nic :: !nics
+         in
+         match xpath_string "source/@network | source/@bridge" with
+         | None -> ()
+         | Some "" ->
+            (* The libvirt VMware driver produces at least <source
+             * bridge=''/> XML - see RHBZ#1257895.
+             *)
+            add_nic (sprintf "eth%d" i)
+         | Some vnet ->
+            add_nic vnet
     done;
     List.rev !nics in
 
-- 
2.5.0




More information about the Libguestfs mailing list