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

Submitted by Victor Toso on Oct. 10, 2019, 9:31 a.m.

Details

Message ID 20191010093145.20097-1-victortoso@redhat.com
State New
Headers show
Series "main: abort previous migration on switch-host message" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Victor Toso Oct. 10, 2019, 9:31 a.m.
From: Victor Toso <me@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@redhat.com>
---
 src/channel-main.c | 5 +++++
 1 file changed, 5 insertions(+)

Patch hide | download patch | download mbox

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,

Comments

> 
> From: Victor Toso <me@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

Aren't these message exclusives? Is there a bug in the server?

> 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.
> 

Do you mean tests/migrate.py ? I don't have spice/tests/migraton.py
(not even spice/tests/migration.py)

> Signed-off-by: Victor Toso <victortoso@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,

Patch seems fine.
Is the migration seamless or not?

Frediano