59 lines
2.1 KiB
Diff
59 lines
2.1 KiB
Diff
From ae35866aa4ff8b880b87d7a8c5ad82f539bb0770 Mon Sep 17 00:00:00 2001
|
|
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
|
Date: Tue, 31 Jul 2018 11:01:55 -0300
|
|
Subject: [PATCH virt-viewer] ovirt-foreign-menu: Factor out code to set file
|
|
collection
|
|
|
|
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
|
Acked-by: Victor Toso <victortoso@redhat.com>
|
|
---
|
|
src/ovirt-foreign-menu.c | 25 +++++++++++++++++--------
|
|
1 file changed, 17 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
|
|
index a729934..4c1ea06 100644
|
|
--- a/src/ovirt-foreign-menu.c
|
|
+++ b/src/ovirt-foreign-menu.c
|
|
@@ -680,6 +680,18 @@ static gboolean storage_domain_validate(OvirtForeignMenu *menu G_GNUC_UNUSED,
|
|
return ret;
|
|
}
|
|
|
|
+static gboolean ovirt_foreign_menu_set_file_collection(OvirtForeignMenu *menu, OvirtCollection *file_collection)
|
|
+{
|
|
+ g_return_val_if_fail(file_collection != NULL, FALSE);
|
|
+
|
|
+ if (menu->priv->files) {
|
|
+ g_object_unref(G_OBJECT(menu->priv->files));
|
|
+ }
|
|
+ menu->priv->files = g_object_ref(G_OBJECT(file_collection));
|
|
+ g_debug("Set VM files to %p", menu->priv->files);
|
|
+ return TRUE;
|
|
+}
|
|
+
|
|
static void storage_domains_fetched_cb(GObject *source_object,
|
|
GAsyncResult *result,
|
|
gpointer user_data)
|
|
@@ -711,14 +723,11 @@ static void storage_domains_fetched_cb(GObject *source_object,
|
|
domain_valid = TRUE;
|
|
|
|
file_collection = ovirt_storage_domain_get_files(domain);
|
|
- if (file_collection != NULL) {
|
|
- if (menu->priv->files) {
|
|
- g_object_unref(G_OBJECT(menu->priv->files));
|
|
- }
|
|
- menu->priv->files = g_object_ref(G_OBJECT(file_collection));
|
|
- g_debug("Set VM files to %p", menu->priv->files);
|
|
- break;
|
|
- }
|
|
+ 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 */
|
|
}
|
|
|
|
if (menu->priv->files != NULL) {
|
|
--
|
|
2.21.0
|
|
|