Blob Blame History Raw
From 4970f2528ce0e84d63242426cb6e360b5bbd07fe Mon Sep 17 00:00:00 2001
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
Date: Fri, 12 May 2017 16:06:08 -0300
Subject: [PATCH] foreign-menu: Use query for fetching virtual machines

This can save us some bandwidth, as we are searching for the specific
virtual machine instead of retrieving the collection with all VMs, and
then iterating over the results after the transfer finishes.

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
---
 src/ovirt-foreign-menu.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index 2939ae5..6d0eab3 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -697,7 +697,14 @@ static void ovirt_foreign_menu_fetch_vm_async(OvirtForeignMenu *menu,
     g_return_if_fail(OVIRT_IS_PROXY(menu->priv->proxy));
     g_return_if_fail(OVIRT_IS_API(menu->priv->api));
 
+#ifdef HAVE_OVIRT_API_SEARCH_VMS
+    char * query = g_strdup_printf("id=%s", menu->priv->vm_guid);
+    vms = ovirt_api_search_vms(menu->priv->api, query);
+    g_free(query);
+#else
     vms = ovirt_api_get_vms(menu->priv->api);
+#endif
+
     ovirt_collection_fetch_async(vms, menu->priv->proxy,
                                  g_task_get_cancellable(task),
                                  vms_fetched_cb, task);
-- 
2.13.6