Blame SOURCES/0062-v2v-i-ova-Remove-incorrect-warning-for-disks-that-ha.patch

0d20ef
From 73eba667462773247bdfdcaaaaffcb140353c491 Mon Sep 17 00:00:00 2001
0d20ef
From: "Richard W.M. Jones" <rjones@redhat.com>
0d20ef
Date: Mon, 24 Nov 2014 15:59:36 +0000
0d20ef
Subject: [PATCH] v2v: -i ova: Remove incorrect warning for disks that have no
0d20ef
 parent controller (RHBZ#1167302).
0d20ef
0d20ef
Don't assume every disk <Item> has a <Parent> field.  For floppy disks
0d20ef
this is not the case.
0d20ef
0d20ef
Thanks: Junqin Zhou
0d20ef
(cherry picked from commit 79fb3debc42b02a7104041f3279ab81bfff03b90)
0d20ef
---
0d20ef
 v2v/input_ova.ml | 14 ++++++++++----
0d20ef
 1 file changed, 10 insertions(+), 4 deletions(-)
0d20ef
0d20ef
diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml
0d20ef
index fe71039..43e1499 100644
0d20ef
--- a/v2v/input_ova.ml
0d20ef
+++ b/v2v/input_ova.ml
0d20ef
@@ -187,14 +187,17 @@ object
0d20ef
       for i = 0 to nr_nodes-1 do
0d20ef
         let n = Xml.xpathobj_node doc obj i in
0d20ef
         Xml.xpathctx_set_current_context xpathctx n;
0d20ef
-        let parent_id = xpath_to_int "rasd:Parent/text()" 0 in
0d20ef
 
0d20ef
         (* XXX We assume the OVF lists these in order.
0d20ef
         let address = xpath_to_int "rasd:AddressOnParent/text()" 0 in
0d20ef
         *)
0d20ef
 
0d20ef
         (* Find the parent controller. *)
0d20ef
-        let controller = parent_controller parent_id in
0d20ef
+        let parent_id = xpath_to_int "rasd:Parent/text()" 0 in
0d20ef
+        let controller =
0d20ef
+          match parent_id with
0d20ef
+          | 0 -> None
0d20ef
+          | id -> parent_controller id in
0d20ef
 
0d20ef
         Xml.xpathctx_set_current_context xpathctx n;
0d20ef
         let file_id = xpath_to_string "rasd:HostResource/text()" "" in
0d20ef
@@ -255,14 +258,17 @@ object
0d20ef
         Xml.xpathctx_set_current_context xpathctx n;
0d20ef
         let id = xpath_to_int "rasd:ResourceType/text()" 0 in
0d20ef
         assert (id = 14 || id = 15 || id = 16);
0d20ef
-        let parent_id = xpath_to_int "rasd:Parent/text()" 0 in
0d20ef
 
0d20ef
         (* XXX We assume the OVF lists these in order.
0d20ef
         let address = xpath_to_int "rasd:AddressOnParent/text()" 0 in
0d20ef
         *)
0d20ef
 
0d20ef
         (* Find the parent controller. *)
0d20ef
-        let controller = parent_controller parent_id in
0d20ef
+        let parent_id = xpath_to_int "rasd:Parent/text()" 0 in
0d20ef
+        let controller =
0d20ef
+          match parent_id with
0d20ef
+          | 0 -> None
0d20ef
+          | id -> parent_controller id in
0d20ef
 
0d20ef
         let typ =
0d20ef
           match id with
0d20ef
-- 
0d20ef
1.8.3.1
0d20ef