[virt-tools-list] [PATCH virt-viewer 1/3] foreign-menu: Use query for fetching virtual machines

Eduardo Lima (Etrunko) etrunko at redhat.com
Fri Aug 4 21:53:47 UTC 2017


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 at redhat.com>
---
 src/ovirt-foreign-menu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index fdfd327..539f716 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -696,12 +696,16 @@ static void ovirt_foreign_menu_fetch_vm_async(OvirtForeignMenu *menu,
                                               GTask *task)
 {
     OvirtCollection *vms;
+    char *query;
 
     g_return_if_fail(OVIRT_IS_FOREIGN_MENU(menu));
     g_return_if_fail(OVIRT_IS_PROXY(menu->priv->proxy));
     g_return_if_fail(OVIRT_IS_API(menu->priv->api));
 
-    vms = ovirt_api_get_vms(menu->priv->api);
+    query = g_strdup_printf("id=%s", menu->priv->vm_guid);
+    vms = ovirt_api_search_vms(menu->priv->api, query);
+    g_free(query);
+
     ovirt_collection_fetch_async(vms, menu->priv->proxy,
                                  g_task_get_cancellable(task),
                                  vms_fetched_cb, task);
-- 
2.13.4




More information about the virt-tools-list mailing list