[Spice-devel] [PATCH spice-gtk v2 04/19] migration: set session migration during connect

Marc-André Lureau marcandre.lureau at redhat.com
Thu Nov 13 15:32:27 PST 2014


Track the migration session earlier, so that disconnecting before
migration finished will abort and release it.
---
 gtk/channel-main.c       |  6 +++---
 gtk/spice-session-priv.h |  5 ++---
 gtk/spice-session.c      | 16 ++++++++--------
 3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 873487b..d4a7d24 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -2079,6 +2079,7 @@ static gboolean migrate_connect(gpointer data)
     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)) {
@@ -2178,9 +2179,8 @@ static void main_migrate_connect(SpiceChannel *channel,
             SPICE_DEBUG("migration (semi-seamless): connections all ok");
             reply_type = SPICE_MSGC_MAIN_MIGRATE_CONNECTED;
         }
-        spice_session_set_migration(spice_channel_get_session(channel),
-                                    mig.session,
-                                    mig.do_seamless);
+        spice_session_start_migrating(spice_channel_get_session(channel),
+                                      mig.do_seamless);
     }
     g_object_unref(mig.session);
 
diff --git a/gtk/spice-session-priv.h b/gtk/spice-session-priv.h
index da43866..8e102e0 100644
--- a/gtk/spice-session-priv.h
+++ b/gtk/spice-session-priv.h
@@ -138,9 +138,8 @@ void spice_session_set_mm_time(SpiceSession *session, guint32 time);
 guint32 spice_session_get_mm_time(SpiceSession *session);
 
 void spice_session_switching_disconnect(SpiceSession *session);
-void spice_session_set_migration(SpiceSession *session,
-                                 SpiceSession *migration,
-                                 gboolean full_migration);
+void spice_session_start_migrating(SpiceSession *session,
+                                   gboolean full_migration);
 void spice_session_abort_migration(SpiceSession *session);
 void spice_session_set_migration_state(SpiceSession *session, SpiceSessionMigration state);
 
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 3e3f16d..42ad280 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -1391,22 +1391,22 @@ void spice_session_switching_disconnect(SpiceSession *self)
 }
 
 G_GNUC_INTERNAL
-void spice_session_set_migration(SpiceSession *session,
-                                 SpiceSession *migration,
-                                 gboolean full_migration)
+void spice_session_start_migrating(SpiceSession *session,
+                                   gboolean full_migration)
 {
     SpiceSessionPrivate *s = session->priv;
-    SpiceSessionPrivate *m = migration->priv;
+    SpiceSessionPrivate *m;
     gchar *tmp;
 
-    g_return_if_fail(s != NULL);
+    g_return_if_fail(s->migration != NULL);
+    m = s->migration->priv;
+    g_return_if_fail(m->migration_state == SPICE_SESSION_MIGRATION_CONNECTING);
+
 
     s->full_migration = full_migration;
     spice_session_set_migration_state(session, SPICE_SESSION_MIGRATION_MIGRATING);
 
-    g_warn_if_fail(s->migration == NULL);
-    s->migration = g_object_ref(migration);
-
+    /* swapping connection details happens after MIGRATION_CONNECTING state */
     tmp = s->host;
     s->host = m->host;
     m->host = tmp;
-- 
1.9.3



More information about the Spice-devel mailing list