summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Lima (Etrunko) <etrunko@redhat.com>2020-06-15 20:53:18 -0300
committerEduardo Lima (Etrunko) <etrunko@redhat.com>2020-06-25 23:02:03 -0300
commitbb3d020cb9f5f3ea79cbfc69755b6621278c21d8 (patch)
tree2c35d366d5212a162376e4ae691c1a0c8871a370
parent42f408902e6939e54deff52ace5c9ae80334d0fb (diff)
ovirt-foreign-menu: Take into account StorageDomains of type DATA
Now that we support both ISO and DATA storage domain types, we need to make sure that the files are listed correctly. In this case we give the domains of ISO type the precedence over DATA ones. This change extends previous commit bbda3aa which made it possible for storage domains of type DATA to be considered valid. Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
-rw-r--r--src/ovirt-foreign-menu.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index 4d05dce..6ee3d86 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -727,8 +727,8 @@ static void storage_domains_fetched_cb(GObject *source_object,
OvirtForeignMenu *menu = OVIRT_FOREIGN_MENU(g_task_get_source_object(task));
OvirtCollection *collection = OVIRT_COLLECTION(source_object);
GHashTableIter iter;
- OvirtStorageDomain *domain;
- gboolean domain_valid = FALSE;
+ OvirtStorageDomain *domain, *valid_domain = NULL;
+ OvirtCollection *file_collection;
ovirt_collection_fetch_finish(collection, result, &error);
if (error != NULL) {
@@ -740,32 +740,36 @@ static void storage_domains_fetched_cb(GObject *source_object,
g_hash_table_iter_init(&iter, ovirt_collection_get_resources(collection));
while (g_hash_table_iter_next(&iter, NULL, (gpointer *)&domain)) {
- OvirtCollection *file_collection;
-
if (!storage_domain_validate(menu, domain))
continue;
- if (!domain_valid)
- domain_valid = TRUE;
+ /* Storage domain of type ISO has precedence over type DATA */
+ if (valid_domain != NULL) {
+ OvirtStorageDomainType domain_type, valid_type;
+ g_object_get(domain, "type", &domain_type, NULL);
+ g_object_get(valid_domain, "type", &valid_type, NULL);
+
+ if (domain_type > valid_type)
+ valid_domain = domain;
- file_collection = storage_domain_get_files(domain);
- if (!ovirt_foreign_menu_set_file_collection(menu, file_collection))
continue;
+ }
- break; /* There can only be one valid storage domain at a time,
- no need to iterate more on the list */
+ valid_domain = domain;
}
- if (menu->priv->files != NULL) {
- ovirt_foreign_menu_next_async_step(menu, task, STATE_STORAGE_DOMAIN);
- } else {
- const char *msg = domain_valid ? "Could not find ISO file collection"
+ file_collection = storage_domain_get_files(valid_domain);
+ if (!ovirt_foreign_menu_set_file_collection(menu, file_collection)) {
+ const char *msg = valid_domain ? "Could not find ISO file collection"
: "Could not find valid ISO storage domain";
g_debug("%s", msg);
g_task_return_new_error(task, OVIRT_ERROR, OVIRT_ERROR_FAILED, "%s", msg);
g_object_unref(task);
+ return;
}
+
+ ovirt_foreign_menu_next_async_step(menu, task, STATE_STORAGE_DOMAIN);
}