diff mbox

[2/4] migration: Inactivate images after .save_live_complete_precopy()

Message ID 1495548064-10926-3-git-send-email-kwolf@redhat.com
State New
Headers show

Commit Message

Kevin Wolf May 23, 2017, 2:01 p.m. UTC
Block migration may still access the image during its
.save_live_complete_precopy() implementation, so we should only
inactivate the image afterwards.

Another reason for the change is that inactivating an image fails when
there is still a non-device BlockBackend using it, which includes the
BBs used by block migration. We want to give block migration a chance to
release the BBs before trying to inactivate the image (this will be done
in another patch).

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 migration/migration.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Eric Blake May 23, 2017, 3:36 p.m. UTC | #1
On 05/23/2017 09:01 AM, Kevin Wolf wrote:
> Block migration may still access the image during its
> .save_live_complete_precopy() implementation, so we should only
> inactivate the image afterwards.
> 
> Another reason for the change is that inactivating an image fails when
> there is still a non-device BlockBackend using it, which includes the
> BBs used by block migration. We want to give block migration a chance to
> release the BBs before trying to inactivate the image (this will be done
> in another patch).
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  migration/migration.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>
Juan Quintela May 24, 2017, 11:34 a.m. UTC | #2
Kevin Wolf <kwolf@redhat.com> wrote:
> Block migration may still access the image during its
> .save_live_complete_precopy() implementation, so we should only
> inactivate the image afterwards.
>
> Another reason for the change is that inactivating an image fails when
> there is still a non-device BlockBackend using it, which includes the
> BBs used by block migration. We want to give block migration a chance to
> release the BBs before trying to inactivate the image (this will be done
> in another patch).
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>

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


> ---
>  migration/migration.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/migration/migration.c b/migration/migration.c
> index 0304c01..846ba09 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -1787,17 +1787,19 @@ static void migration_completion(MigrationState *s, int current_active_state,
>  
>          if (!ret) {
>              ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
> +            if (ret >= 0) {
> +                qemu_file_set_rate_limit(s->to_dst_file, INT64_MAX);
> +                qemu_savevm_state_complete_precopy(s->to_dst_file, false);
> +            }
>              /*
>               * Don't mark the image with BDRV_O_INACTIVE flag if
>               * we will go into COLO stage later.
>               */
>              if (ret >= 0 && !migrate_colo_enabled()) {
>                  ret = bdrv_inactivate_all();
> -            }
> -            if (ret >= 0) {
> -                qemu_file_set_rate_limit(s->to_dst_file, INT64_MAX);
> -                qemu_savevm_state_complete_precopy(s->to_dst_file, false);
> -                s->block_inactive = true;
> +                if (ret >= 0) {
> +                    s->block_inactive = true;
> +                }
>              }
>          }
>          qemu_mutex_unlock_iothread();
diff mbox

Patch

diff --git a/migration/migration.c b/migration/migration.c
index 0304c01..846ba09 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1787,17 +1787,19 @@  static void migration_completion(MigrationState *s, int current_active_state,
 
         if (!ret) {
             ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
+            if (ret >= 0) {
+                qemu_file_set_rate_limit(s->to_dst_file, INT64_MAX);
+                qemu_savevm_state_complete_precopy(s->to_dst_file, false);
+            }
             /*
              * Don't mark the image with BDRV_O_INACTIVE flag if
              * we will go into COLO stage later.
              */
             if (ret >= 0 && !migrate_colo_enabled()) {
                 ret = bdrv_inactivate_all();
-            }
-            if (ret >= 0) {
-                qemu_file_set_rate_limit(s->to_dst_file, INT64_MAX);
-                qemu_savevm_state_complete_precopy(s->to_dst_file, false);
-                s->block_inactive = true;
+                if (ret >= 0) {
+                    s->block_inactive = true;
+                }
             }
         }
         qemu_mutex_unlock_iothread();