Blame SOURCES/0032-utils-Drop-type-member-from-OvirtXmlElement-struct.patch

4dfa2a
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2bd53e
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
2bd53e
Date: Thu, 18 May 2017 17:21:10 -0300
2bd53e
Subject: [PATCH] utils: Drop 'type' member from OvirtXmlElement struct
2bd53e
2bd53e
Instead of passing the type, it is possible to get it using by calling
2bd53e
g_object_class_find_property(). All users have been updated accordingly.
2bd53e
2bd53e
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2bd53e
---
2bd53e
 govirt/ovirt-cluster.c        | 2 --
2bd53e
 govirt/ovirt-host.c           | 2 --
2bd53e
 govirt/ovirt-storage-domain.c | 8 --------
2bd53e
 govirt/ovirt-utils.c          | 8 ++++++--
2bd53e
 govirt/ovirt-utils.h          | 1 -
2bd53e
 govirt/ovirt-vm.c             | 4 ----
2bd53e
 6 files changed, 6 insertions(+), 19 deletions(-)
2bd53e
2bd53e
diff --git a/govirt/ovirt-cluster.c b/govirt/ovirt-cluster.c
2bd53e
index 4aaf6b1..ae25d63 100644
2bd53e
--- a/govirt/ovirt-cluster.c
2bd53e
+++ b/govirt/ovirt-cluster.c
2bd53e
@@ -115,12 +115,10 @@ static gboolean ovirt_cluster_init_from_xml(OvirtResource *resource,
2bd53e
     OvirtResourceClass *parent_class;
2bd53e
     OvirtXmlElement cluster_elements[] = {
2bd53e
         { .prop_name = "data-center-href",
2bd53e
-          .type = G_TYPE_STRING,
2bd53e
           .xml_path = "data_center",
2bd53e
           .xml_attr = "href",
2bd53e
         },
2bd53e
         { .prop_name = "data-center-id",
2bd53e
-          .type = G_TYPE_STRING,
2bd53e
           .xml_path = "data_center",
2bd53e
           .xml_attr = "id",
2bd53e
         },
2bd53e
diff --git a/govirt/ovirt-host.c b/govirt/ovirt-host.c
2bd53e
index 191b360..1570cba 100644
2bd53e
--- a/govirt/ovirt-host.c
2bd53e
+++ b/govirt/ovirt-host.c
2bd53e
@@ -116,12 +116,10 @@ static gboolean ovirt_host_init_from_xml(OvirtResource *resource,
2bd53e
     OvirtResourceClass *parent_class;
2bd53e
     OvirtXmlElement host_elements[] = {
2bd53e
         { .prop_name = "cluster-href",
2bd53e
-          .type = G_TYPE_STRING,
2bd53e
           .xml_path = "cluster",
2bd53e
           .xml_attr = "href",
2bd53e
         },
2bd53e
         { .prop_name = "cluster-id",
2bd53e
-          .type = G_TYPE_STRING,
2bd53e
           .xml_path = "cluster",
2bd53e
           .xml_attr = "id",
2bd53e
         },
2bd53e
diff --git a/govirt/ovirt-storage-domain.c b/govirt/ovirt-storage-domain.c
2bd53e
index 718c1d2..a9078f4 100644
2bd53e
--- a/govirt/ovirt-storage-domain.c
2bd53e
+++ b/govirt/ovirt-storage-domain.c
2bd53e
@@ -153,35 +153,27 @@ static gboolean ovirt_storage_domain_init_from_xml(OvirtResource *resource,
2bd53e
     OvirtResourceClass *parent_class;
2bd53e
     OvirtXmlElement storage_domain_elements[] = {
2bd53e
         { .prop_name = "type",
2bd53e
-          .type = OVIRT_TYPE_STORAGE_DOMAIN_TYPE,
2bd53e
           .xml_path = "type",
2bd53e
         },
2bd53e
         { .prop_name = "master",
2bd53e
-          .type = G_TYPE_BOOLEAN,
2bd53e
           .xml_path = "master",
2bd53e
         },
2bd53e
         { .prop_name = "available",
2bd53e
-          .type = G_TYPE_UINT64,
2bd53e
           .xml_path = "available",
2bd53e
         },
2bd53e
         { .prop_name = "used",
2bd53e
-          .type = G_TYPE_UINT64,
2bd53e
           .xml_path = "used",
2bd53e
         },
2bd53e
         { .prop_name = "committed",
2bd53e
-          .type = G_TYPE_UINT64,
2bd53e
           .xml_path = "committed",
2bd53e
         },
2bd53e
         { .prop_name = "version",
2bd53e
-          .type = OVIRT_TYPE_STORAGE_DOMAIN_FORMAT_VERSION,
2bd53e
           .xml_path = "storage_format",
2bd53e
         },
2bd53e
         { .prop_name = "state",
2bd53e
-          .type = OVIRT_TYPE_STORAGE_DOMAIN_STATE,
2bd53e
           .xml_path = "status/state",
2bd53e
         },
2bd53e
         { .prop_name = "data-center-ids",
2bd53e
-          .type = G_TYPE_STRV,
2bd53e
           .xml_path = "data_centers",
2bd53e
           .xml_attr = "id",
2bd53e
         },
2bd53e
diff --git a/govirt/ovirt-utils.c b/govirt/ovirt-utils.c
2bd53e
index 1898862..501acb9 100644
2bd53e
--- a/govirt/ovirt-utils.c
2bd53e
+++ b/govirt/ovirt-utils.c
2bd53e
@@ -207,9 +207,13 @@ ovirt_rest_xml_node_parse(RestXmlNode *node,
2bd53e
 
2bd53e
     for (;elements->xml_path != NULL; elements++) {
2bd53e
         GValue value = { 0, };
2bd53e
+        GParamSpec *prop;
2bd53e
 
2bd53e
-        g_value_init(&value, elements->type);
2bd53e
-        if (_set_property_value_from_type(&value, elements->type, elements->xml_path, elements->xml_attr, node))
2bd53e
+        prop = g_object_class_find_property(G_OBJECT_GET_CLASS(object), elements->prop_name);
2bd53e
+        g_return_val_if_fail(prop != NULL, FALSE);
2bd53e
+
2bd53e
+        g_value_init(&value, prop->value_type);
2bd53e
+        if (_set_property_value_from_type(&value, prop->value_type, elements->xml_path, elements->xml_attr, node))
2bd53e
             g_object_set_property(object, elements->prop_name, &value);
2bd53e
         g_value_unset(&value);
2bd53e
     }
2bd53e
diff --git a/govirt/ovirt-utils.h b/govirt/ovirt-utils.h
2bd53e
index 545847a..e03f453 100644
2bd53e
--- a/govirt/ovirt-utils.h
2bd53e
+++ b/govirt/ovirt-utils.h
2bd53e
@@ -31,7 +31,6 @@ typedef struct _OvirtXmlElement OvirtXmlElement;
2bd53e
 struct _OvirtXmlElement
2bd53e
 {
2bd53e
     const char *prop_name;
2bd53e
-    GType type;
2bd53e
     const char *xml_path;
2bd53e
     const char *xml_attr; /* if NULL, retrieve node content instead of attribute */
2bd53e
 };
2bd53e
diff --git a/govirt/ovirt-vm.c b/govirt/ovirt-vm.c
4dfa2a
index 70b6f3a..36ffd35 100644
2bd53e
--- a/govirt/ovirt-vm.c
2bd53e
+++ b/govirt/ovirt-vm.c
2bd53e
@@ -184,22 +184,18 @@ static gboolean ovirt_vm_init_from_xml(OvirtResource *resource,
2bd53e
     OvirtResourceClass *parent_class;
2bd53e
     OvirtXmlElement vm_elements[] = {
2bd53e
         { .prop_name = "host-href",
2bd53e
-          .type = G_TYPE_STRING,
2bd53e
           .xml_path = "host",
2bd53e
           .xml_attr = "href",
2bd53e
         },
2bd53e
         { .prop_name = "host-id",
2bd53e
-          .type = G_TYPE_STRING,
2bd53e
           .xml_path = "host",
2bd53e
           .xml_attr = "id",
2bd53e
         },
2bd53e
         { .prop_name = "cluster-href",
2bd53e
-          .type = G_TYPE_STRING,
2bd53e
           .xml_path = "cluster",
2bd53e
           .xml_attr = "href",
2bd53e
         },
2bd53e
         { .prop_name = "cluster-id",
2bd53e
-          .type = G_TYPE_STRING,
2bd53e
           .xml_path = "cluster",
2bd53e
           .xml_attr = "id",
2bd53e
         },