Blob Blame History Raw
From 7fc76f7cea0efe8fdf48033b616cfd107cd9bd56 Mon Sep 17 00:00:00 2001
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
Date: Mon, 20 Jan 2020 19:16:49 -0300
Subject: [PATCH] Add support for oVirt API v4

v3 has been deprecated for a while now, and support will be completely
removed in RHV 4.4.

Tested against main use cases with remote-viewer:

 - Connecting to oVirt using ovirt:// URI.
 - Connecting to oVirt with console.vv file.
 - Listing and changing CD ROMs.

https://bugzilla.redhat.com/show_bug.cgi?id=1399750

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
---
 govirt/ovirt-proxy.c          | 1 -
 govirt/ovirt-resource.c       | 7 -------
 govirt/ovirt-storage-domain.c | 2 +-
 govirt/ovirt-vm.c             | 2 +-
 4 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/govirt/ovirt-proxy.c b/govirt/ovirt-proxy.c
index 92c5ed0..39ef476 100644
--- a/govirt/ovirt-proxy.c
+++ b/govirt/ovirt-proxy.c
@@ -943,7 +943,6 @@ static void ovirt_proxy_constructed(GObject *gobject)
         g_object_set(OVIRT_PROXY(gobject), "ssl-strict", FALSE, NULL);
     }
     ovirt_proxy_add_header(OVIRT_PROXY(gobject), "Prefer", "persistent-auth");
-    ovirt_proxy_add_header(OVIRT_PROXY(gobject), "Version", "3");
 
     /* Chain up to the parent class */
     if (G_OBJECT_CLASS(ovirt_proxy_parent_class)->constructed)
diff --git a/govirt/ovirt-resource.c b/govirt/ovirt-resource.c
index 936e912..9511e2f 100644
--- a/govirt/ovirt-resource.c
+++ b/govirt/ovirt-resource.c
@@ -686,7 +686,6 @@ static enum OvirtResponseStatus parse_action_status(RestXmlNode *root,
 {
     RestXmlNode *node;
     const char *status_key = g_intern_string("status");
-    const char *state_key = g_intern_string("state");
 
     g_return_val_if_fail(g_strcmp0(root->name, "action") == 0,
                          OVIRT_RESPONSE_UNKNOWN);
@@ -699,12 +698,6 @@ static enum OvirtResponseStatus parse_action_status(RestXmlNode *root,
                     _("Could not find 'status' node"));
         g_return_val_if_reached(OVIRT_RESPONSE_UNKNOWN);
     }
-    node = g_hash_table_lookup(node->children, state_key);
-    if (node == NULL) {
-        g_set_error(error, OVIRT_ERROR, OVIRT_ERROR_PARSING_FAILED,
-                    _("Could not find 'state' node"));
-        g_return_val_if_reached(OVIRT_RESPONSE_UNKNOWN);
-    }
     g_debug("State: %s\n", node->content);
     if (g_strcmp0(node->content, "complete") == 0) {
         return OVIRT_RESPONSE_COMPLETE;
diff --git a/govirt/ovirt-storage-domain.c b/govirt/ovirt-storage-domain.c
index a9078f4..4eb3354 100644
--- a/govirt/ovirt-storage-domain.c
+++ b/govirt/ovirt-storage-domain.c
@@ -171,7 +171,7 @@ static gboolean ovirt_storage_domain_init_from_xml(OvirtResource *resource,
           .xml_path = "storage_format",
         },
         { .prop_name = "state",
-          .xml_path = "status/state",
+          .xml_path = "status",
         },
         { .prop_name = "data-center-ids",
           .xml_path = "data_centers",
diff --git a/govirt/ovirt-vm.c b/govirt/ovirt-vm.c
index 8cd482b..7e1dec1 100644
--- a/govirt/ovirt-vm.c
+++ b/govirt/ovirt-vm.c
@@ -201,7 +201,7 @@ static gboolean ovirt_vm_init_from_xml(OvirtResource *resource,
           .xml_attr = "id",
         },
         { .prop_name = "state",
-          .xml_path = "status/state",
+          .xml_path = "status",
         },
         { NULL, },
     };
-- 
2.25.1