[libgovirt] vm: Be more tolerant with missing nodes during <vm> parsing



commit 505faa6c17031a6a04cb847d492cd332b8efeab0
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Wed Apr 13 15:35:27 2016 +0200

    vm: Be more tolerant with missing nodes during <vm> parsing
    
    It's possible that these nodes are missing in test cases for example.
    Since we don't control what the other end is going to send us, it's
    better not to warn too loudly when this happens.

 govirt/ovirt-vm-xml.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/govirt/ovirt-vm-xml.c b/govirt/ovirt-vm-xml.c
index 22d50af..9990262 100644
--- a/govirt/ovirt-vm-xml.c
+++ b/govirt/ovirt-vm-xml.c
@@ -50,7 +50,10 @@ static gboolean vm_set_display_from_xml(OvirtVm *vm,
         return FALSE;
     }
     root = g_hash_table_lookup(root->children, display_key);
-    g_return_val_if_fail(root != NULL, FALSE);
+    if (root == NULL) {
+        g_debug("Could not find 'display' node");
+        return FALSE;
+    }
     display = ovirt_vm_display_new();
 
     node = g_hash_table_lookup(root->children, type_key);
@@ -140,6 +143,10 @@ static gboolean vm_set_state_from_xml(OvirtVm *vm, RestXmlNode *node)
     RestXmlNode *state_node;
 
     state_node = rest_xml_node_find(node, "status");
+    if (state_node == NULL) {
+        g_debug("Could not find 'status' node");
+        return FALSE;
+    }
     state_node = rest_xml_node_find(state_node, "state");
     if (state_node != NULL) {
         int state;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]