[virt-tools-list] [virt-viewer] VirtViewerDisplay: Keep a reference on VirtViewerDisplay::session
Christophe Fergeau
cfergeau at redhat.com
Tue Nov 18 17:09:11 UTC 2014
When using virt-viewer with --reconnect and a qemu+ssh libvirt
connection, when killing the guest with 'virsh destroy', the
VirtViewerSessionSpice instance would be destroyed when handling the
SPICE_CHANNEL_ERROR_IO main channel event with
virt_viewer_session_spice_main_channel_event, but the VirtViewerDisplay
code would then try to use that just freed VirtViewerSessionSpice object
as it has a reference to it:
at virt-viewer-display-spice.c:79
at virt-viewer-display-spice.c:93
#5 0x0000003e1980fd35 in g_closure_invoke (closure=0xac6f00, return_value=return_value at entry=0x0, n_param_values=2, param_values=param_values at entry=0x7fffffffc9d0, invocation_hint=invocation_hint at entry=0x7fffffffc970) at gclosure.c:768
#6 0x0000003e19821a42 in signal_emit_unlocked_R (node=node at entry=0x672eb0, detail=detail at entry=1769, instance=instance at entry=0x8a88b0, emission_return=emission_return at entry=0x0, instance_and_params=instance_and_params at entry=0x7fffffffc9d0) at gsignal.c:3553
#7 0x0000003e1982a181 in g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args at entry=0x7fffffffcb60) at gsignal.c:3309
at virt-viewer-display-spice.c:145
#14 0x0000003e1980fd35 in g_closure_invoke (closure=0xacaca0, return_value=return_value at entry=0x0, n_param_values=2, param_values=param_values at entry=0x7fffffffcee0, invocation_hint=invocation_hint at entry=0x7fffffffce80) at gclosure.c:768
#15 0x0000003e19821a42 in signal_emit_unlocked_R (node=node at entry=0x672eb0, detail=detail at entry=1787, instance=instance at entry=0x89e5a0, emission_return=emission_return at entry=0x0, instance_and_params=instance_and_params at entry=0x7fffffffcee0) at gsignal.c:3553
#16 0x0000003e1982a181 in g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args at entry=0x7fffffffd070) at gsignal.c:3309
at gobject.c:1149
at spice-widget.c:244
at spice-widget.c:2132
, signal_id=<optimized out>, detail=<optimized out>) at gsignal.c:3365
#25 0x0000003e1980fd35 in g_closure_invoke (closure=0xa96790, return_value=return_value at entry=0x0, n_param_values=2, param_values=param_values at entry=0x7fffffffd4d0, invocation_hint=invocation_hint at entry=0x7fffffffd470) at gclosure.c:768
#26 0x0000003e19821a42 in signal_emit_unlocked_R (node=node at entry=0x6ed870, detail=detail at entry=0, instance=instance at entry=0x8a8730, emission_return=emission_return at entry=0x0, instance_and_params=instance_and_params at entry=0x7fffffffd4d0) at gsignal.c:3553
#27 0x0000003e1982a181 in g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args at entry=0x7fffffffd660) at gsignal.c:3309
at spice-channel.c:156
at channel-display.c:134
The qemu+ssh case behaves differently from the local case as in the
latter case, only a SPICE_CHANNEL_CLOSED event is received on the main
channel when destroying the local guest.
This commit make VirtViewerDisplay take a reference on the
VirtViewerSession object it uses so that it does not die early.
---
src/virt-viewer-display.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
index e6bc108..a42276e 100644
--- a/src/virt-viewer-display.c
+++ b/src/virt-viewer-display.c
@@ -93,6 +93,16 @@ enum {
};
static void
+virt_viewer_display_finalize(GObject *obj)
+{
+ VirtViewerDisplay *display = VIRT_VIEWER_DISPLAY(obj);
+ if (display->priv->session != NULL)
+ g_clear_object(&display->priv->session);
+
+ G_OBJECT_CLASS(virt_viewer_display_parent_class)->finalize(obj);
+}
+
+static void
virt_viewer_display_class_init(VirtViewerDisplayClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS(class);
@@ -100,6 +110,7 @@ virt_viewer_display_class_init(VirtViewerDisplayClass *class)
object_class->set_property = virt_viewer_display_set_property;
object_class->get_property = virt_viewer_display_get_property;
+ object_class->finalize = virt_viewer_display_finalize;
#if GTK_CHECK_VERSION(3, 0, 0)
widget_class->get_preferred_width = virt_viewer_display_get_preferred_width;
@@ -316,7 +327,7 @@ virt_viewer_display_set_property(GObject *object,
break;
case PROP_SESSION:
g_warn_if_fail(priv->session == NULL);
- priv->session = g_value_get_object(value);
+ priv->session = g_value_dup_object(value);
break;
case PROP_MONITOR:
priv->monitor = g_value_get_int(value);
--
2.1.0
More information about the virt-tools-list
mailing list