On Tue, Feb 03, 2026 at 11:15:09AM +0100, Lukas Straub wrote:
> Since
> 121ccedc2b migration: block incoming colo when capability is disabled
> 
> x-colo capability needs to be always enabled on the incoming side.
> So migration_incoming_colo_enabled() and migrate_colo() are equivalent
> with migrate_colo() being easier to reason about since it is always true
> during the whole migration.
> 
> Use migrate_colo() to initialize the ram cache in the normal migration path.
> 
> Reviewed-by: Fabiano Rosas <[email protected]>
> Signed-off-by: Lukas Straub <[email protected]>

Since the goal of this patch is to drop the COLO migration command, this
looks an improvement indeed,

Reviewed-by: Peter Xu <[email protected]>

I'll still comment though for possible future updates..

> ---
>  migration/migration.c | 18 ++++++++++++++----
>  migration/savevm.c    | 14 +-------------
>  2 files changed, 15 insertions(+), 17 deletions(-)
> 
> diff --git a/migration/migration.c b/migration/migration.c
> index 
> b103a82fc0b83009d01d238ff16c0a542d83509f..a73d842ad8b060dc84273ade36ef7dc8b87421f3
>  100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -630,10 +630,6 @@ int migration_incoming_enable_colo(Error **errp)
>          return -EINVAL;
>      }
>  
> -    if (ram_block_discard_disable(true)) {
> -        error_setg(errp, "COLO: cannot disable RAM discard");
> -        return -EBUSY;
> -    }
>      migration_colo_enabled = true;
>      return 0;
>  }
> @@ -770,6 +766,20 @@ process_incoming_migration_co(void *opaque)
>  
>      assert(mis->from_src_file);
>  
> +    if (migrate_colo()) {
> +        if (ram_block_discard_disable(true)) {

IMHO this is something we could have done at migrate_incoming and fail the
QMP command directly, rather than waiting until this late.

> +            error_setg(&local_err, "COLO: cannot disable RAM discard");
> +            goto fail;
> +        }
> +
> +        ret = colo_init_ram_cache(&local_err);

This might be more suitable to be put in ram's load_setup() (which should
happen at the initial migration phase, before colo taking snapshots), then
I believe this function can be unexported too.

> +        if (ret) {
> +            error_prepend(&local_err, "failed to init colo RAM cache: %d: ",
> +                          ret);
> +            goto fail;
> +        }
> +    }
> +
>      mis->largest_page_size = qemu_ram_pagesize_largest();
>      postcopy_state_set(POSTCOPY_INCOMING_NONE);
>      migrate_set_state(&mis->state, MIGRATION_STATUS_SETUP,
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 
> 3dc812a7bbb4e8f5321114c9919d4619798fed5e..0353ac2d0de819b6547a1f771e6a4c3b8fb1e4ef
>  100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -2407,19 +2407,7 @@ static int 
> loadvm_process_enable_colo(MigrationIncomingState *mis,
>                                        Error **errp)
>  {
>      ERRP_GUARD();
> -    int ret;
> -
> -    ret = migration_incoming_enable_colo(errp);
> -    if (ret < 0) {
> -        return ret;
> -    }
> -
> -    ret = colo_init_ram_cache(errp);
> -    if (ret) {
> -        error_prepend(errp, "failed to init colo RAM cache: %d: ", ret);
> -        migration_incoming_disable_colo();
> -    }
> -    return ret;
> +    return migration_incoming_enable_colo(errp);
>  }
>  
>  static int loadvm_postcopy_handle_switchover_start(Error **errp)
> 
> -- 
> 2.39.5
> 

-- 
Peter Xu


Reply via email to