[Spice-devel] [spice-gtk PATCH v2 8/8] channel-smartcard: do not attach temporary migration channel to smartcard
Dunrong Huang
riegamaths at gmail.com
Mon Aug 27 08:18:30 PDT 2012
2012/8/26 Yonit Halperin <yhalperi at redhat.com>:
> During migration, the smartcard channel that belongs to the temporary
> copied session shouldn't be active.
> ---
> gtk/channel-main.c | 1 +
> gtk/channel-smartcard.c | 55 ++++++++++++++++++++++++++++++----------------
> gtk/spice-session-priv.h | 1 +
> 3 files changed, 38 insertions(+), 19 deletions(-)
>
> diff --git a/gtk/channel-main.c b/gtk/channel-main.c
> index 7e478af..ff9b0c1 100644
> --- a/gtk/channel-main.c
> +++ b/gtk/channel-main.c
> @@ -1701,6 +1701,7 @@ static gboolean migrate_connect(gpointer data)
>
> session = spice_channel_get_session(mig->src_channel);
> mig->session = spice_session_new_from_session(session);
> + mig->session->priv->migration_copy = true;
>
> if ((c->peer_hdr.major_version == 1) &&
> (c->peer_hdr.minor_version < 1)) {
> diff --git a/gtk/channel-smartcard.c b/gtk/channel-smartcard.c
> index 6fa4435..41d9554 100644
> --- a/gtk/channel-smartcard.c
> +++ b/gtk/channel-smartcard.c
> @@ -27,6 +27,7 @@
> #include "spice-channel-priv.h"
> #include "smartcard-manager.h"
> #include "smartcard-manager-priv.h"
> +#include "spice-session-priv.h"
>
> /**
> * SECTION:channel-smartcard
> @@ -120,28 +121,39 @@ static void spice_smartcard_channel_init(SpiceSmartcardChannel *channel)
> priv->message_queue = g_queue_new();
>
> #ifdef USE_SMARTCARD
> - SpiceSmartcardManager *manager;
> -
> - manager = spice_smartcard_manager_get();
> -
> priv->pending_card_insertions =
> g_hash_table_new_full(g_direct_hash, g_direct_equal,
> (GDestroyNotify)vreader_free, NULL);
> priv->pending_reader_removals =
> g_hash_table_new_full(g_direct_hash, g_direct_equal,
> (GDestroyNotify)vreader_free, NULL);
> -
> - g_signal_connect(G_OBJECT(manager), "reader-added",
> - (GCallback)reader_added_cb, channel);
> - g_signal_connect(G_OBJECT(manager), "reader-removed",
> - (GCallback)reader_removed_cb, channel);
> - g_signal_connect(G_OBJECT(manager), "card-inserted",
> - (GCallback)card_inserted_cb, channel);
> - g_signal_connect(G_OBJECT(manager), "card-removed",
> - (GCallback)card_removed_cb, channel);
> #endif
> }
>
> +static void spice_smartcard_channel_constructed(GObject *object)
> +{
missing #ifdef USE_SMARTCARD
> + SpiceSession *s = spice_channel_get_session(SPICE_CHANNEL(object));
> + SpiceSmartcardChannel *channel = SPICE_SMARTCARD_CHANNEL(object);
> + SpiceSmartcardManager *manager = spice_smartcard_manager_get();
> +
> +
> + g_return_if_fail(s != NULL);
> + if (!s->priv->migration_copy) {
> + g_signal_connect(G_OBJECT(manager), "reader-added",
> + (GCallback)reader_added_cb, channel);
Those helper functions(reader_added_cb ...) are defined only
USE_SMARTCARD is defined.
> + g_signal_connect(G_OBJECT(manager), "reader-removed",
> + (GCallback)reader_removed_cb, channel);
> + g_signal_connect(G_OBJECT(manager), "card-inserted",
> + (GCallback)card_inserted_cb, channel);
> + g_signal_connect(G_OBJECT(manager), "card-removed",
> + (GCallback)card_removed_cb, channel);
> + }
missing #endif
> +
> + if (G_OBJECT_CLASS(spice_smartcard_channel_parent_class)->constructed)
> + G_OBJECT_CLASS(spice_smartcard_channel_parent_class)->constructed(object);
> +
> +}
> +
> static void spice_smartcard_channel_finalize(GObject *obj)
> {
> SpiceSmartcardChannelPrivate *c = SPICE_SMARTCARD_CHANNEL_GET_PRIVATE(obj);
> @@ -200,6 +212,8 @@ static void spice_smartcard_channel_class_init(SpiceSmartcardChannelClass *klass
> SpiceChannelClass *channel_class = SPICE_CHANNEL_CLASS(klass);
>
> gobject_class->finalize = spice_smartcard_channel_finalize;
> + gobject_class->constructed = spice_smartcard_channel_constructed;
> +
> channel_class->handle_msg = spice_smartcard_handle_msg;
> channel_class->channel_up = spice_smartcard_channel_up;
> channel_class->channel_reset = spice_smartcard_channel_reset;
> @@ -448,16 +462,19 @@ static void spice_smartcard_channel_up_cb(GObject *source_object,
> gpointer user_data)
> {
> SpiceChannel *channel = SPICE_CHANNEL(user_data);
> - GError *error = NULL;
>
> g_return_if_fail(channel != NULL);
> g_return_if_fail(SPICE_IS_SESSION(source_object));
>
> - spice_smartcard_manager_init_finish(SPICE_SESSION(source_object),
> - res, &error);
> - if (error)
> - g_warning("%s", error->message);
> - g_clear_error(&error);
> + if (!spice_channel_get_session(SPICE_CHANNEL(channel))->priv->migration_copy) {
> + GError *error = NULL;
> +
> + spice_smartcard_manager_init_finish(SPICE_SESSION(source_object),
> + res, &error);
> + if (error)
> + g_warning("%s", error->message);
> + g_clear_error(&error);
> + }
> }
>
> static void spice_smartcard_channel_up(SpiceChannel *channel)
> diff --git a/gtk/spice-session-priv.h b/gtk/spice-session-priv.h
> index e6cd17f..13345b4 100644
> --- a/gtk/spice-session-priv.h
> +++ b/gtk/spice-session-priv.h
> @@ -86,6 +86,7 @@ struct _SpiceSessionPrivate {
> gboolean disconnecting;
> gboolean migrate_wait_init;
> guint after_main_init;
> + gboolean migration_copy;
>
> display_cache images;
> display_cache palettes;
> --
> 1.7.7.6
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
--
Best Regards,
Dunrong Huang
More information about the Spice-devel
mailing list