[virt-tools-list] [virt-viewer 1/4] ovirt: Remove use of deprecated APIs
Christophe Fergeau
cfergeau at redhat.com
Tue Oct 29 17:53:32 UTC 2013
ovirt_proxy_fetch_vms/ovirt_proxy_lookup_vm have been deprecated
in govirt 0.3.0
---
configure.ac | 2 +-
src/remote-viewer.c | 15 ++++++++++++---
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index b6071cc..ed0fc91 100644
--- a/configure.ac
+++ b/configure.ac
@@ -178,7 +178,7 @@ AC_ARG_WITH([ovirt],
AS_HELP_STRING([--without-ovirt], [Ignore presence of librest and disable oVirt support]))
AS_IF([test "x$with_ovirt" != "xno"],
- [PKG_CHECK_MODULES([OVIRT], [govirt-1.0 >= 0.1.0],
+ [PKG_CHECK_MODULES([OVIRT], [govirt-1.0 >= 0.3.0],
[have_ovirt=yes], [have_ovirt=no])],
[have_ovirt=no])
diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index 88fbe0f..79b270a 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -717,6 +717,8 @@ static gboolean
create_ovirt_session(VirtViewerApp *app, const char *uri)
{
OvirtProxy *proxy = NULL;
+ OvirtApi *api = NULL;
+ OvirtCollection *vms;
OvirtVm *vm = NULL;
OvirtVmDisplay *display = NULL;
OvirtVmState state;
@@ -751,13 +753,18 @@ create_ovirt_session(VirtViewerApp *app, const char *uri)
goto error;
}
- ovirt_proxy_fetch_vms(proxy, &error);
+ api = ovirt_proxy_fetch_api(proxy, &error);
+ if (error != NULL) {
+ g_debug("failed to get oVirt 'api' collection: %s", error->message);
+ goto error;
+ }
+ vms = ovirt_api_get_vms(api);
+ ovirt_collection_fetch(vms, proxy, &error);
if (error != NULL) {
g_debug("failed to lookup %s: %s", vm_name, error->message);
goto error;
}
-
- vm = ovirt_proxy_lookup_vm(proxy, vm_name);
+ vm = OVIRT_VM(ovirt_collection_lookup_resource(vms, vm_name));
g_return_val_if_fail(vm != NULL, FALSE);
g_object_get(G_OBJECT(vm), "state", &state, NULL);
if (state != OVIRT_VM_STATE_UP) {
@@ -834,6 +841,8 @@ error:
g_object_unref(display);
if (vm != NULL)
g_object_unref(vm);
+ if (api != NULL)
+ g_object_unref(api);
if (proxy != NULL)
g_object_unref(proxy);
--
1.8.3.1
More information about the virt-tools-list
mailing list