[spice-gtk PATCH v2 6/8] seamless migration: don't reset messages data when swapping channels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When swapping the src and dest channels's, we need to keep
the xmit_queue and msg serials. Their state is expected to stay the same
after migration.
---
 gtk/channel-main.c       |    4 +++-
 gtk/spice-channel-priv.h |    2 +-
 gtk/spice-channel.c      |   12 +++++++-----
 gtk/spice-session-priv.h |    5 ++++-
 gtk/spice-session.c      |   13 ++++++++++---
 5 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 0e073a6..7e478af 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -1796,7 +1796,9 @@ 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);
+        spice_session_set_migration(spice_channel_get_session(channel),
+                                    mig.session,
+                                    mig.do_seamless);
     }
     g_object_unref(mig.session);
 
diff --git a/gtk/spice-channel-priv.h b/gtk/spice-channel-priv.h
index 8ed79fa..c01b3c4 100644
--- a/gtk/spice-channel-priv.h
+++ b/gtk/spice-channel-priv.h
@@ -174,7 +174,7 @@ void spice_channel_handle_migrate(SpiceChannel *channel, SpiceMsgIn *in);
 
 gint spice_channel_get_channel_id(SpiceChannel *channel);
 gint spice_channel_get_channel_type(SpiceChannel *channel);
-void spice_channel_swap(SpiceChannel *channel, SpiceChannel *swap);
+void spice_channel_swap(SpiceChannel *channel, SpiceChannel *swap, gboolean swap_msgs);
 gboolean spice_channel_get_read_only(SpiceChannel *channel);
 void spice_channel_reset(SpiceChannel *channel, gboolean migrating);
 
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 5f37cbc..a557ce8 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2591,7 +2591,7 @@ enum spice_channel_state spice_channel_get_state(SpiceChannel *channel)
 }
 
 G_GNUC_INTERNAL
-void spice_channel_swap(SpiceChannel *channel, SpiceChannel *swap)
+void spice_channel_swap(SpiceChannel *channel, SpiceChannel *swap, gboolean swap_msgs)
 {
     SpiceChannelPrivate *c = SPICE_CHANNEL_GET_PRIVATE(channel);
     SpiceChannelPrivate *s = SPICE_CHANNEL_GET_PRIVATE(swap);
@@ -2614,11 +2614,13 @@ void spice_channel_swap(SpiceChannel *channel, SpiceChannel *swap)
     SWAP(ctx);
     SWAP(ssl);
     SWAP(sslverify);
-    SWAP(in_serial);
-    SWAP(out_serial);
     SWAP(use_mini_header);
-    SWAP(xmit_queue);
-    SWAP(xmit_queue_blocked);
+    if (swap_msgs) {
+        SWAP(xmit_queue);
+        SWAP(xmit_queue_blocked);
+        SWAP(in_serial);
+        SWAP(out_serial);
+    }
     SWAP(caps);
     SWAP(common_caps);
     SWAP(remote_caps);
diff --git a/gtk/spice-session-priv.h b/gtk/spice-session-priv.h
index c24ef8e..e6cd17f 100644
--- a/gtk/spice-session-priv.h
+++ b/gtk/spice-session-priv.h
@@ -82,6 +82,7 @@ struct _SpiceSessionPrivate {
     SpiceSession      *migration;
     GList             *migration_left;
     SpiceSessionMigration migration_state;
+    gboolean          full_migration; /* seamless migration indicator */
     gboolean          disconnecting;
     gboolean          migrate_wait_init;
     guint             after_main_init;
@@ -119,7 +120,9 @@ 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);
+void spice_session_set_migration(SpiceSession *session,
+                                 SpiceSession *migration,
+                                 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 995b2ed..f714676 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -1194,7 +1194,9 @@ void spice_session_switching_disconnect(SpiceSession *self)
 }
 
 G_GNUC_INTERNAL
-void spice_session_set_migration(SpiceSession *session, SpiceSession *migration)
+void spice_session_set_migration(SpiceSession *session,
+                                 SpiceSession *migration,
+                                 gboolean full_migration)
 {
     SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
     SpiceSessionPrivate *m = SPICE_SESSION_GET_PRIVATE(migration);
@@ -1202,6 +1204,7 @@ void spice_session_set_migration(SpiceSession *session, SpiceSession *migration)
 
     g_return_if_fail(s != NULL);
 
+    s->full_migration = full_migration;
     spice_session_set_migration_state(session, SPICE_SESSION_MIGRATION_MIGRATING);
 
     g_warn_if_fail(s->migration == NULL);
@@ -1278,7 +1281,8 @@ void spice_session_abort_migration(SpiceSession *session)
         spice_channel_swap(c->channel,
             spice_session_lookup_channel(s->migration,
                                          spice_channel_get_channel_id(c->channel),
-                                         spice_channel_get_channel_type(c->channel)));
+                                         spice_channel_get_channel_type(c->channel)),
+                                         !s->full_migration);
     }
 
     g_list_free(s->migration_left);
@@ -1308,7 +1312,10 @@ void spice_session_channel_migrate(SpiceSession *session, SpiceChannel *channel)
     c = spice_session_lookup_channel(s->migration, id, type);
     g_return_if_fail(c != NULL);
 
-    spice_channel_swap(channel, c);
+    if (!g_queue_is_empty(&c->priv->xmit_queue) && s->full_migration) {
+        SPICE_DEBUG("mig channel xmit queue is not empty. type %s", c->priv->name);
+    }
+    spice_channel_swap(channel, c, !s->full_migration);
     s->migration_left = g_list_remove(s->migration_left, channel);
 
     if (g_list_length(s->migration_left) == 0) {
-- 
1.7.7.6

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]