Blame SOURCES/0220-v2v-i-libvirtxml-Map-empty-network-or-bridge-name-to.patch

ffd6ed
From ba119f33fe23b5f0d3bbd9b4022dd4f36f4d61b4 Mon Sep 17 00:00:00 2001
ffd6ed
From: "Richard W.M. Jones" <rjones@redhat.com>
ffd6ed
Date: Fri, 28 Aug 2015 13:57:37 +0100
ffd6ed
Subject: [PATCH] v2v: -i libvirtxml: Map empty network or bridge name to
ffd6ed
 default (RHBZ#1257895).
ffd6ed
ffd6ed
As with the -i ova driver, if an unnamed network is found, map it to
ffd6ed
"eth0", "eth1" etc.
ffd6ed
ffd6ed
(cherry picked from commit 18b019e3dd808393cda510b6d80212ff5bdbed76)
ffd6ed
---
ffd6ed
 v2v/input_libvirtxml.ml | 14 +++++++++++---
ffd6ed
 1 file changed, 11 insertions(+), 3 deletions(-)
ffd6ed
ffd6ed
diff --git a/v2v/input_libvirtxml.ml b/v2v/input_libvirtxml.ml
ffd6ed
index be48a75..089f042 100644
ffd6ed
--- a/v2v/input_libvirtxml.ml
ffd6ed
+++ b/v2v/input_libvirtxml.ml
ffd6ed
@@ -310,9 +310,7 @@ let parse_libvirt_xml ?conn ~verbose xml =
ffd6ed
       match vnet_type with
ffd6ed
       | None -> ()
ffd6ed
       | Some vnet_type ->
ffd6ed
-        match xpath_string "source/@network | source/@bridge" with
ffd6ed
-        | None -> ()
ffd6ed
-        | Some vnet ->
ffd6ed
+         let add_nic vnet =
ffd6ed
            let nic = {
ffd6ed
              s_mac = mac;
ffd6ed
              s_vnet = vnet;
ffd6ed
@@ -320,6 +318,16 @@ let parse_libvirt_xml ?conn ~verbose xml =
ffd6ed
              s_vnet_type = vnet_type
ffd6ed
            } in
ffd6ed
            nics := nic :: !nics
ffd6ed
+         in
ffd6ed
+         match xpath_string "source/@network | source/@bridge" with
ffd6ed
+         | None -> ()
ffd6ed
+         | Some "" ->
ffd6ed
+            (* The libvirt VMware driver produces at least 
ffd6ed
+             * bridge=''/> XML - see RHBZ#1257895.
ffd6ed
+             *)
ffd6ed
+            add_nic (sprintf "eth%d" i)
ffd6ed
+         | Some vnet ->
ffd6ed
+            add_nic vnet
ffd6ed
     done;
ffd6ed
     List.rev !nics in
ffd6ed
 
ffd6ed
-- 
ffd6ed
1.8.3.1
ffd6ed