|
|
48c875 |
From 0e0342f3b37b2c4a312de55902e3cc16af58ccd4 Mon Sep 17 00:00:00 2001
|
|
|
48c875 |
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
|
|
48c875 |
Date: Fri, 4 Aug 2017 18:32:55 -0300
|
|
|
48c875 |
Subject: [PATCH] foreign-menu: Check if storage domain is active for data
|
|
|
48c875 |
center
|
|
|
48c875 |
|
|
|
48c875 |
This last patch of the series is where we actually check if the storage
|
|
|
48c875 |
domain is active in the data center the VM is associated with. It makes
|
|
|
48c875 |
use of g_strv_contains(), which is available only in glib version 2.44.
|
|
|
48c875 |
Compatibility code has been added if building against older versions
|
|
|
48c875 |
than required.
|
|
|
48c875 |
|
|
|
48c875 |
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1427467
|
|
|
48c875 |
https://bugzilla.redhat.com/show_bug.cgi?id=1428401
|
|
|
48c875 |
|
|
|
48c875 |
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
|
|
48c875 |
---
|
|
|
48c875 |
src/Makefile.am | 2 ++
|
|
|
48c875 |
src/glib-compat.c | 35 +++++++++++++++++++++++++++++++++++
|
|
|
48c875 |
src/glib-compat.h | 39 +++++++++++++++++++++++++++++++++++++++
|
|
|
48c875 |
src/ovirt-foreign-menu.c | 25 +++++++++++++++++++++++++
|
|
|
48c875 |
4 files changed, 101 insertions(+)
|
|
|
48c875 |
create mode 100644 src/glib-compat.c
|
|
|
48c875 |
create mode 100644 src/glib-compat.h
|
|
|
48c875 |
|
|
|
48c875 |
diff --git a/src/Makefile.am b/src/Makefile.am
|
|
|
48c875 |
index 9748277..b3eea67 100644
|
|
|
48c875 |
--- a/src/Makefile.am
|
|
|
48c875 |
+++ b/src/Makefile.am
|
|
|
48c875 |
@@ -54,6 +54,8 @@ libvirt_viewer_util_la_SOURCES = \
|
|
|
48c875 |
|
|
|
48c875 |
libvirt_viewer_la_SOURCES = \
|
|
|
48c875 |
$(BUILT_SOURCES) \
|
|
|
48c875 |
+ glib-compat.h \
|
|
|
48c875 |
+ glib-compat.c \
|
|
|
48c875 |
virt-viewer-auth.h \
|
|
|
48c875 |
virt-viewer-auth.c \
|
|
|
48c875 |
virt-viewer-app.h \
|
|
|
48c875 |
diff --git a/src/glib-compat.c b/src/glib-compat.c
|
|
|
48c875 |
new file mode 100644
|
|
|
48c875 |
index 0000000..62ac87e
|
|
|
48c875 |
--- /dev/null
|
|
|
48c875 |
+++ b/src/glib-compat.c
|
|
|
48c875 |
@@ -0,0 +1,35 @@
|
|
|
48c875 |
+/*
|
|
|
48c875 |
+ * This library is free software; you can redistribute it and/or
|
|
|
48c875 |
+ * modify it under the terms of the GNU Lesser General Public
|
|
|
48c875 |
+ * License as published by the Free Software Foundation; either
|
|
|
48c875 |
+ * version 2 of the License, or (at your option) any later version.
|
|
|
48c875 |
+ *
|
|
|
48c875 |
+ * This library is distributed in the hope that it will be useful,
|
|
|
48c875 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
48c875 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
48c875 |
+ * Lesser General Public License for more details.
|
|
|
48c875 |
+ *
|
|
|
48c875 |
+ * You should have received a copy of the GNU Lesser General Public
|
|
|
48c875 |
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
48c875 |
+ */
|
|
|
48c875 |
+#include <config.h>
|
|
|
48c875 |
+
|
|
|
48c875 |
+#include "glib-compat.h"
|
|
|
48c875 |
+
|
|
|
48c875 |
+#if !GLIB_CHECK_VERSION(2,44,0)
|
|
|
48c875 |
+gboolean
|
|
|
48c875 |
+g_strv_contains (const gchar * const *strv,
|
|
|
48c875 |
+ const gchar *str)
|
|
|
48c875 |
+{
|
|
|
48c875 |
+ g_return_val_if_fail (strv != NULL, FALSE);
|
|
|
48c875 |
+ g_return_val_if_fail (str != NULL, FALSE);
|
|
|
48c875 |
+
|
|
|
48c875 |
+ for (; *strv != NULL; strv++)
|
|
|
48c875 |
+ {
|
|
|
48c875 |
+ if (g_str_equal (str, *strv))
|
|
|
48c875 |
+ return TRUE;
|
|
|
48c875 |
+ }
|
|
|
48c875 |
+
|
|
|
48c875 |
+ return FALSE;
|
|
|
48c875 |
+}
|
|
|
48c875 |
+#endif
|
|
|
48c875 |
diff --git a/src/glib-compat.h b/src/glib-compat.h
|
|
|
48c875 |
new file mode 100644
|
|
|
48c875 |
index 0000000..f1b43ae
|
|
|
48c875 |
--- /dev/null
|
|
|
48c875 |
+++ b/src/glib-compat.h
|
|
|
48c875 |
@@ -0,0 +1,39 @@
|
|
|
48c875 |
+/*
|
|
|
48c875 |
+ * Virt Viewer: A virtual machine console viewer
|
|
|
48c875 |
+ *
|
|
|
48c875 |
+ * Copyright (C) 2017 Red Hat, Inc.
|
|
|
48c875 |
+ *
|
|
|
48c875 |
+ * This program is free software; you can redistribute it and/or modify
|
|
|
48c875 |
+ * it under the terms of the GNU General Public License as published by
|
|
|
48c875 |
+ * the Free Software Foundation; either version 2 of the License, or
|
|
|
48c875 |
+ * (at your option) any later version.
|
|
|
48c875 |
+ *
|
|
|
48c875 |
+ * This program is distributed in the hope that it will be useful,
|
|
|
48c875 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
48c875 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
48c875 |
+ * GNU General Public License for more details.
|
|
|
48c875 |
+ *
|
|
|
48c875 |
+ * You should have received a copy of the GNU General Public License
|
|
|
48c875 |
+ * along with this program; if not, write to the Free Software
|
|
|
48c875 |
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
48c875 |
+ *
|
|
|
48c875 |
+ * Author: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
|
|
48c875 |
+ */
|
|
|
48c875 |
+
|
|
|
48c875 |
+#include <config.h>
|
|
|
48c875 |
+
|
|
|
48c875 |
+#ifndef GLIB_COMPAT_H
|
|
|
48c875 |
+#define GLIB_COMPAT_H 1
|
|
|
48c875 |
+
|
|
|
48c875 |
+#include <glib.h>
|
|
|
48c875 |
+
|
|
|
48c875 |
+G_BEGIN_DECLS
|
|
|
48c875 |
+
|
|
|
48c875 |
+#if !GLIB_CHECK_VERSION(2,44,0)
|
|
|
48c875 |
+gboolean g_strv_contains (const gchar * const *strv,
|
|
|
48c875 |
+ const gchar *str);
|
|
|
48c875 |
+#endif
|
|
|
48c875 |
+
|
|
|
48c875 |
+G_END_DECLS
|
|
|
48c875 |
+
|
|
|
48c875 |
+#endif // GLIB_COMPAT_H
|
|
|
48c875 |
diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
|
|
|
48c875 |
index bf32773..b8ad179 100644
|
|
|
48c875 |
--- a/src/ovirt-foreign-menu.c
|
|
|
48c875 |
+++ b/src/ovirt-foreign-menu.c
|
|
|
48c875 |
@@ -29,6 +29,7 @@
|
|
|
48c875 |
|
|
|
48c875 |
#include "ovirt-foreign-menu.h"
|
|
|
48c875 |
#include "virt-viewer-util.h"
|
|
|
48c875 |
+#include "glib-compat.h"
|
|
|
48c875 |
|
|
|
48c875 |
typedef enum {
|
|
|
48c875 |
STATE_0,
|
|
|
48c875 |
@@ -618,6 +619,24 @@ static void ovirt_foreign_menu_fetch_vm_cdrom_async(OvirtForeignMenu *menu,
|
|
|
48c875 |
cdroms_fetched_cb, task);
|
|
|
48c875 |
}
|
|
|
48c875 |
|
|
|
48c875 |
+#ifdef HAVE_OVIRT_DATA_CENTER
|
|
|
48c875 |
+static gboolean storage_domain_attached_to_data_center(OvirtStorageDomain *domain,
|
|
|
48c875 |
+ OvirtDataCenter *data_center)
|
|
|
48c875 |
+{
|
|
|
48c875 |
+ GStrv data_center_ids;
|
|
|
48c875 |
+ char *data_center_guid;
|
|
|
48c875 |
+ gboolean match;
|
|
|
48c875 |
+
|
|
|
48c875 |
+ g_object_get(domain, "data-center-ids", &data_center_ids, NULL);
|
|
|
48c875 |
+ g_object_get(data_center, "guid", &data_center_guid, NULL);
|
|
|
48c875 |
+ match = g_strv_contains((const gchar * const *) data_center_ids, data_center_guid);
|
|
|
48c875 |
+ g_strfreev(data_center_ids);
|
|
|
48c875 |
+ g_free(data_center_guid);
|
|
|
48c875 |
+
|
|
|
48c875 |
+ return match;
|
|
|
48c875 |
+}
|
|
|
48c875 |
+#endif
|
|
|
48c875 |
+
|
|
|
48c875 |
|
|
|
48c875 |
static void storage_domains_fetched_cb(GObject *source_object,
|
|
|
48c875 |
GAsyncResult *result,
|
|
|
48c875 |
@@ -653,6 +672,12 @@ static void storage_domains_fetched_cb(GObject *source_object,
|
|
|
48c875 |
continue;
|
|
|
48c875 |
}
|
|
|
48c875 |
|
|
|
48c875 |
+#ifdef HAVE_OVIRT_DATA_CENTER
|
|
|
48c875 |
+ if (!storage_domain_attached_to_data_center(domain, menu->priv->data_center)) {
|
|
|
48c875 |
+ continue;
|
|
|
48c875 |
+ }
|
|
|
48c875 |
+#endif
|
|
|
48c875 |
+
|
|
|
48c875 |
file_collection = ovirt_storage_domain_get_files(domain);
|
|
|
48c875 |
if (file_collection != NULL) {
|
|
|
48c875 |
if (menu->priv->files) {
|
|
|
48c875 |
--
|
|
|
48c875 |
2.13.6
|
|
|
48c875 |
|