Commit 92b53adb authored by Rocky Automation's avatar Rocky Automation 📺
Browse files

import virt-viewer-9.0-11.el8

parent c5eff90e
From 11ec065ce2aea7d0529539e4af1a95d8e210ed27 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20Jank=C5=AF?= <jjanku@redhat.com>
Date: Wed, 3 Feb 2021 23:27:50 +0100
Subject: [PATCH] vnc-session: save message from "vnc-error" for "vnc-disconnected"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
"vnc-error" is always followed by "vnc-disconnected".
So save the error message and use it in "vnc-disconnected" callback.
"session-disconnected" already allows us to set a string
with details on why the disconnection happened.
This approach is also similar to the one in spice session
(GError is saved in virt_viewer_session_spice_channel_destroyed).
Signed-off-by: Jakub Janků <jjanku@redhat.com>
---
src/virt-viewer-session-vnc.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/virt-viewer-session-vnc.c b/src/virt-viewer-session-vnc.c
index 3d11112..7d6dfb2 100644
--- a/src/virt-viewer-session-vnc.c
+++ b/src/virt-viewer-session-vnc.c
@@ -40,6 +40,7 @@ struct _VirtViewerSessionVncPrivate {
/* XXX we should really just have a VncConnection */
VncDisplay *vnc;
gboolean auth_dialog_cancelled;
+ gchar *error_msg;
};
G_DEFINE_TYPE_WITH_PRIVATE(VirtViewerSessionVnc, virt_viewer_session_vnc, VIRT_VIEWER_TYPE_SESSION)
@@ -63,6 +64,7 @@ virt_viewer_session_vnc_finalize(GObject *obj)
}
if (vnc->priv->main_window)
g_object_unref(vnc->priv->main_window);
+ g_free(vnc->priv->error_msg);
G_OBJECT_CLASS(virt_viewer_session_vnc_parent_class)->finalize(obj);
}
@@ -122,7 +124,7 @@ virt_viewer_session_vnc_disconnected(VncDisplay *vnc G_GNUC_UNUSED,
virt_viewer_session_clear_displays(VIRT_VIEWER_SESSION(session));
display = virt_viewer_display_vnc_new(session, session->priv->vnc);
g_debug("Disconnected");
- g_signal_emit_by_name(session, "session-disconnected", NULL);
+ g_signal_emit_by_name(session, "session-disconnected", session->priv->error_msg);
virt_viewer_display_set_enabled(VIRT_VIEWER_DISPLAY(display), FALSE);
virt_viewer_display_set_show_hint(VIRT_VIEWER_DISPLAY(display),
VIRT_VIEWER_DISPLAY_SHOW_HINT_READY, FALSE);
@@ -135,6 +137,10 @@ virt_viewer_session_vnc_error(VncDisplay *vnc G_GNUC_UNUSED,
{
g_warning("vnc-session: got vnc error %s", msg);
g_signal_emit_by_name(session, "session-error", msg);
+ /* "vnc-error" is always followed by "vnc-disconnected",
+ * so save the error for that signal */
+ g_free(session->priv->error_msg);
+ session->priv->error_msg = g_strdup(msg);
}
static void
@@ -162,8 +168,9 @@ virt_viewer_session_vnc_bell(VncDisplay *vnc G_GNUC_UNUSED,
static void
virt_viewer_session_vnc_auth_unsupported(VncDisplay *vnc G_GNUC_UNUSED,
unsigned int authType,
- VirtViewerSession *session)
+ VirtViewerSessionVnc *session)
{
+ g_clear_pointer(&session->priv->error_msg, g_free);
gchar *msg = g_strdup_printf(_("Unsupported authentication type %u"),
authType);
g_signal_emit_by_name(session, "session-auth-unsupported", msg);
@@ -173,9 +180,9 @@ virt_viewer_session_vnc_auth_unsupported(VncDisplay *vnc G_GNUC_UNUSED,
static void
virt_viewer_session_vnc_auth_failure(VncDisplay *vnc G_GNUC_UNUSED,
const gchar *reason,
- VirtViewerSession *session)
+ VirtViewerSessionVnc *session)
{
-
+ g_clear_pointer(&session->priv->error_msg, g_free);
g_signal_emit_by_name(session, "session-auth-refused", reason);
}
--
2.29.2
From 8bc91ac80f9c5c7df30f25e35946be0869be3db5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20Jank=C5=AF?= <jjanku@redhat.com>
Date: Wed, 10 Feb 2021 10:58:57 +0100
Subject: [PATCH] session: remove "session-error" signal
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This partially reverts commit de5cd71.
Problem with that commit is, that it practically renders
the "session-auth-*" signals from vnc session useless.
That's because gtk-vnc currently emits "vnc-error" before each
"vnc-auth-*" signal and the error callback in virt-viewer-app.c
calls virt_viewer_app_disconnected(), which in turn closes
the session.
As a consequence, virt-viewer never retries authentication
with vnc, it simply exits.
Since the last commit, vnc, similarly to spice, emits
"session-disconnected" with the appropriate error message. Thus
there's no need to maintain separate "session-error" signal
for now.
With vnc, this error message is shown to the user in a dialog,
if the disconnect happened during the init phase.
"session-auth-*" callbacks create their own dialogs, so
initialized must be set to TRUE to avoid having a dialog
displayed twice.
Related:
https://bugzilla.redhat.com/show_bug.cgi?id=1911224
Signed-off-by: Jakub Janků <jjanku@redhat.com>
---
src/virt-viewer-app.c | 33 +++++++++++----------------------
src/virt-viewer-session-vnc.c | 1 -
src/virt-viewer-session.c | 9 ---------
3 files changed, 11 insertions(+), 32 deletions(-)
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index e42535b..2bb780f 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -70,9 +70,6 @@ void virt_viewer_app_about_delete(GtkWidget *dialog, void *dummy, VirtViewerApp
/* Internal methods */
static void virt_viewer_app_connected(VirtViewerSession *session,
VirtViewerApp *self);
-static void virt_viewer_app_error(VirtViewerSession *session G_GNUC_UNUSED,
- const gchar *msg,
- VirtViewerApp *self);
static void virt_viewer_app_initialized(VirtViewerSession *session,
VirtViewerApp *self);
static void virt_viewer_app_disconnected(VirtViewerSession *session,
@@ -745,7 +742,8 @@ static void hide_one_window(gpointer value,
{
VirtViewerApp* self = VIRT_VIEWER_APP(user_data);
VirtViewerAppPrivate *priv = self->priv;
- gboolean connect_error = !priv->connected && !priv->cancelled;
+ gboolean connect_error = !priv->cancelled &&
+ !(VIRT_VIEWER_IS_SESSION_VNC(priv->session) ? priv->initialized : priv->connected);
if (connect_error || self->priv->main_window != value)
virt_viewer_window_hide(VIRT_VIEWER_WINDOW(value));
@@ -1342,8 +1340,6 @@ virt_viewer_app_create_session(VirtViewerApp *self, const gchar *type, GError **
g_signal_connect(priv->session, "session-initialized",
G_CALLBACK(virt_viewer_app_initialized), self);
- g_signal_connect(priv->session, "session-error",
- G_CALLBACK(virt_viewer_app_error), self);
g_signal_connect(priv->session, "session-connected",
G_CALLBACK(virt_viewer_app_connected), self);
g_signal_connect(priv->session, "session-disconnected",
@@ -1721,7 +1717,8 @@ virt_viewer_app_disconnected(VirtViewerSession *session G_GNUC_UNUSED, const gch
VirtViewerApp *self)
{
VirtViewerAppPrivate *priv = self->priv;
- gboolean connect_error = !priv->connected && !priv->cancelled;
+ gboolean connect_error = !priv->cancelled &&
+ !(VIRT_VIEWER_IS_SESSION_VNC(session) ? priv->initialized : priv->connected);
if (!priv->kiosk)
virt_viewer_app_hide_all_windows(self);
@@ -1744,21 +1741,6 @@ virt_viewer_app_disconnected(VirtViewerSession *session G_GNUC_UNUSED, const gch
virt_viewer_app_deactivate(self, connect_error);
}
-static void
-virt_viewer_app_error(VirtViewerSession *session G_GNUC_UNUSED,
- const gchar *msg,
- VirtViewerApp *self)
-{
- VirtViewerAppPrivate *priv = self->priv;
-
- /* Do not open a dialog if the connection was initialized
- * This happens when the VNC server closes the connection */
- if (!priv->initialized)
- priv->connected = FALSE; /* display error dialog */
-
- virt_viewer_app_disconnected(session, msg, self);
-}
-
static void virt_viewer_app_cancelled(VirtViewerSession *session,
VirtViewerApp *self)
{
@@ -1781,15 +1763,22 @@ static void virt_viewer_app_auth_refused(VirtViewerSession *session,
* VirtViewerApp needs to schedule a new connection to retry */
priv->authretry = (!virt_viewer_session_can_retry_auth(session) &&
!virt_viewer_session_get_file(session));
+
+ /* don't display another dialog in virt_viewer_app_disconnected when using VNC */
+ priv->initialized = TRUE;
}
static void virt_viewer_app_auth_unsupported(VirtViewerSession *session G_GNUC_UNUSED,
const char *msg,
VirtViewerApp *self)
{
+ VirtViewerAppPrivate *priv = virt_viewer_app_get_instance_private(self);
virt_viewer_app_simple_message_dialog(self,
_("Unable to authenticate with remote desktop server: %s"),
msg);
+
+ /* don't display another dialog in virt_viewer_app_disconnected when using VNC */
+ priv->initialized = TRUE;
}
static void virt_viewer_app_usb_failed(VirtViewerSession *session G_GNUC_UNUSED,
diff --git a/src/virt-viewer-session-vnc.c b/src/virt-viewer-session-vnc.c
index 7d6dfb2..aa29d00 100644
--- a/src/virt-viewer-session-vnc.c
+++ b/src/virt-viewer-session-vnc.c
@@ -136,7 +136,6 @@ virt_viewer_session_vnc_error(VncDisplay *vnc G_GNUC_UNUSED,
VirtViewerSessionVnc *session)
{
g_warning("vnc-session: got vnc error %s", msg);
- g_signal_emit_by_name(session, "session-error", msg);
/* "vnc-error" is always followed by "vnc-disconnected",
* so save the error for that signal */
g_free(session->priv->error_msg);
diff --git a/src/virt-viewer-session.c b/src/virt-viewer-session.c
index 639d7a4..4171f3d 100644
--- a/src/virt-viewer-session.c
+++ b/src/virt-viewer-session.c
@@ -276,15 +276,6 @@ virt_viewer_session_class_init(VirtViewerSessionClass *class)
G_TYPE_NONE,
0);
- g_signal_new("session-error",
- G_OBJECT_CLASS_TYPE(object_class),
- G_SIGNAL_RUN_FIRST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING);
g_signal_new("session-disconnected",
G_OBJECT_CLASS_TYPE(object_class),
G_SIGNAL_RUN_FIRST,
--
2.29.2
From 5a55d43796385c9d919ce4c8eb92c2e5e614937c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20Jank=C5=AF?= <jjanku@redhat.com>
Date: Wed, 3 Feb 2021 21:10:09 +0100
Subject: [PATCH] vnc-session: use g_signal_connect_object
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
If the VncDisplay emits a signal and the VirtViewerSessionVnc
instance is no longer valid, using the pointer inside one of the
callbacks can lead to segfault.
To prevent that, use g_signal_connect_object instead of
g_signal_connect.
Related:
https://bugzilla.redhat.com/show_bug.cgi?id=1911224
Signed-off-by: Jakub Janků <jjanku@redhat.com>
---
src/virt-viewer-session-vnc.c | 72 +++++++++++++++++------------------
1 file changed, 36 insertions(+), 36 deletions(-)
diff --git a/src/virt-viewer-session-vnc.c b/src/virt-viewer-session-vnc.c
index aa29d00..5730e9d 100644
--- a/src/virt-viewer-session-vnc.c
+++ b/src/virt-viewer-session-vnc.c
@@ -395,26 +395,26 @@ virt_viewer_session_vnc_close(VirtViewerSession* session)
self->priv->vnc = VNC_DISPLAY(vnc_display_new());
g_object_ref_sink(self->priv->vnc);
- g_signal_connect(self->priv->vnc, "vnc-connected",
- G_CALLBACK(virt_viewer_session_vnc_connected), session);
- g_signal_connect(self->priv->vnc, "vnc-initialized",
- G_CALLBACK(virt_viewer_session_vnc_initialized), session);
- g_signal_connect(self->priv->vnc, "vnc-disconnected",
- G_CALLBACK(virt_viewer_session_vnc_disconnected), session);
- g_signal_connect(self->priv->vnc, "vnc-error",
- G_CALLBACK(virt_viewer_session_vnc_error), session);
+ g_signal_connect_object(self->priv->vnc, "vnc-connected",
+ G_CALLBACK(virt_viewer_session_vnc_connected), session, 0);
+ g_signal_connect_object(self->priv->vnc, "vnc-initialized",
+ G_CALLBACK(virt_viewer_session_vnc_initialized), session, 0);
+ g_signal_connect_object(self->priv->vnc, "vnc-disconnected",
+ G_CALLBACK(virt_viewer_session_vnc_disconnected), session, 0);
+ g_signal_connect_object(self->priv->vnc, "vnc-error",
+ G_CALLBACK(virt_viewer_session_vnc_error), session, 0);
- g_signal_connect(self->priv->vnc, "vnc-bell",
- G_CALLBACK(virt_viewer_session_vnc_bell), session);
- g_signal_connect(self->priv->vnc, "vnc-auth-failure",
- G_CALLBACK(virt_viewer_session_vnc_auth_failure), session);
- g_signal_connect(self->priv->vnc, "vnc-auth-unsupported",
- G_CALLBACK(virt_viewer_session_vnc_auth_unsupported), session);
- g_signal_connect(self->priv->vnc, "vnc-server-cut-text",
- G_CALLBACK(virt_viewer_session_vnc_cut_text), session);
+ g_signal_connect_object(self->priv->vnc, "vnc-bell",
+ G_CALLBACK(virt_viewer_session_vnc_bell), session, 0);
+ g_signal_connect_object(self->priv->vnc, "vnc-auth-failure",
+ G_CALLBACK(virt_viewer_session_vnc_auth_failure), session, 0);
+ g_signal_connect_object(self->priv->vnc, "vnc-auth-unsupported",
+ G_CALLBACK(virt_viewer_session_vnc_auth_unsupported), session, 0);
+ g_signal_connect_object(self->priv->vnc, "vnc-server-cut-text",
+ G_CALLBACK(virt_viewer_session_vnc_cut_text), session, 0);
- g_signal_connect(self->priv->vnc, "vnc-auth-credential",
- G_CALLBACK(virt_viewer_session_vnc_auth_credential), session);
+ g_signal_connect_object(self->priv->vnc, "vnc-auth-credential",
+ G_CALLBACK(virt_viewer_session_vnc_auth_credential), session, 0);
}
@@ -432,24 +432,24 @@ virt_viewer_session_vnc_new(VirtViewerApp *app, GtkWindow *main_window)
- g_signal_connect(session->priv->vnc, "vnc-connected",
- G_CALLBACK(virt_viewer_session_vnc_connected), session);
- g_signal_connect(session->priv->vnc, "vnc-initialized",
- G_CALLBACK(virt_viewer_session_vnc_initialized), session);
- g_signal_connect(session->priv->vnc, "vnc-disconnected",
- G_CALLBACK(virt_viewer_session_vnc_disconnected), session);
- g_signal_connect(session->priv->vnc, "vnc-error",
- G_CALLBACK(virt_viewer_session_vnc_error), session);
+ g_signal_connect_object(session->priv->vnc, "vnc-connected",
+ G_CALLBACK(virt_viewer_session_vnc_connected), session, 0);
+ g_signal_connect_object(session->priv->vnc, "vnc-initialized",
+ G_CALLBACK(virt_viewer_session_vnc_initialized), session, 0);
+ g_signal_connect_object(session->priv->vnc, "vnc-disconnected",
+ G_CALLBACK(virt_viewer_session_vnc_disconnected), session, 0);
+ g_signal_connect_object(session->priv->vnc, "vnc-error",
+ G_CALLBACK(virt_viewer_session_vnc_error), session, 0);
- g_signal_connect(session->priv->vnc, "vnc-bell",
- G_CALLBACK(virt_viewer_session_vnc_bell), session);
- g_signal_connect(session->priv->vnc, "vnc-auth-failure",
- G_CALLBACK(virt_viewer_session_vnc_auth_failure), session);
- g_signal_connect(session->priv->vnc, "vnc-auth-unsupported",
- G_CALLBACK(virt_viewer_session_vnc_auth_unsupported), session);
- g_signal_connect(session->priv->vnc, "vnc-server-cut-text",
- G_CALLBACK(virt_viewer_session_vnc_cut_text), session);
+ g_signal_connect_object(session->priv->vnc, "vnc-bell",
+ G_CALLBACK(virt_viewer_session_vnc_bell), session, 0);
+ g_signal_connect_object(session->priv->vnc, "vnc-auth-failure",
+ G_CALLBACK(virt_viewer_session_vnc_auth_failure), session, 0);
+ g_signal_connect_object(session->priv->vnc, "vnc-auth-unsupported",
+ G_CALLBACK(virt_viewer_session_vnc_auth_unsupported), session, 0);
+ g_signal_connect_object(session->priv->vnc, "vnc-server-cut-text",
+ G_CALLBACK(virt_viewer_session_vnc_cut_text), session, 0);
- g_signal_connect(session->priv->vnc, "vnc-auth-credential",
- G_CALLBACK(virt_viewer_session_vnc_auth_credential), session);
+ g_signal_connect_object(session->priv->vnc, "vnc-auth-credential",
+ G_CALLBACK(virt_viewer_session_vnc_auth_credential), session, 0);
return VIRT_VIEWER_SESSION(session);
}
--
2.29.2
From 81129f8eb11e86ccc9329b5a7cb4e319a4db7e04 Mon Sep 17 00:00:00 2001
From: Victor Toso <victortoso@redhat.com>
Date: Mon, 8 Mar 2021 16:52:06 +0100
Subject: [PATCH] build: fix build without gtk-vnc
Without gtk-vnc we get implicit function declaration for
VIRT_VIEWER_IS_SESSION_VNC. Introduced at 8bc91ac "session: remove
"session-error" signal" in 2021-02-18
As we are already using #ifdef here, I've also changed the ternary to
an if for clarity.
Signed-off-by: Victor Toso <victortoso@redhat.com>
---
src/virt-viewer-app.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 5d3b395..b20d11a 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -748,8 +748,12 @@ static void hide_one_window(gpointer value,
{
VirtViewerApp* self = VIRT_VIEWER_APP(user_data);
VirtViewerAppPrivate *priv = self->priv;
- gboolean connect_error = !priv->cancelled &&
- !(VIRT_VIEWER_IS_SESSION_VNC(priv->session) ? priv->initialized : priv->connected);
+ gboolean connect_error = !priv->cancelled && !priv->connected;
+#ifdef HAVE_GTK_VNC
+ if (VIRT_VIEWER_IS_SESSION_VNC(priv->session)) {
+ connect_error = !priv->cancelled && !priv->initialized;
+ }
+#endif
if (connect_error || self->priv->main_window != value)
virt_viewer_window_hide(VIRT_VIEWER_WINDOW(value));
@@ -1773,8 +1777,12 @@ virt_viewer_app_disconnected(VirtViewerSession *session G_GNUC_UNUSED, const gch
VirtViewerApp *self)
{
VirtViewerAppPrivate *priv = self->priv;
- gboolean connect_error = !priv->cancelled &&
- !(VIRT_VIEWER_IS_SESSION_VNC(session) ? priv->initialized : priv->connected);
+ gboolean connect_error = !priv->cancelled && !priv->connected;
+#ifdef HAVE_GTK_VNC
+ if (VIRT_VIEWER_IS_SESSION_VNC(priv->session)) {
+ connect_error = !priv->cancelled && !priv->initialized;
+ }
+#endif
if (!priv->kiosk)
virt_viewer_app_hide_all_windows(self);
--
2.29.2
From 0522f86a3e8420b1a2e32dbdf798d4667c91f036 Mon Sep 17 00:00:00 2001
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
Date: Wed, 1 Jul 2020 11:16:09 -0300
Subject: [PATCH virt-viewer] ovirt-foreign-menu: Support changing ISO from
Data StorageDomain
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1835640
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
---
src/glib-compat.c | 21 +++++
src/glib-compat.h | 5 +
src/ovirt-foreign-menu.c | 104 +++++++++++++++------
src/ovirt-foreign-menu.h | 3 +
src/remote-viewer-iso-list-dialog.c | 46 +++++----
src/resources/ui/remote-viewer-iso-list.ui | 2 +
6 files changed, 135 insertions(+), 46 deletions(-)
diff --git a/src/glib-compat.c b/src/glib-compat.c
index 62ac87e..17122f6 100644
--- a/src/glib-compat.c
+++ b/src/glib-compat.c
@@ -33,3 +33,24 @@ g_strv_contains (const gchar * const *strv,
return FALSE;
}
#endif
+
+#if !GLIB_CHECK_VERSION(2,60,0)
+gboolean
+g_strv_equal (const gchar * const *strv1,
+ const gchar * const *strv2)
+{
+ g_return_val_if_fail (strv1 != NULL, FALSE);
+ g_return_val_if_fail (strv2 != NULL, FALSE);
+
+ if (strv1 == strv2)
+ return TRUE;
+
+ for (; *strv1 != NULL && *strv2 != NULL; strv1++, strv2++)
+ {
+ if (!g_str_equal (*strv1, *strv2))
+ return FALSE;
+ }
+
+ return (*strv1 == NULL && *strv2 == NULL);
+}
+#endif
diff --git a/src/glib-compat.h b/src/glib-compat.h
index f1b43ae..a89ae04 100644
--- a/src/glib-compat.h
+++ b/src/glib-compat.h
@@ -34,6 +34,11 @@ gboolean g_strv_contains (const gchar * const *strv,
const gchar *str);
#endif
+#if !GLIB_CHECK_VERSION(2,60,0)
+gboolean g_strv_equal (const gchar * const *strv1,
+ const gchar * const *strv2);
+#endif
+
G_END_DECLS
#endif // GLIB_COMPAT_H
diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index 8d02a79..a6745d3 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -77,9 +77,9 @@ struct _OvirtForeignMenuPrivate {
/* The next 2 members are used when changing the ISO image shown in
* a VM */
/* Name of the ISO which is currently used by the VM OvirtCdrom */
- char *current_iso_name;
+ GStrv current_iso_info;
/* Name of the ISO we are trying to insert in the VM OvirtCdrom */
- char *next_iso_name;
+ GStrv next_iso_info;
GList *iso_names;
};
@@ -112,6 +112,40 @@ ovirt_foreign_menu_get_current_iso_name(OvirtForeignMenu *foreign_menu)
return name;
}
+static GStrv
+iso_info_new(const gchar *name, const gchar *id)
+{
+ GStrv info = g_new0(gchar *, 3);
+ info[0] = g_strdup(name);
+ info[1] = id != NULL ? g_strdup(id) : g_strdup(name);
+ return info;
+}
+
+
+GStrv
+ovirt_foreign_menu_get_current_iso_info(OvirtForeignMenu *menu)
+{
+ if (menu->priv->cdrom == NULL)
+ return NULL;
+
+ return menu->priv->current_iso_info;
+}
+
+static void
+ovirt_foreign_menu_set_current_iso_info(OvirtForeignMenu *menu, const gchar *name, const gchar *id)
+{
+ GStrv info = NULL;
+
+ g_debug("Setting current ISO to: name '%s', id '%s'", name, id);
+ if (menu->priv->cdrom == NULL)
+ return;
+
+ if (name != NULL)
+ info = iso_info_new(name, id);
+
+ g_strfreev(menu->priv->current_iso_info);
+ menu->priv->current_iso_info = info;
+}
GList*
ovirt_foreign_menu_get_iso_names(OvirtForeignMenu *foreign_menu)
@@ -211,8 +245,8 @@ ovirt_foreign_menu_dispose(GObject *obj)
self->priv->iso_names = NULL;
}
- g_clear_pointer(&self->priv->current_iso_name, g_free);
- g_clear_pointer(&self->priv->next_iso_name, g_free);
+ g_clear_pointer(&self->priv->current_iso_info, g_strfreev);
+ g_clear_pointer(&self->priv->next_iso_info, g_strfreev);
G_OBJECT_CLASS(ovirt_foreign_menu_parent_class)->dispose(obj);
}
@@ -402,21 +436,21 @@ static void iso_name_set_cb(GObject *source_object,
updated = ovirt_cdrom_update_finish(OVIRT_CDROM(source_object),
result, &error);
if (updated) {
- g_debug("Finished updating cdrom content: %s", foreign_menu->priv->next_iso_name);
- g_free(foreign_menu->priv->current_iso_name);
- foreign_menu->priv->current_iso_name = foreign_menu->priv->next_iso_name;
- foreign_menu->priv->next_iso_name = NULL;
+ g_debug("Finished updating cdrom content");
+ g_strfreev(foreign_menu->priv->current_iso_info);
+ foreign_menu->priv->current_iso_info = foreign_menu->priv->next_iso_info;
+ foreign_menu->priv->next_iso_info = NULL;
g_task_return_boolean(task, TRUE);
goto end;
}
/* Reset old state back as we were not successful in switching to
* the new ISO */
- g_debug("setting OvirtCdrom:file back to '%s'",
- foreign_menu->priv->current_iso_name);
+ g_debug("setting OvirtCdrom:file back");
g_object_set(foreign_menu->priv->cdrom, "file",
- foreign_menu->priv->current_iso_name, NULL);
- g_clear_pointer(&foreign_menu->priv->next_iso_name, g_free);
+ foreign_menu->priv->current_iso_info ? foreign_menu->priv->current_iso_info[1] : NULL,
+ NULL);
+ g_clear_pointer(&foreign_menu->priv->next_iso_info, g_strfreev);
if (error != NULL) {
g_warning("failed to update cdrom resource: %s", error->message);
@@ -434,6 +468,7 @@ end:
void ovirt_foreign_menu_set_current_iso_name_async(OvirtForeignMenu *foreign_menu,
const char *name,
+ const char *id,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@@ -441,18 +476,18 @@ void ovirt_foreign_menu_set_current_iso_name_async(OvirtForeignMenu *foreign_men
GTask *task;
g_return_if_fail(foreign_menu->priv->cdrom != NULL);
- g_return_if_fail(foreign_menu->priv->next_iso_name == NULL);
+ g_return_if_fail(foreign_menu->priv->next_iso_info == NULL);
if (name) {
g_debug("Updating VM cdrom image to '%s'", name);
- foreign_menu->priv->next_iso_name = g_strdup(name);
+ foreign_menu->priv->next_iso_info = iso_info_new(name, id);
} else {
g_debug("Removing current cdrom image");
- foreign_menu->priv->next_iso_name = NULL;
+ foreign_menu->priv->next_iso_info = NULL;