diff mbox

[02/36] migration: simplify state assignmente

Message ID 839ab5ce6888472e1161b0677cfeed0afa7b8d27.1318326683.git.quintela@redhat.com
State New
Headers show

Commit Message

Juan Quintela Oct. 11, 2011, 10 a.m. UTC
Once there, make sure that if we already know that there is one error,
just call migration_fd_cleanup() with the ERROR state.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

Comments

Anthony Liguori Oct. 17, 2011, 1:52 p.m. UTC | #1
On 10/11/2011 05:00 AM, Juan Quintela wrote:
> Once there, make sure that if we already know that there is one error,
> just call migration_fd_cleanup() with the ERROR state.
>
> Signed-off-by: Juan Quintela<quintela@redhat.com>

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

> ---
>   migration.c |   11 ++++-------
>   1 files changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/migration.c b/migration.c
> index 77a51ad..7fd6c23 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -371,7 +371,6 @@ void migrate_fd_put_ready(void *opaque)
>
>       DPRINTF("iterate\n");
>       if (qemu_savevm_state_iterate(s->mon, s->file) == 1) {
> -        int state;
>           int old_vm_running = runstate_is_running();
>
>           DPRINTF("done iterating\n");
> @@ -381,20 +380,18 @@ void migrate_fd_put_ready(void *opaque)
>               if (old_vm_running) {
>                   vm_start();
>               }
> -            state = MIG_STATE_ERROR;
> -        } else {
> -            state = MIG_STATE_COMPLETED;
> +            s->state = MIG_STATE_ERROR;
>           }
>           if (migrate_fd_cleanup(s)<  0) {
>               if (old_vm_running) {
>                   vm_start();
>               }
> -            state = MIG_STATE_ERROR;
> +            s->state = MIG_STATE_ERROR;
>           }
> -        if (state == MIG_STATE_COMPLETED) {
> +        if (s->state == MIG_STATE_ACTIVE) {
> +            s->state = MIG_STATE_COMPLETED;
>               runstate_set(RUN_STATE_POSTMIGRATE);
>           }
> -        s->state = state;
>           notifier_list_notify(&migration_state_notifiers, NULL);
>       }
>   }
diff mbox

Patch

diff --git a/migration.c b/migration.c
index 77a51ad..7fd6c23 100644
--- a/migration.c
+++ b/migration.c
@@ -371,7 +371,6 @@  void migrate_fd_put_ready(void *opaque)

     DPRINTF("iterate\n");
     if (qemu_savevm_state_iterate(s->mon, s->file) == 1) {
-        int state;
         int old_vm_running = runstate_is_running();

         DPRINTF("done iterating\n");
@@ -381,20 +380,18 @@  void migrate_fd_put_ready(void *opaque)
             if (old_vm_running) {
                 vm_start();
             }
-            state = MIG_STATE_ERROR;
-        } else {
-            state = MIG_STATE_COMPLETED;
+            s->state = MIG_STATE_ERROR;
         }
         if (migrate_fd_cleanup(s) < 0) {
             if (old_vm_running) {
                 vm_start();
             }
-            state = MIG_STATE_ERROR;
+            s->state = MIG_STATE_ERROR;
         }
-        if (state == MIG_STATE_COMPLETED) {
+        if (s->state == MIG_STATE_ACTIVE) {
+            s->state = MIG_STATE_COMPLETED;
             runstate_set(RUN_STATE_POSTMIGRATE);
         }
-        s->state = state;
         notifier_list_notify(&migration_state_notifiers, NULL);
     }
 }