Patchwork [spice-server,12/13] server: fall back to switch host scheme in case semi-seamless connection to target fails

login
register
mail settings
Submitter Yonit Halperin
Date Sept. 21, 2011, 3:51 p.m.
Message ID <1316620283-8330-13-git-send-email-yhalperi@redhat.com>
Download mbox | patch
Permalink /patch/115819/
State New
Headers show

Comments

Yonit Halperin - Sept. 21, 2011, 3:51 p.m.
Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
---
 server/reds.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
Alon Levy - Sept. 22, 2011, 2:38 p.m.
On Wed, Sep 21, 2011 at 06:51:22PM +0300, Yonit Halperin wrote:
> 
> Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
> ---
>  server/reds.c |   18 +++++++++++++-----
>  1 files changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/server/reds.c b/server/reds.c
> index 76aa0ed..54c06d1 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -283,6 +283,7 @@ typedef struct RedsState {
>      int mig_wait_disconnect;
>      int mig_wait_prev_complete;
>      int mig_inprogress;
> +    int mig_connect_ok;
>      int expect_migrate;
>      int mig_target;
>      RedsMigSpice *mig_spice;
> @@ -1736,6 +1737,7 @@ static void reds_main_handle_message(void *opaque, size_t size, uint32_t type, v
>      case SPICE_MSGC_MAIN_MIGRATE_CONNECTED:
>          red_printf("client connected to migration target");
>          if (reds->mig_wait_connect) {
> +            reds->mig_connect_ok = TRUE;
>              reds_mig_cleanup();
>          }
>          break;
> @@ -1743,6 +1745,7 @@ static void reds_main_handle_message(void *opaque, size_t size, uint32_t type, v
>          // TODO: fall into switch host in case of connect error or timeout
So this is no longer true?

>          red_printf("mig connect error");
>          if (reds->mig_wait_connect) {
> +            reds->mig_connect_ok = FALSE;
>              reds_mig_cleanup();
>          }
>          break;
> @@ -2172,6 +2175,7 @@ static void reds_handle_main_link(RedLinkInfo *link)
>      reds->mig_inprogress = FALSE;
>      reds->mig_wait_connect = FALSE;
>      reds->mig_wait_disconnect = FALSE;
> +    reds->mig_connect_ok = FALSE;
>      reds->stream = link->stream;
>      reds->in_handler.shut = FALSE;
>  
> @@ -4151,8 +4155,6 @@ static void reds_mig_connect(void)
>  
>      reds_push_pipe_item(item);
>  
> -    reds_mig_release();
> -
>      reds->mig_wait_connect = TRUE;
>      core->timer_start(reds->mig_timer, MIGRATE_TIMEOUT);
>  }
> @@ -4194,6 +4196,7 @@ static void reds_mig_started(void)
>  
>      reds_listen_stop();
>      sif = SPICE_CONTAINEROF(migration_interface->base.sif, SpiceMigrateInterface, base);
> +    reds->mig_connect_ok = FALSE;
>  
>      if (reds->stream == NULL) {
>          red_printf("not connected to stream");
> @@ -4227,7 +4230,7 @@ static void reds_mig_finished(int completed)
>      RedsOutItem *item;
>  
>      red_printf("");
> -
> +    reds_mig_release();
>      if (reds->stream == NULL) {
>          red_printf("no stream connected");
>          return;
> @@ -4298,7 +4301,12 @@ static void migrate_timeout(void *opaque)
>  {
>      red_printf("");
>      ASSERT(reds->mig_wait_connect || reds->mig_wait_disconnect || reds->mig_wait_prev_complete);
> -    reds_mig_disconnect();
> +    if (reds->mig_wait_connect) {
> +        reds->mig_connect_ok = FALSE;
> +        reds_mig_cleanup();
> +    } else {
> +        reds_mig_disconnect();
> +    }
>  }
>  
>  static void key_modifiers_sender(void *opaque)
> @@ -5188,7 +5196,7 @@ SPICE_GNUC_VISIBLE int spice_server_migrate_end(SpiceServer *s, int completed)
>          goto complete;
>      }
>  
> -    if (reds->client_semi_mig_cap) {
> +    if (reds->client_semi_mig_cap && reds->mig_connect_ok) {
>          reds_mig_finished(completed);
>      } else {
>          ret = spice_server_migrate_switch(s);
> -- 
> 1.7.4.4
>

Patch

diff --git a/server/reds.c b/server/reds.c
index 76aa0ed..54c06d1 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -283,6 +283,7 @@  typedef struct RedsState {
     int mig_wait_disconnect;
     int mig_wait_prev_complete;
     int mig_inprogress;
+    int mig_connect_ok;
     int expect_migrate;
     int mig_target;
     RedsMigSpice *mig_spice;
@@ -1736,6 +1737,7 @@  static void reds_main_handle_message(void *opaque, size_t size, uint32_t type, v
     case SPICE_MSGC_MAIN_MIGRATE_CONNECTED:
         red_printf("client connected to migration target");
         if (reds->mig_wait_connect) {
+            reds->mig_connect_ok = TRUE;
             reds_mig_cleanup();
         }
         break;
@@ -1743,6 +1745,7 @@  static void reds_main_handle_message(void *opaque, size_t size, uint32_t type, v
         // TODO: fall into switch host in case of connect error or timeout
         red_printf("mig connect error");
         if (reds->mig_wait_connect) {
+            reds->mig_connect_ok = FALSE;
             reds_mig_cleanup();
         }
         break;
@@ -2172,6 +2175,7 @@  static void reds_handle_main_link(RedLinkInfo *link)
     reds->mig_inprogress = FALSE;
     reds->mig_wait_connect = FALSE;
     reds->mig_wait_disconnect = FALSE;
+    reds->mig_connect_ok = FALSE;
     reds->stream = link->stream;
     reds->in_handler.shut = FALSE;
 
@@ -4151,8 +4155,6 @@  static void reds_mig_connect(void)
 
     reds_push_pipe_item(item);
 
-    reds_mig_release();
-
     reds->mig_wait_connect = TRUE;
     core->timer_start(reds->mig_timer, MIGRATE_TIMEOUT);
 }
@@ -4194,6 +4196,7 @@  static void reds_mig_started(void)
 
     reds_listen_stop();
     sif = SPICE_CONTAINEROF(migration_interface->base.sif, SpiceMigrateInterface, base);
+    reds->mig_connect_ok = FALSE;
 
     if (reds->stream == NULL) {
         red_printf("not connected to stream");
@@ -4227,7 +4230,7 @@  static void reds_mig_finished(int completed)
     RedsOutItem *item;
 
     red_printf("");
-
+    reds_mig_release();
     if (reds->stream == NULL) {
         red_printf("no stream connected");
         return;
@@ -4298,7 +4301,12 @@  static void migrate_timeout(void *opaque)
 {
     red_printf("");
     ASSERT(reds->mig_wait_connect || reds->mig_wait_disconnect || reds->mig_wait_prev_complete);
-    reds_mig_disconnect();
+    if (reds->mig_wait_connect) {
+        reds->mig_connect_ok = FALSE;
+        reds_mig_cleanup();
+    } else {
+        reds_mig_disconnect();
+    }
 }
 
 static void key_modifiers_sender(void *opaque)
@@ -5188,7 +5196,7 @@  SPICE_GNUC_VISIBLE int spice_server_migrate_end(SpiceServer *s, int completed)
         goto complete;
     }
 
-    if (reds->client_semi_mig_cap) {
+    if (reds->client_semi_mig_cap && reds->mig_connect_ok) {
         reds_mig_finished(completed);
     } else {
         ret = spice_server_migrate_switch(s);