|
|
0f5b8b |
From f5936a87795dfdefee10f87672abcf8f9175a7c9 Mon Sep 17 00:00:00 2001
|
|
|
0f5b8b |
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
|
|
0f5b8b |
Date: Mon, 15 Jun 2020 20:53:18 -0300
|
|
|
0f5b8b |
Subject: [PATCH virt-viewer] ovirt-foreign-menu: Take into account
|
|
|
0f5b8b |
StorageDomains of type DATA
|
|
|
0f5b8b |
|
|
|
0f5b8b |
Now that we support both ISO and DATA storage domain types, we need to
|
|
|
0f5b8b |
make sure that the files are listed correctly. In this case we give the
|
|
|
0f5b8b |
domains of ISO type the precedence over DATA ones.
|
|
|
0f5b8b |
|
|
|
0f5b8b |
This change extends previous commit bbda3aa which made it possible for
|
|
|
0f5b8b |
storage domains of type DATA to be considered valid.
|
|
|
0f5b8b |
|
|
|
0f5b8b |
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
|
|
0f5b8b |
---
|
|
|
0f5b8b |
src/ovirt-foreign-menu.c | 39 ++++++++++++++++++++++-----------------
|
|
|
0f5b8b |
1 file changed, 22 insertions(+), 17 deletions(-)
|
|
|
0f5b8b |
|
|
|
0f5b8b |
diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
|
|
|
0f5b8b |
index 3c67f1a..8d02a79 100644
|
|
|
0f5b8b |
--- a/src/ovirt-foreign-menu.c
|
|
|
0f5b8b |
+++ b/src/ovirt-foreign-menu.c
|
|
|
0f5b8b |
@@ -734,6 +734,9 @@ static gboolean set_file_collection_from_toplevel_storage_domain(OvirtForeignMen
|
|
|
0f5b8b |
OvirtResource *resource = NULL;
|
|
|
0f5b8b |
gchar *href = NULL, *id = NULL;
|
|
|
0f5b8b |
|
|
|
0f5b8b |
+ if (domain == NULL)
|
|
|
0f5b8b |
+ return FALSE;
|
|
|
0f5b8b |
+
|
|
|
0f5b8b |
g_object_get(domain, "guid", &id, NULL);
|
|
|
0f5b8b |
href = g_strdup_printf("/ovirt-engine/api/storagedomains/%s", id);
|
|
|
0f5b8b |
resource = g_initable_new(OVIRT_TYPE_STORAGE_DOMAIN, NULL, &error, "guid", id, "href", href, NULL);
|
|
|
0f5b8b |
@@ -767,8 +770,8 @@ static void storage_domains_fetched_cb(GObject *source_object,
|
|
|
0f5b8b |
OvirtForeignMenu *menu = OVIRT_FOREIGN_MENU(g_task_get_source_object(task));
|
|
|
0f5b8b |
OvirtCollection *collection = OVIRT_COLLECTION(source_object);
|
|
|
0f5b8b |
GHashTableIter iter;
|
|
|
0f5b8b |
- OvirtStorageDomain *domain;
|
|
|
0f5b8b |
- gboolean domain_valid = FALSE;
|
|
|
0f5b8b |
+ OvirtStorageDomain *domain, *valid_domain = NULL;
|
|
|
0f5b8b |
+ OvirtCollection *file_collection;
|
|
|
0f5b8b |
|
|
|
0f5b8b |
ovirt_collection_fetch_finish(collection, result, &error);
|
|
|
0f5b8b |
if (error != NULL) {
|
|
|
0f5b8b |
@@ -780,35 +783,37 @@ static void storage_domains_fetched_cb(GObject *source_object,
|
|
|
0f5b8b |
|
|
|
0f5b8b |
g_hash_table_iter_init(&iter, ovirt_collection_get_resources(collection));
|
|
|
0f5b8b |
while (g_hash_table_iter_next(&iter, NULL, (gpointer *)&domain)) {
|
|
|
0f5b8b |
- OvirtCollection *file_collection;
|
|
|
0f5b8b |
-
|
|
|
0f5b8b |
if (!storage_domain_validate(menu, domain))
|
|
|
0f5b8b |
continue;
|
|
|
0f5b8b |
|
|
|
0f5b8b |
- if (!domain_valid)
|
|
|
0f5b8b |
- domain_valid = TRUE;
|
|
|
0f5b8b |
+ /* Storage domain of type ISO has precedence over type DATA */
|
|
|
0f5b8b |
+ if (valid_domain != NULL) {
|
|
|
0f5b8b |
+ OvirtStorageDomainType domain_type, valid_type;
|
|
|
0f5b8b |
+ g_object_get(domain, "type", &domain_type, NULL);
|
|
|
0f5b8b |
+ g_object_get(valid_domain, "type", &valid_type, NULL);
|
|
|
0f5b8b |
|
|
|
0f5b8b |
- file_collection = storage_domain_get_files(domain);
|
|
|
0f5b8b |
- if (!ovirt_foreign_menu_set_file_collection(menu, file_collection)) {
|
|
|
0f5b8b |
- /* Retry with toplevel storage domain */
|
|
|
0f5b8b |
- if (!set_file_collection_from_toplevel_storage_domain(menu, domain))
|
|
|
0f5b8b |
- continue;
|
|
|
0f5b8b |
+ if (domain_type > valid_type)
|
|
|
0f5b8b |
+ valid_domain = domain;
|
|
|
0f5b8b |
+
|
|
|
0f5b8b |
+ continue;
|
|
|
0f5b8b |
}
|
|
|
0f5b8b |
|
|
|
0f5b8b |
- break; /* There can only be one valid storage domain at a time,
|
|
|
0f5b8b |
- no need to iterate more on the list */
|
|
|
0f5b8b |
+ valid_domain = domain;
|
|
|
0f5b8b |
}
|
|
|
0f5b8b |
|
|
|
0f5b8b |
- if (menu->priv->files != NULL) {
|
|
|
0f5b8b |
- ovirt_foreign_menu_next_async_step(menu, task, STATE_STORAGE_DOMAIN);
|
|
|
0f5b8b |
- } else {
|
|
|
0f5b8b |
- const char *msg = domain_valid ? "Could not find ISO file collection"
|
|
|
0f5b8b |
+ file_collection = storage_domain_get_files(valid_domain);
|
|
|
0f5b8b |
+ if (!ovirt_foreign_menu_set_file_collection(menu, file_collection) &&
|
|
|
0f5b8b |
+ !set_file_collection_from_toplevel_storage_domain(menu, valid_domain)) { /* Retry with toplevel storage domain */
|
|
|
0f5b8b |
+ const char *msg = valid_domain ? "Could not find ISO file collection"
|
|
|
0f5b8b |
: "Could not find valid ISO storage domain";
|
|
|
0f5b8b |
|
|
|
0f5b8b |
g_debug("%s", msg);
|
|
|
0f5b8b |
g_task_return_new_error(task, OVIRT_ERROR, OVIRT_ERROR_FAILED, "%s", msg);
|
|
|
0f5b8b |
g_object_unref(task);
|
|
|
0f5b8b |
+ return;
|
|
|
0f5b8b |
}
|
|
|
0f5b8b |
+
|
|
|
0f5b8b |
+ ovirt_foreign_menu_next_async_step(menu, task, STATE_STORAGE_DOMAIN);
|
|
|
0f5b8b |
}
|
|
|
0f5b8b |
|
|
|
0f5b8b |
|
|
|
0f5b8b |
--
|
|
|
0f5b8b |
2.26.2
|
|
|
0f5b8b |
|