The migration session creation may fail. Instead of delaying the session creation to the main_connect() callback, do it directly from the message handler context, to report failure early to server. --- gtk/channel-main.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/gtk/channel-main.c b/gtk/channel-main.c index 7cc7630..2b88391 100644 --- a/gtk/channel-main.c +++ b/gtk/channel-main.c @@ -2065,21 +2065,16 @@ static gboolean migrate_connect(gpointer data) SpiceChannelPrivate *c; int port, sport; const char *host; - SpiceSession *session; g_return_val_if_fail(mig != NULL, FALSE); g_return_val_if_fail(mig->info != NULL, FALSE); g_return_val_if_fail(mig->nchannels == 0, FALSE); c = SPICE_CHANNEL(mig->src_channel)->priv; g_return_val_if_fail(c != NULL, FALSE); + g_return_val_if_fail(mig->session != NULL, FALSE); - session = spice_channel_get_session(mig->src_channel); - g_return_val_if_fail(session->priv->migration == NULL, FALSE); - - mig->session = spice_session_new_from_session(session); mig->session->priv->migration_copy = true; spice_session_set_migration_state(mig->session, SPICE_SESSION_MIGRATION_CONNECTING); - session->priv->migration = g_object_ref(mig->session); if ((c->peer_hdr.major_version == 1) && (c->peer_hdr.minor_version < 1)) { @@ -2149,9 +2144,10 @@ static void main_migrate_connect(SpiceChannel *channel, uint32_t src_mig_version) { SpiceMainChannelPrivate *main_priv = SPICE_MAIN_CHANNEL(channel)->priv; + int reply_type = SPICE_MSGC_MAIN_MIGRATE_CONNECT_ERROR; spice_migrate mig = { 0, }; SpiceMsgOut *out; - int reply_type; + SpiceSession *session; mig.src_channel = channel; mig.info = dst_info; @@ -2159,6 +2155,16 @@ static void main_migrate_connect(SpiceChannel *channel, mig.do_seamless = do_seamless; mig.src_mig_version = src_mig_version; + CHANNEL_DEBUG(channel, "migrate connect"); + session = spice_channel_get_session(channel); + if (session->priv->migration != NULL) + goto end; + + mig.session = spice_session_new_from_session(session); + if (mig.session == NULL) + goto end; + session->priv->migration = g_object_ref(mig.session); + main_priv->migrate_data = &mig; /* no need to track idle, call is sync for this coroutine */ @@ -2166,7 +2172,6 @@ static void main_migrate_connect(SpiceChannel *channel, /* switch to main loop and wait for connections */ coroutine_yield(NULL); - g_return_if_fail(mig.session != NULL); if (mig.nchannels != 0) { reply_type = SPICE_MSGC_MAIN_MIGRATE_CONNECT_ERROR; @@ -2184,6 +2189,8 @@ static void main_migrate_connect(SpiceChannel *channel, } g_object_unref(mig.session); +end: + CHANNEL_DEBUG(channel, "migrate connect reply %d", reply_type); out = spice_msg_out_new(SPICE_CHANNEL(channel), reply_type); spice_msg_out_send(out); } -- 1.9.3 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel