Blame SOURCES/0006-ovirt-foreign-menu-Use-proper-function-in-the-case-o.patch

19ccae
From 0a16fd513034c2a1475ed84b38461faea7a12250 Mon Sep 17 00:00:00 2001
19ccae
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
19ccae
Date: Thu, 25 Jun 2020 21:19:32 -0300
19ccae
Subject: [PATCH virt-viewer] ovirt-foreign-menu: Use proper function in the
19ccae
 case of DATA StorageDomains
19ccae
19ccae
Unlike the StorageDomain objects of ISO type, the DATA ones require a
19ccae
specific API recently added to libgovirt to support them. This commit
19ccae
makes use of those new functions under #ifdef guards and adds proper a
19ccae
check to configure.ac.
19ccae
19ccae
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1847223
19ccae
19ccae
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
19ccae
---
19ccae
 configure.ac             |  2 +-
19ccae
 src/ovirt-foreign-menu.c | 36 ++++++++++++++++++++++++++++++++++--
19ccae
 2 files changed, 35 insertions(+), 3 deletions(-)
19ccae
19ccae
diff --git a/configure.ac b/configure.ac
19ccae
index 9da056f..a313ce1 100644
19ccae
--- a/configure.ac
19ccae
+++ b/configure.ac
19ccae
@@ -203,7 +203,7 @@ AS_IF([test "x$with_ovirt" = "xyes"],
19ccae
        SAVED_LIBS="$LIBS"
19ccae
        CFLAGS="$SAVED_CFLAGS $OVIRT_CFLAGS"
19ccae
        LIBS="$SAVED_LIBS $OVIRT_LIBS"
19ccae
-       AC_CHECK_FUNCS([ovirt_api_search_vms ovirt_vm_get_host ovirt_host_get_cluster ovirt_cluster_get_data_center],
19ccae
+       AC_CHECK_FUNCS([ovirt_api_search_vms ovirt_vm_get_host ovirt_host_get_cluster ovirt_cluster_get_data_center ovirt_storage_domain_get_disks],
19ccae
                       [AC_DEFINE([HAVE_OVIRT_DATA_CENTER], 1, [Have support for data center])],
19ccae
                       []
19ccae
                       )
19ccae
diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
19ccae
index c31c93f..3c67f1a 100644
19ccae
--- a/src/ovirt-foreign-menu.c
19ccae
+++ b/src/ovirt-foreign-menu.c
19ccae
@@ -481,6 +481,18 @@ static void ovirt_foreign_menu_set_files(OvirtForeignMenu *menu,
19ccae
     for (it = files; it != NULL; it = it->next) {
19ccae
         char *name;
19ccae
         g_object_get(it->data, "name", &name, NULL);
19ccae
+
19ccae
+#ifdef HAVE_OVIRT_STORAGE_DOMAIN_GET_DISKS
19ccae
+        if (OVIRT_IS_DISK(it->data)) {
19ccae
+            OvirtDiskContentType content_type;
19ccae
+            g_object_get(it->data, "content-type", &content_type, NULL);
19ccae
+            if (content_type != OVIRT_DISK_CONTENT_TYPE_ISO) {
19ccae
+                g_debug("Ignoring %s disk which content-type is not ISO", name);
19ccae
+                continue;
19ccae
+            }
19ccae
+        }
19ccae
+#endif
19ccae
+
19ccae
         /* The oVirt REST API is supposed to have a 'type' node
19ccae
          * associated with file resources , but as of 3.2, this node
19ccae
          * is not present, so we do an extension check instead
19ccae
@@ -695,6 +707,26 @@ static gboolean ovirt_foreign_menu_set_file_collection(OvirtForeignMenu *menu, O
19ccae
     return TRUE;
19ccae
 }
19ccae
 
19ccae
+static OvirtCollection *storage_domain_get_files(OvirtStorageDomain *domain)
19ccae
+{
19ccae
+    OvirtCollection *files = NULL;
19ccae
+    OvirtStorageDomainType type;
19ccae
+
19ccae
+    if (domain == NULL)
19ccae
+        return NULL;
19ccae
+
19ccae
+    g_object_get(domain, "type", &type, NULL);
19ccae
+
19ccae
+    if (type == OVIRT_STORAGE_DOMAIN_TYPE_ISO)
19ccae
+        files = ovirt_storage_domain_get_files(domain);
19ccae
+#ifdef HAVE_OVIRT_STORAGE_DOMAIN_GET_DISKS
19ccae
+    else if (type == OVIRT_STORAGE_DOMAIN_TYPE_DATA)
19ccae
+        files = ovirt_storage_domain_get_disks(domain);
19ccae
+#endif
19ccae
+
19ccae
+    return files;
19ccae
+}
19ccae
+
19ccae
 static gboolean set_file_collection_from_toplevel_storage_domain(OvirtForeignMenu *menu, OvirtStorageDomain *domain)
19ccae
 {
19ccae
     gboolean ret = FALSE;
19ccae
@@ -716,7 +748,7 @@ static gboolean set_file_collection_from_toplevel_storage_domain(OvirtForeignMen
19ccae
         goto end;
19ccae
     }
19ccae
 
19ccae
-    ret = ovirt_foreign_menu_set_file_collection(menu, ovirt_storage_domain_get_files(OVIRT_STORAGE_DOMAIN(resource)));
19ccae
+    ret = ovirt_foreign_menu_set_file_collection(menu, storage_domain_get_files(OVIRT_STORAGE_DOMAIN(resource)));
19ccae
 
19ccae
 end:
19ccae
     g_clear_error(&error);
19ccae
@@ -756,7 +788,7 @@ static void storage_domains_fetched_cb(GObject *source_object,
19ccae
         if (!domain_valid)
19ccae
             domain_valid = TRUE;
19ccae
 
19ccae
-        file_collection = ovirt_storage_domain_get_files(domain);
19ccae
+        file_collection = storage_domain_get_files(domain);
19ccae
         if (!ovirt_foreign_menu_set_file_collection(menu, file_collection)) {
19ccae
             /* Retry with toplevel storage domain */
19ccae
             if (!set_file_collection_from_toplevel_storage_domain(menu, domain))
19ccae
-- 
19ccae
2.26.2
19ccae