080a59
import libgovirt-0.3.4-9.el8
@@ -0,0 +1,40 @@
|
|
1
|
+
From 7eae90f67d00bf36c0a9c56cf3c9e4fdc7d02494 Mon Sep 17 00:00:00 2001
|
2
|
+
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
3
|
+
Date: Wed, 10 May 2017 15:53:12 -0300
|
4
|
+
Subject: [PATCH] utils: Support G_TYPE_UINT in _set_property_value_from_type()
|
5
|
+
|
6
|
+
This type will mostly be used to parse the XML elements for
|
7
|
+
OvirtVmDisplay.
|
8
|
+
|
9
|
+
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
10
|
+
---
|
11
|
+
govirt/ovirt-utils.c | 6 ++++++
|
12
|
+
1 file changed, 6 insertions(+)
|
13
|
+
|
14
|
+
diff --git a/govirt/ovirt-utils.c b/govirt/ovirt-utils.c
|
15
|
+
index 501acb9..af1dfc6 100644
|
16
|
+
--- a/govirt/ovirt-utils.c
|
17
|
+
+++ b/govirt/ovirt-utils.c
|
18
|
+
|
19
|
+
#include <config.h>
|
20
|
+
|
21
|
+
#include <errno.h>
|
22
|
+
+#include <stdlib.h>
|
23
|
+
#include <string.h>
|
24
|
+
|
25
|
+
#include <glib/gi18n-lib.h>
|
26
|
+
@@ -182,6 +183,11 @@ _set_property_value_from_type(GValue *value,
|
27
|
+
g_value_set_string(value, value_str);
|
28
|
+
break;
|
29
|
+
}
|
30
|
+
+ case G_TYPE_UINT: {
|
31
|
+
+ guint uint_value = strtoul(value_str, NULL, 0);
|
32
|
+
+ g_value_set_uint(value, uint_value);
|
33
|
+
+ break;
|
34
|
+
+ }
|
35
|
+
case G_TYPE_UINT64: {
|
36
|
+
guint64 int64_value = g_ascii_strtoull(value_str, NULL, 0);
|
37
|
+
g_value_set_uint64(value, int64_value);
|
38
|
+
--
|
39
|
+
2.14.4
|
40
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
From 5a41846ba6e0d88a0a641caa214703336e2b2820 Mon Sep 17 00:00:00 2001
|
2
|
+
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
3
|
+
Date: Mon, 18 Sep 2017 10:47:13 -0300
|
4
|
+
Subject: [PATCH] utils: Improve log message when subnode is not found
|
5
|
+
|
6
|
+
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
7
|
+
---
|
8
|
+
govirt/ovirt-utils.c | 3 ++-
|
9
|
+
1 file changed, 2 insertions(+), 1 deletion(-)
|
10
|
+
|
11
|
+
diff --git a/govirt/ovirt-utils.c b/govirt/ovirt-utils.c
|
12
|
+
index af1dfc6..a60c754 100644
|
13
|
+
--- a/govirt/ovirt-utils.c
|
14
|
+
+++ b/govirt/ovirt-utils.c
|
15
|
+
@@ -63,9 +63,10 @@ ovirt_rest_xml_node_find(RestXmlNode *node, const char *path)
|
16
|
+
pathv = g_strsplit(path, "/", -1);
|
17
|
+
|
18
|
+
for (i = 0; i < g_strv_length(pathv); ++i) {
|
19
|
+
+ gchar *name = node->name;
|
20
|
+
node = rest_xml_node_find(node, pathv[i]);
|
21
|
+
if (node == NULL) {
|
22
|
+
- g_debug("could not find XML node '%s'", pathv[i]);
|
23
|
+
+ g_debug("could not find subnode '%s' of XML node '%s' (search: %s)", pathv[i], name, path);
|
24
|
+
break;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
--
|
28
|
+
2.14.4
|
29
|
+
|
@@ -0,0 +1,93 @@
|
|
1
|
+
From 1bff3d3ca4101639e659c8649731020e7a5c9c10 Mon Sep 17 00:00:00 2001
|
2
|
+
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
3
|
+
Date: Tue, 3 Oct 2017 17:32:03 -0300
|
4
|
+
Subject: [PATCH] utils: Factor out basic value type setting from
|
5
|
+
_set_property_value_from_type()
|
6
|
+
|
7
|
+
A simple cosmetic enhancement with the hope to improve code readability.
|
8
|
+
|
9
|
+
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
10
|
+
---
|
11
|
+
govirt/ovirt-utils.c | 59 ++++++++++++++++++++++++++++++----------------------
|
12
|
+
1 file changed, 34 insertions(+), 25 deletions(-)
|
13
|
+
|
14
|
+
diff --git a/govirt/ovirt-utils.c b/govirt/ovirt-utils.c
|
15
|
+
index a60c754..a0146fd 100644
|
16
|
+
--- a/govirt/ovirt-utils.c
|
17
|
+
+++ b/govirt/ovirt-utils.c
|
18
|
+
@@ -134,6 +134,39 @@ ovirt_rest_xml_node_get_str_array_from_path(RestXmlNode *node, const char *path,
|
19
|
+
return (GStrv) g_array_free(array, FALSE);
|
20
|
+
}
|
21
|
+
|
22
|
+
+static gboolean
|
23
|
+
+_set_property_value_from_basic_type(GValue *value,
|
24
|
+
+ GType type,
|
25
|
+
+ const char *value_str)
|
26
|
+
+{
|
27
|
+
+ switch(type) {
|
28
|
+
+ case G_TYPE_BOOLEAN: {
|
29
|
+
+ gboolean bool_value = ovirt_utils_boolean_from_string(value_str);
|
30
|
+
+ g_value_set_boolean(value, bool_value);
|
31
|
+
+ return TRUE;
|
32
|
+
+ }
|
33
|
+
+ case G_TYPE_STRING: {
|
34
|
+
+ g_value_set_string(value, value_str);
|
35
|
+
+ return TRUE;
|
36
|
+
+ }
|
37
|
+
+ case G_TYPE_UINT: {
|
38
|
+
+ guint uint_value = strtoul(value_str, NULL, 0);
|
39
|
+
+ g_value_set_uint(value, uint_value);
|
40
|
+
+ return TRUE;
|
41
|
+
+ }
|
42
|
+
+ case G_TYPE_UINT64: {
|
43
|
+
+ guint64 int64_value = g_ascii_strtoull(value_str, NULL, 0);
|
44
|
+
+ g_value_set_uint64(value, int64_value);
|
45
|
+
+ return TRUE;
|
46
|
+
+ }
|
47
|
+
+ default: {
|
48
|
+
+ g_warning("Unexpected type '%s' with value '%s'", g_type_name(type), value_str);
|
49
|
+
+ }
|
50
|
+
+ }
|
51
|
+
+
|
52
|
+
+ return FALSE;
|
53
|
+
+}
|
54
|
+
+
|
55
|
+
static gboolean
|
56
|
+
_set_property_value_from_type(GValue *value,
|
57
|
+
GType type,
|
58
|
+
@@ -174,31 +207,7 @@ _set_property_value_from_type(GValue *value,
|
59
|
+
goto end;
|
60
|
+
}
|
61
|
+
|
62
|
+
- switch(type) {
|
63
|
+
- case G_TYPE_BOOLEAN: {
|
64
|
+
- gboolean bool_value = ovirt_utils_boolean_from_string(value_str);
|
65
|
+
- g_value_set_boolean(value, bool_value);
|
66
|
+
- break;
|
67
|
+
- }
|
68
|
+
- case G_TYPE_STRING: {
|
69
|
+
- g_value_set_string(value, value_str);
|
70
|
+
- break;
|
71
|
+
- }
|
72
|
+
- case G_TYPE_UINT: {
|
73
|
+
- guint uint_value = strtoul(value_str, NULL, 0);
|
74
|
+
- g_value_set_uint(value, uint_value);
|
75
|
+
- break;
|
76
|
+
- }
|
77
|
+
- case G_TYPE_UINT64: {
|
78
|
+
- guint64 int64_value = g_ascii_strtoull(value_str, NULL, 0);
|
79
|
+
- g_value_set_uint64(value, int64_value);
|
80
|
+
- break;
|
81
|
+
- }
|
82
|
+
- default: {
|
83
|
+
- g_warning("Unexpected type '%s' with value '%s'", g_type_name(type), value_str);
|
84
|
+
- ret = FALSE;
|
85
|
+
- }
|
86
|
+
- }
|
87
|
+
+ ret = _set_property_value_from_basic_type(value, type, value_str);
|
88
|
+
|
89
|
+
end:
|
90
|
+
return ret;
|
91
|
+
--
|
92
|
+
2.14.4
|
93
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
From 290692dcf6d572e86a2a90ff87f666ea148eb602 Mon Sep 17 00:00:00 2001
|
2
|
+
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
3
|
+
Date: Tue, 3 Oct 2017 17:51:41 -0300
|
4
|
+
Subject: [PATCH] utils: Get enum default value from GParamSpec
|
5
|
+
|
6
|
+
Instead of assuming 0 as the default value, use the one specified during
|
7
|
+
property creation time with g_param_spec_enum().
|
8
|
+
|
9
|
+
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
10
|
+
---
|
11
|
+
govirt/ovirt-utils.c | 8 +++++---
|
12
|
+
1 file changed, 5 insertions(+), 3 deletions(-)
|
13
|
+
|
14
|
+
diff --git a/govirt/ovirt-utils.c b/govirt/ovirt-utils.c
|
15
|
+
index a0146fd..dfaf09d 100644
|
16
|
+
--- a/govirt/ovirt-utils.c
|
17
|
+
+++ b/govirt/ovirt-utils.c
|
18
|
+
@@ -169,13 +169,14 @@ _set_property_value_from_basic_type(GValue *value,
|
19
|
+
|
20
|
+
static gboolean
|
21
|
+
_set_property_value_from_type(GValue *value,
|
22
|
+
- GType type,
|
23
|
+
+ GParamSpec *prop,
|
24
|
+
const char *path,
|
25
|
+
const char *attr,
|
26
|
+
RestXmlNode *node)
|
27
|
+
{
|
28
|
+
gboolean ret = TRUE;
|
29
|
+
const char *value_str;
|
30
|
+
+ GType type = prop->value_type;
|
31
|
+
|
32
|
+
if (g_type_is_a(type, OVIRT_TYPE_RESOURCE)) {
|
33
|
+
OvirtResource *resource_value = ovirt_resource_new_from_xml(type, node, NULL);
|
34
|
+
@@ -202,7 +203,8 @@ _set_property_value_from_type(GValue *value,
|
35
|
+
return FALSE;
|
36
|
+
|
37
|
+
if (G_TYPE_IS_ENUM(type)) {
|
38
|
+
- int enum_value = ovirt_utils_genum_get_value(type, value_str, 0);
|
39
|
+
+ GParamSpecEnum *enum_prop = G_PARAM_SPEC_ENUM(prop);
|
40
|
+
+ int enum_value = ovirt_utils_genum_get_value(type, value_str, enum_prop->default_value);
|
41
|
+
g_value_set_enum(value, enum_value);
|
42
|
+
goto end;
|
43
|
+
}
|
44
|
+
@@ -229,7 +231,7 @@ ovirt_rest_xml_node_parse(RestXmlNode *node,
|
45
|
+
g_return_val_if_fail(prop != NULL, FALSE);
|
46
|
+
|
47
|
+
g_value_init(&value, prop->value_type);
|
48
|
+
- if (_set_property_value_from_type(&value, prop->value_type, elements->xml_path, elements->xml_attr, node))
|
49
|
+
+ if (_set_property_value_from_type(&value, prop, elements->xml_path, elements->xml_attr, node))
|
50
|
+
g_object_set_property(object, elements->prop_name, &value);
|
51
|
+
g_value_unset(&value);
|
52
|
+
}
|
53
|
+
--
|
54
|
+
2.14.4
|
55
|
+
|
@@ -0,0 +1,82 @@
|
|
1
|
+
From 039c8d8bc0aa49ea3bd34fc190afc844d68a6e41 Mon Sep 17 00:00:00 2001
|
2
|
+
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
3
|
+
Date: Thu, 4 May 2017 18:23:39 -0300
|
4
|
+
Subject: [PATCH] vm: Set vm state property using OvirtXmlElement struct
|
5
|
+
|
6
|
+
It was required to change the default value of the enum property to
|
7
|
+
OVIRT_VM_STATE_UNKNOWN, so that it will be set by
|
8
|
+
ovirt_rest_xml_node_parse() function in case of error.
|
9
|
+
|
10
|
+
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
11
|
+
---
|
12
|
+
govirt/ovirt-vm-xml.c | 30 +-----------------------------
|
13
|
+
govirt/ovirt-vm.c | 5 ++++-
|
14
|
+
2 files changed, 5 insertions(+), 30 deletions(-)
|
15
|
+
|
16
|
+
diff --git a/govirt/ovirt-vm-xml.c b/govirt/ovirt-vm-xml.c
|
17
|
+
index 9990262..25f50f3 100644
|
18
|
+
--- a/govirt/ovirt-vm-xml.c
|
19
|
+
+++ b/govirt/ovirt-vm-xml.c
|
20
|
+
@@ -138,35 +138,7 @@ static gboolean vm_set_display_from_xml(OvirtVm *vm,
|
21
|
+
return TRUE;
|
22
|
+
}
|
23
|
+
|
24
|
+
-static gboolean vm_set_state_from_xml(OvirtVm *vm, RestXmlNode *node)
|
25
|
+
-{
|
26
|
+
- RestXmlNode *state_node;
|
27
|
+
-
|
28
|
+
- state_node = rest_xml_node_find(node, "status");
|
29
|
+
- if (state_node == NULL) {
|
30
|
+
- g_debug("Could not find 'status' node");
|
31
|
+
- return FALSE;
|
32
|
+
- }
|
33
|
+
- state_node = rest_xml_node_find(state_node, "state");
|
34
|
+
- if (state_node != NULL) {
|
35
|
+
- int state;
|
36
|
+
-
|
37
|
+
- g_return_val_if_fail(state_node->content != NULL, FALSE);
|
38
|
+
- state = ovirt_utils_genum_get_value(OVIRT_TYPE_VM_STATE,
|
39
|
+
- state_node->content,
|
40
|
+
- OVIRT_VM_STATE_UNKNOWN);
|
41
|
+
- g_object_set(G_OBJECT(vm), "state", state, NULL);
|
42
|
+
-
|
43
|
+
- return TRUE;
|
44
|
+
- }
|
45
|
+
-
|
46
|
+
- return FALSE;
|
47
|
+
-}
|
48
|
+
-
|
49
|
+
G_GNUC_INTERNAL gboolean ovirt_vm_refresh_from_xml(OvirtVm *vm, RestXmlNode *node)
|
50
|
+
{
|
51
|
+
- vm_set_state_from_xml(vm, node);
|
52
|
+
- vm_set_display_from_xml(vm, node);
|
53
|
+
-
|
54
|
+
- return TRUE;
|
55
|
+
+ return vm_set_display_from_xml(vm, node);
|
56
|
+
}
|
57
|
+
diff --git a/govirt/ovirt-vm.c b/govirt/ovirt-vm.c
|
58
|
+
index 36ffd35..f30022d 100644
|
59
|
+
--- a/govirt/ovirt-vm.c
|
60
|
+
+++ b/govirt/ovirt-vm.c
|
61
|
+
@@ -199,6 +199,9 @@ static gboolean ovirt_vm_init_from_xml(OvirtResource *resource,
|
62
|
+
.xml_path = "cluster",
|
63
|
+
.xml_attr = "id",
|
64
|
+
},
|
65
|
+
+ { .prop_name = "state",
|
66
|
+
+ .xml_path = "status/state",
|
67
|
+
+ },
|
68
|
+
{ NULL, },
|
69
|
+
};
|
70
|
+
|
71
|
+
@@ -233,7 +236,7 @@ static void ovirt_vm_class_init(OvirtVmClass *klass)
|
72
|
+
"State",
|
73
|
+
"Virtual Machine State",
|
74
|
+
OVIRT_TYPE_VM_STATE,
|
75
|
+
- OVIRT_VM_STATE_DOWN,
|
76
|
+
+ OVIRT_VM_STATE_UNKNOWN,
|
77
|
+
G_PARAM_READWRITE |
|
78
|
+
G_PARAM_STATIC_STRINGS));
|
79
|
+
g_object_class_install_property(object_class,
|
80
|
+
--
|
81
|
+
2.14.4
|
82
|
+
|
@@ -0,0 +1,190 @@
|
|
1
|
+
From b8b0d03e43bee40ad15fa4c3aa6ca8b07ca98e31 Mon Sep 17 00:00:00 2001
|
2
|
+
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
3
|
+
Date: Wed, 10 May 2017 15:48:09 -0300
|
4
|
+
Subject: [PATCH] vm: Set values of OvirtVmDisplay using OvirtXmlElement struct
|
5
|
+
|
6
|
+
This required the addition of OVIRT_VM_DISPLAY_INVALID to the
|
7
|
+
OvirtVmDisplayType enum as the default value.
|
8
|
+
|
9
|
+
The value of the 'type' property of OvirtVmDisplay is tested after the
|
10
|
+
parsing is done, to ensure it is either vnc or spice.
|
11
|
+
|
12
|
+
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
13
|
+
---
|
14
|
+
govirt/ovirt-vm-display.c | 2 +-
|
15
|
+
govirt/ovirt-vm-display.h | 3 +-
|
16
|
+
govirt/ovirt-vm-xml.c | 118 ++++++++++++++--------------------------------
|
17
|
+
3 files changed, 38 insertions(+), 85 deletions(-)
|
18
|
+
|
19
|
+
diff --git a/govirt/ovirt-vm-display.c b/govirt/ovirt-vm-display.c
|
20
|
+
index 37e042a..b03c303 100644
|
21
|
+
--- a/govirt/ovirt-vm-display.c
|
22
|
+
+++ b/govirt/ovirt-vm-display.c
|
23
|
+
@@ -197,7 +197,7 @@ static void ovirt_vm_display_class_init(OvirtVmDisplayClass *klass)
|
24
|
+
"Type",
|
25
|
+
"Display Type",
|
26
|
+
OVIRT_TYPE_VM_DISPLAY_TYPE,
|
27
|
+
- OVIRT_VM_DISPLAY_SPICE,
|
28
|
+
+ OVIRT_VM_DISPLAY_INVALID,
|
29
|
+
G_PARAM_READWRITE |
|
30
|
+
G_PARAM_STATIC_STRINGS));
|
31
|
+
g_object_class_install_property(object_class,
|
32
|
+
diff --git a/govirt/ovirt-vm-display.h b/govirt/ovirt-vm-display.h
|
33
|
+
index f7eb310..38ef9b7 100644
|
34
|
+
--- a/govirt/ovirt-vm-display.h
|
35
|
+
+++ b/govirt/ovirt-vm-display.h
|
36
|
+
@@ -55,7 +55,8 @@ struct _OvirtVmDisplayClass
|
37
|
+
|
38
|
+
typedef enum {
|
39
|
+
OVIRT_VM_DISPLAY_SPICE,
|
40
|
+
- OVIRT_VM_DISPLAY_VNC
|
41
|
+
+ OVIRT_VM_DISPLAY_VNC,
|
42
|
+
+ OVIRT_VM_DISPLAY_INVALID,
|
43
|
+
} OvirtVmDisplayType;
|
44
|
+
|
45
|
+
GType ovirt_vm_display_get_type(void);
|
46
|
+
diff --git a/govirt/ovirt-vm-xml.c b/govirt/ovirt-vm-xml.c
|
47
|
+
index 25f50f3..0603427 100644
|
48
|
+
--- a/govirt/ovirt-vm-xml.c
|
49
|
+
+++ b/govirt/ovirt-vm-xml.c
|
50
|
+
|
51
|
+
static gboolean vm_set_display_from_xml(OvirtVm *vm,
|
52
|
+
RestXmlNode *root)
|
53
|
+
{
|
54
|
+
- RestXmlNode *node;
|
55
|
+
OvirtVmDisplay *display;
|
56
|
+
- const char *display_key = g_intern_string("display");
|
57
|
+
- const char *type_key = g_intern_string("type");
|
58
|
+
- const char *address_key = g_intern_string("address");
|
59
|
+
- const char *port_key = g_intern_string("port");
|
60
|
+
- const char *secure_port_key = g_intern_string("secure_port");
|
61
|
+
- const char *monitors_key = g_intern_string("monitors");
|
62
|
+
- const char *certificate_key = g_intern_string("certificate");
|
63
|
+
- const char *smartcard_key = g_intern_string("smartcard_enabled");
|
64
|
+
- const char *allow_override_key = g_intern_string("allow_override");
|
65
|
+
- const char *proxy_key = g_intern_string("proxy");
|
66
|
+
+ OvirtVmDisplayType type;
|
67
|
+
+ OvirtXmlElement display_elements[] = {
|
68
|
+
+ { .prop_name = "type",
|
69
|
+
+ .xml_path = "type",
|
70
|
+
+ },
|
71
|
+
+ { .prop_name = "address",
|
72
|
+
+ .xml_path = "address",
|
73
|
+
+ },
|
74
|
+
+ { .prop_name = "port",
|
75
|
+
+ .xml_path = "port",
|
76
|
+
+ },
|
77
|
+
+ { .prop_name = "secure-port",
|
78
|
+
+ .xml_path = "secure_port",
|
79
|
+
+ },
|
80
|
+
+ { .prop_name = "monitor-count",
|
81
|
+
+ .xml_path = "monitors",
|
82
|
+
+ },
|
83
|
+
+ { .prop_name = "smartcard",
|
84
|
+
+ .xml_path = "smartcard_enabled",
|
85
|
+
+ },
|
86
|
+
+ { .prop_name = "allow-override",
|
87
|
+
+ .xml_path = "allow_override",
|
88
|
+
+ },
|
89
|
+
+ { .prop_name = "host-subject",
|
90
|
+
+ .xml_path = "certificate/subject",
|
91
|
+
+ },
|
92
|
+
+ { .prop_name = "proxy-url",
|
93
|
+
+ .xml_path = "proxy",
|
94
|
+
+ },
|
95
|
+
+ { NULL, },
|
96
|
+
+ };
|
97
|
+
|
98
|
+
if (root == NULL) {
|
99
|
+
return FALSE;
|
100
|
+
}
|
101
|
+
- root = g_hash_table_lookup(root->children, display_key);
|
102
|
+
+ root = rest_xml_node_find(root, "display");
|
103
|
+
if (root == NULL) {
|
104
|
+
g_debug("Could not find 'display' node");
|
105
|
+
return FALSE;
|
106
|
+
}
|
107
|
+
display = ovirt_vm_display_new();
|
108
|
+
-
|
109
|
+
- node = g_hash_table_lookup(root->children, type_key);
|
110
|
+
- g_return_val_if_fail(node != NULL, FALSE);
|
111
|
+
- if (g_strcmp0(node->content, "spice") == 0) {
|
112
|
+
- g_object_set(G_OBJECT(display), "type", OVIRT_VM_DISPLAY_SPICE, NULL);
|
113
|
+
- } else if (g_strcmp0(node->content, "vnc") == 0) {
|
114
|
+
- g_object_set(G_OBJECT(display), "type", OVIRT_VM_DISPLAY_VNC, NULL);
|
115
|
+
- } else {
|
116
|
+
- g_warning("Unknown display type: %s", node->content);
|
117
|
+
+ ovirt_rest_xml_node_parse(root, G_OBJECT(display), display_elements);
|
118
|
+
+ g_object_get(G_OBJECT(display), "type", &type, NULL);
|
119
|
+
+ if (type == OVIRT_VM_DISPLAY_INVALID) {
|
120
|
+
return FALSE;
|
121
|
+
}
|
122
|
+
|
123
|
+
- node = g_hash_table_lookup(root->children, monitors_key);
|
124
|
+
- g_return_val_if_fail(node != NULL, FALSE);
|
125
|
+
- g_object_set(G_OBJECT(display),
|
126
|
+
- "monitor-count", strtoul(node->content, NULL, 0),
|
127
|
+
- NULL);
|
128
|
+
-
|
129
|
+
- /* on non started VMs, these 2 values will not be available */
|
130
|
+
- node = g_hash_table_lookup(root->children, address_key);
|
131
|
+
- if (node != NULL) {
|
132
|
+
- g_object_set(G_OBJECT(display), "address", node->content, NULL);
|
133
|
+
- }
|
134
|
+
-
|
135
|
+
- node = g_hash_table_lookup(root->children, port_key);
|
136
|
+
- if (node != NULL) {
|
137
|
+
- g_object_set(G_OBJECT(display),
|
138
|
+
- "port", strtoul(node->content, NULL, 0),
|
139
|
+
- NULL);
|
140
|
+
- }
|
141
|
+
-
|
142
|
+
- node = g_hash_table_lookup(root->children, secure_port_key);
|
143
|
+
- if (node != NULL) {
|
144
|
+
- g_object_set(G_OBJECT(display),
|
145
|
+
- "secure-port", strtoul(node->content, NULL, 0),
|
146
|
+
- NULL);
|
147
|
+
- }
|
148
|
+
-
|
149
|
+
- node = g_hash_table_lookup(root->children, smartcard_key);
|
150
|
+
- if (node != NULL) {
|
151
|
+
- gboolean smartcard;
|
152
|
+
-
|
153
|
+
- smartcard = (g_strcmp0(node->content, "true") == 0);
|
154
|
+
- g_object_set(G_OBJECT(display),
|
155
|
+
- "smartcard", smartcard,
|
156
|
+
- NULL);
|
157
|
+
- }
|
158
|
+
-
|
159
|
+
- node = g_hash_table_lookup(root->children, allow_override_key);
|
160
|
+
- if (node != NULL) {
|
161
|
+
- gboolean allow_override;
|
162
|
+
-
|
163
|
+
- allow_override = (g_strcmp0(node->content, "true") == 0);
|
164
|
+
- g_object_set(G_OBJECT(display),
|
165
|
+
- "allow-override", allow_override,
|
166
|
+
- NULL);
|
167
|
+
- }
|
168
|
+
-
|
169
|
+
- node = g_hash_table_lookup(root->children, certificate_key);
|
170
|
+
- if (node != NULL) {
|
171
|
+
- const char *subject_key = g_intern_string("subject");
|
172
|
+
- node = g_hash_table_lookup(node->children, subject_key);
|
173
|
+
- if (node != NULL) {
|
174
|
+
- g_object_set(G_OBJECT(display),
|
175
|
+
- "host-subject", node->content,
|
176
|
+
- NULL);
|
177
|
+
- }
|
178
|
+
- }
|
179
|
+
-
|
180
|
+
- node = g_hash_table_lookup(root->children, proxy_key);
|
181
|
+
- if (node != NULL) {
|
182
|
+
- g_object_set(G_OBJECT(display), "proxy-url", node->content, NULL);
|
183
|
+
- }
|
184
|
+
-
|
185
|
+
/* FIXME: this overrides the ticket/expiry which may
|
186
|
+
* already be set
|
187
|
+
*/
|
188
|
+
--
|
189
|
+
2.14.4
|
190
|
+
|
@@ -0,0 +1,266 @@
|
|
1
|
+
From c81f18b9dd4888145ac979addb4ef5d73585a176 Mon Sep 17 00:00:00 2001
|
2
|
+
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
3
|
+
Date: Tue, 19 Sep 2017 12:02:32 -0300
|
4
|
+
Subject: [PATCH] vm-display: Move XML parsing from ovirt-vm-xml.c file
|
5
|
+
|
6
|
+
Following the model of other resources, the code for parsing the XML
|
7
|
+
elements for the OvirtVmDisplay object where it really belongs to.
|
8
|
+
|
9
|
+
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
10
|
+
---
|
11
|
+
govirt/Makefile.am | 1 -
|
12
|
+
govirt/ovirt-vm-display.c | 60 +++++++++++++++++++++++++++++
|
13
|
+
govirt/ovirt-vm-display.h | 2 +
|
14
|
+
govirt/ovirt-vm-xml.c | 96 -----------------------------------------------
|
15
|
+
govirt/ovirt-vm.c | 15 ++++++--
|
16
|
+
5 files changed, 74 insertions(+), 100 deletions(-)
|
17
|
+
delete mode 100644 govirt/ovirt-vm-xml.c
|
18
|
+
|
19
|
+
diff --git a/govirt/Makefile.am b/govirt/Makefile.am
|
20
|
+
index 9bf0eba..1a59f2c 100644
|
21
|
+
--- a/govirt/Makefile.am
|
22
|
+
+++ b/govirt/Makefile.am
|
23
|
+
@@ -73,7 +73,6 @@ libgovirt_la_SOURCES = \
|
24
|
+
ovirt-utils.c \
|
25
|
+
ovirt-vm.c \
|
26
|
+
ovirt-vm-display.c \
|
27
|
+
- ovirt-vm-xml.c \
|
28
|
+
ovirt-vm-pool.c \
|
29
|
+
$(NULL)
|
30
|
+
|
31
|
+
diff --git a/govirt/ovirt-vm-display.c b/govirt/ovirt-vm-display.c
|
32
|
+
index b03c303..ebb04c2 100644
|
33
|
+
--- a/govirt/ovirt-vm-display.c
|
34
|
+
+++ b/govirt/ovirt-vm-display.c
|
35
|
+
|
36
|
+
|
37
|
+
#include "ovirt-enum-types.h"
|
38
|
+
#include "ovirt-vm-display.h"
|
39
|
+
+#include "ovirt-utils.h"
|
40
|
+
|
41
|
+
#define OVIRT_VM_DISPLAY_GET_PRIVATE(obj) \
|
42
|
+
(G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_VM_DISPLAY, OvirtVmDisplayPrivate))
|
43
|
+
@@ -303,3 +304,62 @@ OvirtVmDisplay *ovirt_vm_display_new(void)
|
44
|
+
{
|
45
|
+
return OVIRT_VM_DISPLAY(g_object_new(OVIRT_TYPE_VM_DISPLAY, NULL));
|
46
|
+
}
|
47
|
+
+
|
48
|
+
+static gboolean ovirt_vm_display_set_from_xml(OvirtVmDisplay *display, RestXmlNode *node)
|
49
|
+
+{
|
50
|
+
+ OvirtVmDisplayType type;
|
51
|
+
+ OvirtXmlElement display_elements[] = {
|
52
|
+
+ { .prop_name = "type",
|
53
|
+
+ .xml_path = "type",
|
54
|
+
+ },
|
55
|
+
+ { .prop_name = "address",
|
56
|
+
+ .xml_path = "address",
|
57
|
+
+ },
|
58
|
+
+ { .prop_name = "port",
|
59
|
+
+ .xml_path = "port",
|
60
|
+
+ },
|
61
|
+
+ { .prop_name = "secure-port",
|
62
|
+
+ .xml_path = "secure_port",
|
63
|
+
+ },
|
64
|
+
+ { .prop_name = "monitor-count",
|
65
|
+
+ .xml_path = "monitors",
|
66
|
+
+ },
|
67
|
+
+ { .prop_name = "smartcard",
|
68
|
+
+ .xml_path = "smartcard_enabled",
|
69
|
+
+ },
|
70
|
+
+ { .prop_name = "allow-override",
|
71
|
+
+ .xml_path = "allow_override",
|
72
|
+
+ },
|
73
|
+
+ { .prop_name = "host-subject",
|
74
|
+
+ .xml_path = "certificate/subject",
|
75
|
+
+ },
|
76
|
+
+ { .prop_name = "proxy-url",
|
77
|
+
+ .xml_path = "proxy",
|
78
|
+
+ },
|
79
|
+
+ { NULL, },
|
80
|
+
+ };
|
81
|
+
+
|
82
|
+
+ ovirt_rest_xml_node_parse(node, G_OBJECT(display), display_elements);
|
83
|
+
+ g_object_get(G_OBJECT(display), "type", &type, NULL);
|
84
|
+
+ if (type == OVIRT_VM_DISPLAY_INVALID) {
|
85
|
+
+ return FALSE;
|
86
|
+
+ }
|
87
|
+
+
|
88
|
+
+ return TRUE;
|
89
|
+
+}
|
90
|
+
+
|
91
|
+
+OvirtVmDisplay *ovirt_vm_display_new_from_xml(RestXmlNode *node)
|
92
|
+
+{
|
93
|
+
+ OvirtVmDisplay *display;
|
94
|
+
+
|
95
|
+
+ g_return_val_if_fail(node != NULL, NULL);
|
96
|
+
+
|
97
|
+
+ display = ovirt_vm_display_new();
|
98
|
+
+
|
99
|
+
+ if (!ovirt_vm_display_set_from_xml(display, node)) {
|
100
|
+
+ g_object_unref(display);
|
101
|
+
+ return NULL;
|
102
|
+
+ }
|
103
|
+
+
|
104
|
+
+ return display;
|
105
|
+
+}
|
106
|
+
diff --git a/govirt/ovirt-vm-display.h b/govirt/ovirt-vm-display.h
|
107
|
+
index 38ef9b7..11a5074 100644
|
108
|
+
--- a/govirt/ovirt-vm-display.h
|
109
|
+
+++ b/govirt/ovirt-vm-display.h
|
110
|
+
|
111
|
+
|
112
|
+
#include <glib-object.h>
|
113
|
+
#include <govirt/ovirt-types.h>
|
114
|
+
+#include <rest/rest-xml-node.h>
|
115
|
+
|
116
|
+
G_BEGIN_DECLS
|
117
|
+
|
118
|
+
@@ -61,6 +62,7 @@ typedef enum {
|
119
|
+
|
120
|
+
GType ovirt_vm_display_get_type(void);
|
121
|
+
OvirtVmDisplay *ovirt_vm_display_new(void);
|
122
|
+
+OvirtVmDisplay *ovirt_vm_display_new_from_xml(RestXmlNode *node);
|
123
|
+
|
124
|
+
G_END_DECLS
|
125
|
+
|
126
|
+
diff --git a/govirt/ovirt-vm-xml.c b/govirt/ovirt-vm-xml.c
|
127
|
+
deleted file mode 100644
|
128
|
+
index 0603427..0000000
|
129
|
+
--- a/govirt/ovirt-vm-xml.c
|
130
|
+
+++ /dev/null
|
131
|
+
|
132
|
+
-/*
|
133
|
+
- * ovirt-vm-xml.c
|
134
|
+
- *
|
135
|
+
- * Copyright (C) 2011, 2013 Red Hat, Inc.
|
136
|
+
- *
|
137
|
+
- * This library is free software; you can redistribute it and/or
|
138
|
+
- * modify it under the terms of the GNU Lesser General Public
|
139
|
+
- * License as published by the Free Software Foundation; either
|
140
|
+
- * version 2.1 of the License, or (at your option) any later version.
|
141
|
+
- *
|
142
|
+
- * This library is distributed in the hope that it will be useful,
|
143
|
+
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
144
|
+
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
145
|
+
- * Lesser General Public License for more details.
|
146
|
+
- *
|
147
|
+
- * You should have received a copy of the GNU Lesser General Public
|
148
|
+
- * License along with this library. If not, see
|
149
|
+
- * <http://www.gnu.org/licenses/>.
|
150
|
+
- *
|
151
|
+
- * Author: Christophe Fergeau <cfergeau@redhat.com>
|
152
|
+
- */
|
153
|
+
-#include <config.h>
|
154
|
+
-
|
155
|
+
-#include <stdlib.h>
|
156
|
+
-#include <string.h>
|
157
|
+
-
|
158
|
+
-#include "ovirt-enum-types.h"
|
159
|
+
-#include "ovirt-utils.h"
|
160
|
+
-#include "ovirt-vm.h"
|
161
|
+
-#include "ovirt-vm-display.h"
|
162
|
+
-#include "ovirt-vm-private.h"
|
163
|
+
-
|
164
|
+
-static gboolean vm_set_display_from_xml(OvirtVm *vm,
|
165
|
+
- RestXmlNode *root)
|
166
|
+
-{
|
167
|
+
- OvirtVmDisplay *display;
|
168
|
+
- OvirtVmDisplayType type;
|
169
|
+
- OvirtXmlElement display_elements[] = {
|
170
|
+
- { .prop_name = "type",
|
171
|
+
- .xml_path = "type",
|
172
|
+
- },
|
173
|
+
- { .prop_name = "address",
|
174
|
+
- .xml_path = "address",
|
175
|
+
- },
|
176
|
+
- { .prop_name = "port",
|
177
|
+
- .xml_path = "port",
|
178
|
+
- },
|
179
|
+
- { .prop_name = "secure-port",
|
180
|
+
- .xml_path = "secure_port",
|
181
|
+
- },
|
182
|
+
- { .prop_name = "monitor-count",
|
183
|
+
- .xml_path = "monitors",
|
184
|
+
- },
|
185
|
+
- { .prop_name = "smartcard",
|
186
|
+
- .xml_path = "smartcard_enabled",
|
187
|
+
- },
|
188
|
+
- { .prop_name = "allow-override",
|
189
|
+
- .xml_path = "allow_override",
|
190
|
+
- },
|
191
|
+
- { .prop_name = "host-subject",
|
192
|
+
- .xml_path = "certificate/subject",
|
193
|
+
- },
|
194
|
+
- { .prop_name = "proxy-url",
|
195
|
+
- .xml_path = "proxy",
|
196
|
+
- },
|
197
|
+
- { NULL, },
|
198
|
+
- };
|
199
|
+
-
|
200
|
+
- if (root == NULL) {
|
201
|
+
- return FALSE;
|
202
|
+
- }
|
203
|
+
- root = rest_xml_node_find(root, "display");
|
204
|
+
- if (root == NULL) {
|
205
|
+
- g_debug("Could not find 'display' node");
|
206
|
+
- return FALSE;
|
207
|
+
- }
|
208
|
+
- display = ovirt_vm_display_new();
|
209
|
+
- ovirt_rest_xml_node_parse(root, G_OBJECT(display), display_elements);
|
210
|
+
- g_object_get(G_OBJECT(display), "type", &type, NULL);
|
211
|
+
- if (type == OVIRT_VM_DISPLAY_INVALID) {
|
212
|
+
- return FALSE;
|
213
|
+
- }
|
214
|
+
-
|
215
|
+
- /* FIXME: this overrides the ticket/expiry which may
|
216
|
+
- * already be set
|
217
|
+
- */
|
218
|
+
- g_object_set(G_OBJECT(vm), "display", display, NULL);
|
219
|
+
- g_object_unref(G_OBJECT(display));
|
220
|
+
-
|
221
|
+
- return TRUE;
|
222
|
+
-}
|
223
|
+
-
|
224
|
+
-G_GNUC_INTERNAL gboolean ovirt_vm_refresh_from_xml(OvirtVm *vm, RestXmlNode *node)
|
225
|
+
-{
|
226
|
+
- return vm_set_display_from_xml(vm, node);
|
227
|
+
-}
|
228
|
+
diff --git a/govirt/ovirt-vm.c b/govirt/ovirt-vm.c
|
229
|
+
index f30022d..95c1e4d 100644
|
230
|
+
--- a/govirt/ovirt-vm.c
|
231
|
+
+++ b/govirt/ovirt-vm.c
|
232
|
+
@@ -180,7 +180,8 @@ static gboolean ovirt_vm_init_from_xml(OvirtResource *resource,
|
233
|
+
RestXmlNode *node,
|
234
|
+
GError **error)
|
235
|
+
{
|
236
|
+
- gboolean parsed_ok;
|
237
|
+
+ OvirtVmDisplay *display;
|
238
|
+
+ RestXmlNode *display_node;
|
239
|
+
OvirtResourceClass *parent_class;
|
240
|
+
OvirtXmlElement vm_elements[] = {
|
241
|
+
{ .prop_name = "host-href",
|
242
|
+
@@ -205,11 +206,19 @@ static gboolean ovirt_vm_init_from_xml(OvirtResource *resource,
|
243
|
+
{ NULL, },
|
244
|
+
};
|
245
|
+
|
246
|
+
- parsed_ok = ovirt_vm_refresh_from_xml(OVIRT_VM(resource), node);
|
247
|
+
- if (!parsed_ok) {
|
248
|
+
+ display_node = rest_xml_node_find(node, "display");
|
249
|
+
+ if (display_node == NULL) {
|
250
|
+
+ g_debug("Could not find 'display' node");
|
251
|
+
return FALSE;
|
252
|
+
}
|
253
|
+
|
254
|
+
+ display = ovirt_vm_display_new_from_xml(display_node);
|
255
|
+
+ if (display == NULL)
|
256
|
+
+ return FALSE;
|
257
|
+
+
|
258
|
+
+ g_object_set(G_OBJECT(resource), "display", display, NULL);
|
259
|
+
+ g_object_unref(G_OBJECT(display));
|
260
|
+
+
|
261
|
+
if (!ovirt_rest_xml_node_parse(node, G_OBJECT(resource), vm_elements))
|
262
|
+
return FALSE;
|
263
|
+
|
264
|
+
--
|
265
|
+
2.14.4
|
266
|
+
|
@@ -0,0 +1,98 @@
|
|
1
|
+
From 3a92d61ba92b85c0d31aa836713344085dab813e Mon Sep 17 00:00:00 2001
|
2
|
+
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
3
|
+
Date: Wed, 10 May 2017 15:16:27 -0300
|
4
|
+
Subject: [PATCH] vm: Set 'ticket/expiry' using OvirtXmlElement struct
|
5
|
+
|
6
|
+
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
7
|
+
---
|
8
|
+
govirt/ovirt-vm.c | 56 +++++++++++++++++++++++++++++++------------------------
|
9
|
+
1 file changed, 32 insertions(+), 24 deletions(-)
|
10
|
+
|
11
|
+
diff --git a/govirt/ovirt-vm.c b/govirt/ovirt-vm.c
|
12
|
+
index 95c1e4d..8cd482b 100644
|
13
|
+
--- a/govirt/ovirt-vm.c
|
14
|
+
+++ b/govirt/ovirt-vm.c
|
15
|
+
@@ -381,48 +381,56 @@ gboolean ovirt_vm_stop(OvirtVm *vm, OvirtProxy *proxy, GError **error)
|
16
|
+
|
17
|
+
static gboolean parse_ticket_status(RestXmlNode *root, OvirtResource *resource, GError **error)
|
18
|
+
{
|
19
|
+
- OvirtVm *vm;
|
20
|
+
- RestXmlNode *node;
|
21
|
+
- const char *ticket_key = g_intern_string("ticket");
|
22
|
+
- const char *value_key = g_intern_string("value");
|
23
|
+
- const char *expiry_key = g_intern_string("expiry");
|
24
|
+
OvirtVmDisplay *display;
|
25
|
+
+ gchar *ticket = NULL;
|
26
|
+
+ guint expiry = 0;
|
27
|
+
+ gboolean ret = FALSE;
|
28
|
+
+ OvirtXmlElement ticket_elements[] = {
|
29
|
+
+ { .prop_name = "ticket",
|
30
|
+
+ .xml_path = "value",
|
31
|
+
+ },
|
32
|
+
+ { .prop_name = "expiry",
|
33
|
+
+ .xml_path = "expiry",
|
34
|
+
+ },
|
35
|
+
+ { NULL, },
|
36
|
+
+ };
|
37
|
+
|
38
|
+
g_return_val_if_fail(root != NULL, FALSE);
|
39
|
+
g_return_val_if_fail(OVIRT_IS_VM(resource), FALSE);
|
40
|
+
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
|
41
|
+
|
42
|
+
- vm = OVIRT_VM(resource);
|
43
|
+
- root = g_hash_table_lookup(root->children, ticket_key);
|
44
|
+
+ g_object_get(G_OBJECT(resource), "display", &display, NULL);
|
45
|
+
+ g_return_val_if_fail(display != NULL, FALSE);
|
46
|
+
+
|
47
|
+
+ root = rest_xml_node_find(root, "ticket");
|
48
|
+
if (root == NULL) {
|
49
|
+
g_set_error(error, OVIRT_ERROR, OVIRT_ERROR_PARSING_FAILED,
|
50
|
+
_("Could not find 'ticket' node"));
|
51
|
+
- g_return_val_if_reached(FALSE);
|
52
|
+
+ goto end;
|
53
|
+
}
|
54
|
+
- node = g_hash_table_lookup(root->children, value_key);
|
55
|
+
- if (node == NULL) {
|
56
|
+
+
|
57
|
+
+ ovirt_rest_xml_node_parse(root, G_OBJECT(display), ticket_elements);
|
58
|
+
+
|
59
|
+
+ g_object_get(G_OBJECT(display), "ticket", &ticket, "expiry", &expiry, NULL);
|
60
|
+
+
|
61
|
+
+ if (ticket == NULL) {
|
62
|
+
g_set_error(error, OVIRT_ERROR, OVIRT_ERROR_PARSING_FAILED,
|
63
|
+
_("Could not find 'value' node"));
|
64
|
+
- g_return_val_if_reached(FALSE);
|
65
|
+
+ goto end;
|
66
|
+
}
|
67
|
+
+ g_free(ticket);
|
68
|
+
|
69
|
+
- g_object_get(G_OBJECT(vm), "display", &display, NULL);
|
70
|
+
- g_return_val_if_fail(display != NULL, FALSE);
|
71
|
+
- g_object_set(G_OBJECT(display), "ticket", node->content, NULL);
|
72
|
+
-
|
73
|
+
- node = g_hash_table_lookup(root->children, expiry_key);
|
74
|
+
- if (node == NULL) {
|
75
|
+
+ if (expiry == 0) {
|
76
|
+
g_set_error(error, OVIRT_ERROR, OVIRT_ERROR_PARSING_FAILED,
|
77
|
+
_("Could not find 'expiry' node"));
|
78
|
+
- g_object_unref(G_OBJECT(display));
|
79
|
+
- g_return_val_if_reached(FALSE);
|
80
|
+
+ goto end;
|
81
|
+
}
|
82
|
+
- g_object_set(G_OBJECT(display),
|
83
|
+
- "expiry", strtoul(node->content, NULL, 0),
|
84
|
+
- NULL);
|
85
|
+
+
|
86
|
+
+ ret = TRUE;
|
87
|
+
+
|
88
|
+
+end:
|
89
|
+
g_object_unref(G_OBJECT(display));
|
90
|
+
-
|
91
|
+
- return TRUE;
|
92
|
+
+ return ret;
|
93
|
+
}
|
94
|
+
|
95
|
+
|
96
|
+
--
|
97
|
+
2.14.4
|
98
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
From a2abf332bf99baf1d6b6a96d9153b44efdedf384 Mon Sep 17 00:00:00 2001
|
2
|
+
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
3
|
+
Date: Fri, 22 Jun 2018 18:18:53 -0300
|
4
|
+
Subject: [PATCH] test-govirt: Add 'display' node to vm XMLs
|
5
|
+
|
6
|
+
Makes 'make distcheck' pass again. Test-govirt was failing since commit
|
7
|
+
039c8d8, because the 'display' node is mandatory, but the return value
|
8
|
+
of the function vm_set_display_from_xml() had been ignored.
|
9
|
+
|
10
|
+
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
11
|
+
---
|
12
|
+
tests/test-govirt.c | 8 ++++++++
|
13
|
+
1 file changed, 8 insertions(+)
|
14
|
+
|
15
|
+
diff --git a/tests/test-govirt.c b/tests/test-govirt.c
|
16
|
+
index 247a27a..7f2cd57 100644
|
17
|
+
--- a/tests/test-govirt.c
|
18
|
+
+++ b/tests/test-govirt.c
|
19
|
+
@@ -194,9 +194,17 @@ static void test_govirt_list_duplicate_vms(void)
|
20
|
+
const char *vms_body = "<vms> \
|
21
|
+
<vm href=\"api/vms/uuid0\" id=\"uuid0\"> \
|
22
|
+
<name>vm0</name> \
|
23
|
+
+ <display> \
|
24
|
+
+ <type>spice</type> \
|
25
|
+
+ <monitors>1</monitors> \
|
26
|
+
+ </display> \
|
27
|
+
</vm> \
|
28
|
+
<vm href=\"api/vms/uuid1\" id=\"uuid1\"> \
|
29
|
+
<name>vm0</name> \
|
30
|
+
+ <display> \
|
31
|
+
+ <type>spice</type> \
|
32
|
+
+ <monitors>1</monitors> \
|
33
|
+
+ </display> \
|
34
|
+
</vm> \
|
35
|
+
</vms>";
|
36
|
+
|
37
|
+
--
|
38
|
+
2.14.4
|
39
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
From 01563a00550dd001f080aeddd8c6bbc35c676991 Mon Sep 17 00:00:00 2001
|
2
|
+
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
3
|
+
Date: Wed, 11 Jul 2018 15:42:16 -0300
|
4
|
+
Subject: [PATCH] proxy: Set detailed error message for async call
|
5
|
+
|
6
|
+
The rest API returns more detailed error messages with the result, not
|
7
|
+
only the literal corresponding to the value. If this is the case, we set
|
8
|
+
a new error message and return it.
|
9
|
+
|
10
|
+
For example, before this change, virt-viewer showed a dialog with a
|
11
|
+
vague 'Bad Request' message, and now a much more detailed 'Operation
|
12
|
+
Failed: query execution failed due to insufficient permissions.'
|
13
|
+
|
14
|
+
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
15
|
+
---
|
16
|
+
govirt/ovirt-proxy.c | 20 ++++++++++++++++++--
|
17
|
+
1 file changed, 18 insertions(+), 2 deletions(-)
|
18
|
+
|
19
|
+
diff --git a/govirt/ovirt-proxy.c b/govirt/ovirt-proxy.c
|
20
|
+
index 921e22e..f8e629e 100644
|
21
|
+
--- a/govirt/ovirt-proxy.c
|
22
|
+
+++ b/govirt/ovirt-proxy.c
|
23
|
+
@@ -240,6 +240,22 @@ call_async_cancelled_cb (G_GNUC_UNUSED GCancellable *cancellable,
|
24
|
+
}
|
25
|
+
|
26
|
+
|
27
|
+
+static void rest_call_async_set_error(RestProxyCall *call, GSimpleAsyncResult *result, const GError *error)
|
28
|
+
+{
|
29
|
+
+ GError *local_error = NULL;
|
30
|
+
+ RestXmlNode *root = ovirt_rest_xml_node_from_call(call);
|
31
|
+
+
|
32
|
+
+ if (root != NULL && ovirt_utils_gerror_from_xml_fault(root, &local_error)) {
|
33
|
+
+ g_debug("ovirt_rest_call_async(): %s", local_error->message);
|
34
|
+
+ g_simple_async_result_set_from_error(result, local_error);
|
35
|
+
+ g_clear_error(&local_error);
|
36
|
+
+ } else {
|
37
|
+
+ g_simple_async_result_set_from_error(result, error);
|
38
|
+
+ }
|
39
|
+
+
|
40
|
+
+ rest_xml_node_unref(root);
|
41
|
+
+}
|
42
|
+
+
|
43
|
+
static void
|
44
|
+
call_async_cb(RestProxyCall *call, const GError *error,
|
45
|
+
G_GNUC_UNUSED GObject *weak_object,
|
46
|
+
@@ -249,7 +265,7 @@ call_async_cb(RestProxyCall *call, const GError *error,
|
47
|
+
GSimpleAsyncResult *result = data->result;
|
48
|
+
|
49
|
+
if (error != NULL) {
|
50
|
+
- g_simple_async_result_set_from_error(result, error);
|
51
|
+
+ rest_call_async_set_error(call, result, error);
|
52
|
+
} else {
|
53
|
+
GError *call_error = NULL;
|
54
|
+
gboolean callback_result = TRUE;
|
55
|
+
@@ -259,7 +275,7 @@ call_async_cb(RestProxyCall *call, const GError *error,
|
56
|
+
data->call_user_data,
|
57
|
+
&call_error);
|
58
|
+
if (call_error != NULL) {
|
59
|
+
- g_simple_async_result_set_from_error(result, call_error);
|
60
|
+
+ rest_call_async_set_error(call, result, call_error);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
--
|
65
|
+
2.20.1
|
66
|
+
|
@@ -0,0 +1,108 @@
|
|
1
|
+
From 53fb63d610503679bd3f4e2780989076544ddb14 Mon Sep 17 00:00:00 2001
|
2
|
+
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
3
|
+
Date: Thu, 4 May 2017 15:54:02 -0300
|
4
|
+
Subject: [PATCH] cdrom: Set file property using OvirtXmlElement struct
|
5
|
+
|
6
|
+
This was the last place left to move to the new automatic parsing
|
7
|
+
scheme.
|
8
|
+
|
9
|
+
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
10
|
+
---
|
11
|
+
govirt/ovirt-cdrom.c | 57 +++++++++++++++++---------------------------
|
12
|
+
1 file changed, 22 insertions(+), 35 deletions(-)
|
13
|
+
|
14
|
+
diff --git a/govirt/ovirt-cdrom.c b/govirt/ovirt-cdrom.c
|
15
|
+
index d852403..5bab7d3 100644
|
16
|
+
--- a/govirt/ovirt-cdrom.c
|
17
|
+
+++ b/govirt/ovirt-cdrom.c
|
18
|
+
|
19
|
+
#include "ovirt-proxy-private.h"
|
20
|
+
#include "ovirt-resource-private.h"
|
21
|
+
#include "ovirt-resource-rest-call.h"
|
22
|
+
+#include "ovirt-utils.h"
|
23
|
+
|
24
|
+
#define OVIRT_CDROM_GET_PRIVATE(obj) \
|
25
|
+
(G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_CDROM, OvirtCdromPrivate))
|
26
|
+
@@ -95,25 +96,29 @@ static void ovirt_cdrom_finalize(GObject *object)
|
27
|
+
}
|
28
|
+
|
29
|
+
|
30
|
+
-static gboolean ovirt_cdrom_refresh_from_xml(OvirtCdrom *cdrom,
|
31
|
+
- RestXmlNode *node)
|
32
|
+
+static gboolean ovirt_cdrom_init_from_xml(OvirtResource *resource,
|
33
|
+
+ RestXmlNode *node,
|
34
|
+
+ GError **error)
|
35
|
+
{
|
36
|
+
- RestXmlNode *file_node;
|
37
|
+
- const char *file;
|
38
|
+
- const char *file_key = g_intern_string("file");
|
39
|
+
+ gboolean ret = FALSE;
|
40
|
+
char *name;
|
41
|
+
+ OvirtResourceClass *parent_class;
|
42
|
+
+ OvirtXmlElement cdrom_elements[] = {
|
43
|
+
+ { .prop_name = "file",
|
44
|
+
+ .xml_path = "file",
|
45
|
+
+ .xml_attr = "id",
|
46
|
+
+ },
|
47
|
+
+ { NULL , },
|
48
|
+
+ };
|
49
|
+
|
50
|
+
- file_node = g_hash_table_lookup(node->children, file_key);
|
51
|
+
- if (file_node != NULL) {
|
52
|
+
- file = rest_xml_node_get_attr(file_node, "id");
|
53
|
+
- if (g_strcmp0(file, cdrom->priv->file) != 0) {
|
54
|
+
- g_free(cdrom->priv->file);
|
55
|
+
- cdrom->priv->file = g_strdup(file);
|
56
|
+
- g_object_notify(G_OBJECT(cdrom), "file");
|
57
|
+
- }
|
58
|
+
- }
|
59
|
+
+ parent_class = OVIRT_RESOURCE_CLASS(ovirt_cdrom_parent_class);
|
60
|
+
+
|
61
|
+
+ if (!parent_class->init_from_xml(resource, node, error))
|
62
|
+
+ return FALSE;
|
63
|
+
|
64
|
+
- g_object_get(G_OBJECT(cdrom), "name", &name, NULL);
|
65
|
+
+ ovirt_rest_xml_node_parse(node, G_OBJECT(resource), cdrom_elements);
|
66
|
+
+
|
67
|
+
+ g_object_get(G_OBJECT(resource), "name", &name, NULL);
|
68
|
+
if (name == NULL) {
|
69
|
+
/* Build up fake name as ovirt_collection_refresh_from_xml()
|
70
|
+
* expects it to be set (it uses it as a hash table key), but
|
71
|
+
@@ -122,32 +127,14 @@ static gboolean ovirt_cdrom_refresh_from_xml(OvirtCdrom *cdrom,
|
72
|
+
* enough for now
|
73
|
+
*/
|
74
|
+
g_debug("Setting fake 'name' for cdrom resource");
|
75
|
+
- g_object_set(G_OBJECT(cdrom), "name", "cdrom0", NULL);
|
76
|
+
- } else {
|
77
|
+
- g_free(name);
|
78
|
+
+ g_object_set(G_OBJECT(resource), "name", "cdrom0", NULL);
|
79
|
+
}
|
80
|
+
|
81
|
+
+ g_free(name);
|
82
|
+
return TRUE;
|
83
|
+
}
|
84
|
+
|
85
|
+
|
86
|
+
-static gboolean ovirt_cdrom_init_from_xml(OvirtResource *resource,
|
87
|
+
- RestXmlNode *node,
|
88
|
+
- GError **error)
|
89
|
+
-{
|
90
|
+
- gboolean parsed_ok;
|
91
|
+
- OvirtResourceClass *parent_class;
|
92
|
+
-
|
93
|
+
- parsed_ok = ovirt_cdrom_refresh_from_xml(OVIRT_CDROM(resource), node);
|
94
|
+
- if (!parsed_ok) {
|
95
|
+
- return FALSE;
|
96
|
+
- }
|
97
|
+
- parent_class = OVIRT_RESOURCE_CLASS(ovirt_cdrom_parent_class);
|
98
|
+
-
|
99
|
+
- return parent_class->init_from_xml(resource, node, error);
|
100
|
+
-}
|
101
|
+
-
|
102
|
+
-
|
103
|
+
static char *ovirt_cdrom_to_xml(OvirtResource *resource)
|
104
|
+
{
|
105
|
+
OvirtCdrom *cdrom;
|
106
|
+
--
|
107
|
+
2.20.1
|
108
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
From 8032575cbe274c9e70ec2a0efb0b536f13dbc6cd Mon Sep 17 00:00:00 2001
|
2
|
+
From: Christophe Fergeau <cfergeau@redhat.com>
|
3
|
+
Date: Fri, 21 Dec 2018 13:15:16 +0100
|
4
|
+
Subject: [PATCH] proxy: Don't try to unref NULL root node
|
5
|
+
|
6
|
+
When an error occurs, we may have failed to get any data, so 'root' may
|
7
|
+
be NULL. Trying to unref it triggers a critical. This happens for
|
8
|
+
example when trying to connect to a remote host with an invalid
|
9
|
+
certificate.
|
10
|
+
---
|
11
|
+
govirt/ovirt-proxy.c | 4 +++-
|
12
|
+
1 file changed, 3 insertions(+), 1 deletion(-)
|
13
|
+
|
14
|
+
diff --git a/govirt/ovirt-proxy.c b/govirt/ovirt-proxy.c
|
15
|
+
index f8e629e..920ef21 100644
|
16
|
+
--- a/govirt/ovirt-proxy.c
|
17
|
+
+++ b/govirt/ovirt-proxy.c
|
18
|
+
@@ -253,7 +253,9 @@ static void rest_call_async_set_error(RestProxyCall *call, GSimpleAsyncResult *r
|
19
|
+
g_simple_async_result_set_from_error(result, error);
|
20
|
+
}
|
21
|
+
|
22
|
+
- rest_xml_node_unref(root);
|
23
|
+
+ if (root != NULL) {
|
24
|
+
+ rest_xml_node_unref(root);
|
25
|
+
+ }
|
26
|
+
}
|
27
|
+
|
28
|
+
static void
|
29
|
+
--
|
30
|
+
2.20.1
|
31
|
+
|
@@ -0,0 +1,98 @@
|
|
1
|
+
From d6ddeff795ce3f132f1e266fc813e0a4917f8bf7 Mon Sep 17 00:00:00 2001
|
2
|
+
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
3
|
+
Date: Mon, 4 Feb 2019 15:58:40 -0200
|
4
|
+
Subject: [PATCH] utils: Check for valid data before calling
|
5
|
+
rest_xml_parser_parse_from_data()
|
6
|
+
|
7
|
+
In the case of HTTP errors, such as a invalid TLS certificate, the
|
8
|
+
returned data is NULL, and the code in librest does not check for the
|
9
|
+
pointer being valid, causing a segfault.
|
10
|
+
|
11
|
+
The users of this function have been updated to check for NULL return
|
12
|
+
value.
|
13
|
+
|
14
|
+
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
15
|
+
---
|
16
|
+
govirt/ovirt-proxy.c | 6 ++++++
|
17
|
+
govirt/ovirt-resource.c | 9 ++++++++-
|
18
|
+
govirt/ovirt-utils.c | 7 +++++--
|
19
|
+
3 files changed, 19 insertions(+), 3 deletions(-)
|
20
|
+
|
21
|
+
diff --git a/govirt/ovirt-proxy.c b/govirt/ovirt-proxy.c
|
22
|
+
index 920ef21..9cdd211 100644
|
23
|
+
--- a/govirt/ovirt-proxy.c
|
24
|
+
+++ b/govirt/ovirt-proxy.c
|
25
|
+
@@ -365,6 +365,11 @@ static gboolean get_collection_xml_async_cb(OvirtProxy* proxy,
|
26
|
+
data = (OvirtProxyGetCollectionAsyncData *)user_data;
|
27
|
+
|
28
|
+
root = ovirt_rest_xml_node_from_call(call);
|
29
|
+
+ if (root == NULL) {
|
30
|
+
+ g_set_error_literal(error, OVIRT_ERROR, OVIRT_ERROR_PARSING_FAILED,
|
31
|
+
+ _("Failed to parse response from collection"));
|
32
|
+
+ goto end;
|
33
|
+
+ }
|
34
|
+
|
35
|
+
/* Do the parsing */
|
36
|
+
g_warn_if_fail(data->parser != NULL);
|
37
|
+
@@ -374,6 +379,7 @@ static gboolean get_collection_xml_async_cb(OvirtProxy* proxy,
|
38
|
+
|
39
|
+
rest_xml_node_unref(root);
|
40
|
+
|
41
|
+
+end:
|
42
|
+
return parsed;
|
43
|
+
}
|
44
|
+
|
45
|
+
diff --git a/govirt/ovirt-resource.c b/govirt/ovirt-resource.c
|
46
|
+
index 1984b1d..936e912 100644
|
47
|
+
--- a/govirt/ovirt-resource.c
|
48
|
+
+++ b/govirt/ovirt-resource.c
|
49
|
+
@@ -868,17 +868,24 @@ static gboolean ovirt_resource_refresh_async_cb(OvirtProxy *proxy,
|
50
|
+
{
|
51
|
+
OvirtResource *resource;
|
52
|
+
RestXmlNode *root;
|
53
|
+
- gboolean refreshed;
|
54
|
+
+ gboolean refreshed = FALSE;
|
55
|
+
|
56
|
+
g_return_val_if_fail(REST_IS_PROXY_CALL(call), FALSE);
|
57
|
+
g_return_val_if_fail(OVIRT_IS_RESOURCE(user_data), FALSE);
|
58
|
+
|
59
|
+
root = ovirt_rest_xml_node_from_call(call);
|
60
|
+
+ if (root == NULL) {
|
61
|
+
+ g_set_error_literal(error, OVIRT_ERROR, OVIRT_ERROR_PARSING_FAILED,
|
62
|
+
+ _("Failed to parse response from resource"));
|
63
|
+
+ goto end;
|
64
|
+
+ }
|
65
|
+
+
|
66
|
+
resource = OVIRT_RESOURCE(user_data);
|
67
|
+
refreshed = ovirt_resource_init_from_xml(resource, root, error);
|
68
|
+
|
69
|
+
rest_xml_node_unref(root);
|
70
|
+
|
71
|
+
+end:
|
72
|
+
return refreshed;
|
73
|
+
}
|
74
|
+
|
75
|
+
diff --git a/govirt/ovirt-utils.c b/govirt/ovirt-utils.c
|
76
|
+
index dfaf09d..56ce2e1 100644
|
77
|
+
--- a/govirt/ovirt-utils.c
|
78
|
+
+++ b/govirt/ovirt-utils.c
|
79
|
+
@@ -40,11 +40,14 @@ ovirt_rest_xml_node_from_call(RestProxyCall *call)
|
80
|
+
{
|
81
|
+
RestXmlParser *parser;
|
82
|
+
RestXmlNode *node;
|
83
|
+
+ const char * data = rest_proxy_call_get_payload (call);
|
84
|
+
+
|
85
|
+
+ if (data == NULL)
|
86
|
+
+ return NULL;
|
87
|
+
|
88
|
+
parser = rest_xml_parser_new ();
|
89
|
+
|
90
|
+
- node = rest_xml_parser_parse_from_data (parser,
|
91
|
+
- rest_proxy_call_get_payload (call),
|
92
|
+
+ node = rest_xml_parser_parse_from_data (parser, data,
|
93
|
+
rest_proxy_call_get_payload_length (call));
|
94
|
+
|
95
|
+
g_object_unref(G_OBJECT(parser));
|
96
|
+
--
|
97
|
+
2.20.1
|
98
|
+
|
@@ -1,4 +1,4 @@
|
|
1
|
-
From
|
1
|
+
From d8b4c483d8e31525b1290115fbded054b4e8c3ab Mon Sep 17 00:00:00 2001
|
2
2
|
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
3
3
|
Date: Tue, 21 May 2019 14:30:50 -0300
|
4
4
|
Subject: [PATCH] Update tests certificates
|
@@ -0,0 +1,25 @@
|
|
1
|
+
From 6ffccbc63ec4617123e3a6cdb32d721658bc4f50 Mon Sep 17 00:00:00 2001
|
2
|
+
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
3
|
+
Date: Mon, 27 May 2019 09:45:01 -0300
|
4
|
+
Subject: [PATCH] cdrom: Remove unused variable
|
5
|
+
|
6
|
+
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
7
|
+
---
|
8
|
+
govirt/ovirt-cdrom.c | 1 -
|
9
|
+
1 file changed, 1 deletion(-)
|
10
|
+
|
11
|
+
diff --git a/govirt/ovirt-cdrom.c b/govirt/ovirt-cdrom.c
|
12
|
+
index 5bab7d3..f625a0c 100644
|
13
|
+
--- a/govirt/ovirt-cdrom.c
|
14
|
+
+++ b/govirt/ovirt-cdrom.c
|
15
|
+
@@ -100,7 +100,6 @@ static gboolean ovirt_cdrom_init_from_xml(OvirtResource *resource,
|
16
|
+
RestXmlNode *node,
|
17
|
+
GError **error)
|
18
|
+
{
|
19
|
+
- gboolean ret = FALSE;
|
20
|
+
char *name;
|
21
|
+
OvirtResourceClass *parent_class;
|
22
|
+
OvirtXmlElement cdrom_elements[] = {
|
23
|
+
--
|
24
|
+
2.21.0
|
25
|
+
|
@@ -17,7 +17,7 @@
|
|
17
17
|
Summary: A GObject library for interacting with oVirt REST API
|
18
18
|
Name: libgovirt
|
19
19
|
Version: 0.3.4
|
20
|
-
Release:
|
20
|
+
Release: 9%{?dist}%{?extra_release}
|
21
21
|
License: LGPLv2+
|
22
22
|
Group: Development/Libraries
|
23
23
|
Source0: http://ftp.gnome.org/pub/GNOME/sources/libgovirt/0.3/%{name}-%{version}.tar.xz
|
@@ -56,8 +56,21 @@ Patch29: 0029-resource-Fix-ovirt_resource_rest_call_sync-crash-on-.patch
|
|
56
56
|
Patch30: 0030-resource-Fix-ovirt_resource_init_from_xml_real-preco.patch
|
57
57
|
Patch31: 0031-resource-Update-xml-node-in-ovirt_resource_init_from.patch
|
58
58
|
Patch32: 0032-utils-Drop-type-member-from-OvirtXmlElement-struct.patch
|
59
|
-
|
60
|
-
|
59
|
+
Patch33: 0033-utils-Support-G_TYPE_UINT-in-_set_property_value_fro.patch
|
60
|
+
Patch34: 0034-utils-Improve-log-message-when-subnode-is-not-found.patch
|
61
|
+
Patch35: 0035-utils-Factor-out-basic-value-type-setting-from-_set_.patch
|
62
|
+
Patch36: 0036-utils-Get-enum-default-value-from-GParamSpec.patch
|
63
|
+
Patch37: 0037-vm-Set-vm-state-property-using-OvirtXmlElement-struc.patch
|
64
|
+
Patch38: 0038-vm-Set-values-of-OvirtVmDisplay-using-OvirtXmlElemen.patch
|
65
|
+
Patch39: 0039-vm-display-Move-XML-parsing-from-ovirt-vm-xml.c-file.patch
|
66
|
+
Patch40: 0040-vm-Set-ticket-expiry-using-OvirtXmlElement-struct.patch
|
67
|
+
Patch41: 0041-test-govirt-Add-display-node-to-vm-XMLs.patch
|
68
|
+
Patch42: 0042-proxy-Set-detailed-error-message-for-async-call.patch
|
69
|
+
Patch43: 0043-cdrom-Set-file-property-using-OvirtXmlElement-struct.patch
|
70
|
+
Patch44: 0044-proxy-Don-t-try-to-unref-NULL-root-node.patch
|
71
|
+
Patch45: 0045-utils-Check-for-valid-data-before-calling-rest_xml_p.patch
|
72
|
+
Patch46: 0046-Update-tests-certificates.patch
|
73
|
+
Patch47: 0047-cdrom-Remove-unused-variable.patch
|
61
74
|
|
62
75
|
%if 0%{?enable_autotools}
|
63
76
|
BuildRequires: autoconf
|
@@ -145,8 +158,9 @@ make check
|
|
145
158
|
%endif
|
146
159
|
|
147
160
|
%changelog
|
148
|
-
*
|
149
|
-
-
|
161
|
+
* Mon Aug 2 2019 Eduardo Lima (Etrunko) <etrunko@redhat.com> - 0.3.4-9
|
162
|
+
- Sync with the rhel 7.7 package
|
163
|
+
Related: rhbz#1717900
|
150
164
|
|
151
165
|
* Mon Jun 11 2018 Christophe Fergeau <cfergeau@redhat.com> - 0.3.4-8
|
152
166
|
- Sync with the rhel 7.6 package
|