You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.9 KiB

From 039c8d8bc0aa49ea3bd34fc190afc844d68a6e41 Mon Sep 17 00:00:00 2001
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
Date: Thu, 4 May 2017 18:23:39 -0300
Subject: [PATCH] vm: Set vm state property using OvirtXmlElement struct
It was required to change the default value of the enum property to
OVIRT_VM_STATE_UNKNOWN, so that it will be set by
ovirt_rest_xml_node_parse() function in case of error.
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
---
govirt/ovirt-vm-xml.c | 30 +-----------------------------
govirt/ovirt-vm.c | 5 ++++-
2 files changed, 5 insertions(+), 30 deletions(-)
diff --git a/govirt/ovirt-vm-xml.c b/govirt/ovirt-vm-xml.c
index 9990262..25f50f3 100644
--- a/govirt/ovirt-vm-xml.c
+++ b/govirt/ovirt-vm-xml.c
@@ -138,35 +138,7 @@ static gboolean vm_set_display_from_xml(OvirtVm *vm,
return TRUE;
}
-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;
-
- g_return_val_if_fail(state_node->content != NULL, FALSE);
- state = ovirt_utils_genum_get_value(OVIRT_TYPE_VM_STATE,
- state_node->content,
- OVIRT_VM_STATE_UNKNOWN);
- g_object_set(G_OBJECT(vm), "state", state, NULL);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
G_GNUC_INTERNAL gboolean ovirt_vm_refresh_from_xml(OvirtVm *vm, RestXmlNode *node)
{
- vm_set_state_from_xml(vm, node);
- vm_set_display_from_xml(vm, node);
-
- return TRUE;
+ return vm_set_display_from_xml(vm, node);
}
diff --git a/govirt/ovirt-vm.c b/govirt/ovirt-vm.c
index 36ffd35..f30022d 100644
--- a/govirt/ovirt-vm.c
+++ b/govirt/ovirt-vm.c
@@ -199,6 +199,9 @@ static gboolean ovirt_vm_init_from_xml(OvirtResource *resource,
.xml_path = "cluster",
.xml_attr = "id",
},
+ { .prop_name = "state",
+ .xml_path = "status/state",
+ },
{ NULL, },
};
@@ -233,7 +236,7 @@ static void ovirt_vm_class_init(OvirtVmClass *klass)
"State",
"Virtual Machine State",
OVIRT_TYPE_VM_STATE,
- OVIRT_VM_STATE_DOWN,
+ OVIRT_VM_STATE_UNKNOWN,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
g_object_class_install_property(object_class,
--
2.14.4