[Spice-devel] [spice-gtk] main: abort previous migration on switch-host message

Victor Toso victortoso at redhat.com
Thu Oct 10 09:31:45 UTC 2019


From: Victor Toso <me at victortoso.com>

In the host, it is possible that the migration goes faster than
client side would expect. In case we receive a migrate-begin message
followed by switch-host message, we should be sure to abort previous
migration to avoid keeping some unused objects in memory plus
critical messages in subsequent migrations as below:

 > GSpice-CRITICAL **: spice_session_set_migration_session:
 > assertion 'session->priv->migration == NULL' failed

Found by testing with spice/tests/migraton.py without QCOW image.

Signed-off-by: Victor Toso <victortoso at redhat.com>
---
 src/channel-main.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/channel-main.c b/src/channel-main.c
index 4305dcd..4afaa3f 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -2506,6 +2506,11 @@ static void main_handle_migrate_switch_host(SpiceChannel *channel, SpiceMsgIn *i
     }
 
     session = spice_channel_get_session(channel);
+    /* It is possible that we were migrating before receiving the switch-host
+     * message without receiving a migrate-cancel message. Simply cancel
+     * previous migration before switching host */
+    spice_session_abort_migration(session);
+
     spice_session_set_migration_state(session, SPICE_SESSION_MIGRATION_SWITCHING);
     g_object_set(session,
                  "host", host,
-- 
2.21.0



More information about the Spice-devel mailing list