Patchwork [26/41] migration: detect error before sleeping

login
register
mail settings
Submitter Paolo Bonzini
Date Feb. 15, 2013, 5:46 p.m.
Message ID <1360950433-17106-27-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/220811/
State New
Headers show

Comments

Paolo Bonzini - Feb. 15, 2013, 5:46 p.m.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 migration.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
Orit Wasserman - Feb. 21, 2013, 7:27 a.m.
On 02/15/2013 07:46 PM, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  migration.c |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/migration.c b/migration.c
> index 5e2077e..63ecab5 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -644,6 +644,10 @@ static void *migration_thread(void *opaque)
>                  }
>              }
>          }
> +        if (qemu_file_get_error(s->file)) {
> +            __sync_val_compare_and_swap(&s->state, MIG_STATE_ACTIVE, MIG_STATE_ERROR);
> +	    break;
> +        }
>          if (current_time >= initial_time + BUFFER_DELAY) {
>              uint64_t transferred_bytes = s->bytes_xfer;
>              uint64_t time_spent = current_time - initial_time;
> @@ -661,9 +665,6 @@ static void *migration_thread(void *opaque)
>              /* usleep expects microseconds */
>              g_usleep((initial_time + BUFFER_DELAY - current_time)*1000);
>          }
> -        if (qemu_file_get_error(s->file)) {
> -            __sync_val_compare_and_swap(&s->state, MIG_STATE_ACTIVE, MIG_STATE_ERROR);
> -        }
>      }
>  
>      qemu_mutex_lock_iothread();
> 
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Juan Quintela - Feb. 22, 2013, 11:15 a.m.
Paolo Bonzini <pbonzini@redhat.com> wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>

Patch

diff --git a/migration.c b/migration.c
index 5e2077e..63ecab5 100644
--- a/migration.c
+++ b/migration.c
@@ -644,6 +644,10 @@  static void *migration_thread(void *opaque)
                 }
             }
         }
+        if (qemu_file_get_error(s->file)) {
+            __sync_val_compare_and_swap(&s->state, MIG_STATE_ACTIVE, MIG_STATE_ERROR);
+	    break;
+        }
         if (current_time >= initial_time + BUFFER_DELAY) {
             uint64_t transferred_bytes = s->bytes_xfer;
             uint64_t time_spent = current_time - initial_time;
@@ -661,9 +665,6 @@  static void *migration_thread(void *opaque)
             /* usleep expects microseconds */
             g_usleep((initial_time + BUFFER_DELAY - current_time)*1000);
         }
-        if (qemu_file_get_error(s->file)) {
-            __sync_val_compare_and_swap(&s->state, MIG_STATE_ACTIVE, MIG_STATE_ERROR);
-        }
     }
 
     qemu_mutex_lock_iothread();