[RFC PATCH 07/25] migration: Use migrate_mode() to query for cpr-transfer

Fabiano Rosas posted 25 patches 1 week, 4 days ago
Maintainers: Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Li Zhijian <lizhijian@fujitsu.com>
There is a newer version of this series
[RFC PATCH 07/25] migration: Use migrate_mode() to query for cpr-transfer
Posted by Fabiano Rosas 1 week, 4 days ago
cpr_set_incoming_mode() is only called on the target side, so
migrate_mode() on the source side is the same as s->parameters.mode.

Use the function to reduce explicit access to s->parameters, we have
options.c for that.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
 migration/migration.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/migration/migration.c b/migration/migration.c
index f2933f7789..4b1afcab24 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2252,7 +2252,7 @@ void qmp_migrate(const char *uri, bool has_channels,
         return;
     }
 
-    if (s->parameters.mode == MIG_MODE_CPR_TRANSFER && !cpr_channel) {
+    if (migrate_mode() == MIG_MODE_CPR_TRANSFER && !cpr_channel) {
         error_setg(errp, "missing 'cpr' migration channel");
         return;
     }
@@ -2277,7 +2277,7 @@ void qmp_migrate(const char *uri, bool has_channels,
      * in which case the target will not listen for the incoming migration
      * connection, so qmp_migrate_finish will fail to connect, and then recover.
      */
-    if (s->parameters.mode == MIG_MODE_CPR_TRANSFER) {
+    if (migrate_mode() == MIG_MODE_CPR_TRANSFER) {
         migrate_hup_add(s, cpr_state_ioc(), (GSourceFunc)qmp_migrate_finish_cb,
                         QAPI_CLONE(MigrationAddress, addr));
 
-- 
2.51.0
Re: [RFC PATCH 07/25] migration: Use migrate_mode() to query for cpr-transfer
Posted by Peter Xu 1 week, 1 day ago
On Fri, Dec 26, 2025 at 06:19:09PM -0300, Fabiano Rosas wrote:
> cpr_set_incoming_mode() is only called on the target side, so
> migrate_mode() on the source side is the same as s->parameters.mode.
> 
> Use the function to reduce explicit access to s->parameters, we have
> options.c for that.
> 
> Signed-off-by: Fabiano Rosas <farosas@suse.de>

Reviewed-by: Peter Xu <peterx@redhat.com>

Said that, we have three more users outside options.c.  Wanna do it
together?  They are:

  migration_call_notifiers, migrate_mode_is_cpr, migrate_prepare.

> ---
>  migration/migration.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/migration/migration.c b/migration/migration.c
> index f2933f7789..4b1afcab24 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -2252,7 +2252,7 @@ void qmp_migrate(const char *uri, bool has_channels,
>          return;
>      }
>  
> -    if (s->parameters.mode == MIG_MODE_CPR_TRANSFER && !cpr_channel) {
> +    if (migrate_mode() == MIG_MODE_CPR_TRANSFER && !cpr_channel) {
>          error_setg(errp, "missing 'cpr' migration channel");
>          return;
>      }
> @@ -2277,7 +2277,7 @@ void qmp_migrate(const char *uri, bool has_channels,
>       * in which case the target will not listen for the incoming migration
>       * connection, so qmp_migrate_finish will fail to connect, and then recover.
>       */
> -    if (s->parameters.mode == MIG_MODE_CPR_TRANSFER) {
> +    if (migrate_mode() == MIG_MODE_CPR_TRANSFER) {
>          migrate_hup_add(s, cpr_state_ioc(), (GSourceFunc)qmp_migrate_finish_cb,
>                          QAPI_CLONE(MigrationAddress, addr));
>  
> -- 
> 2.51.0
> 

-- 
Peter Xu
Re: [RFC PATCH 07/25] migration: Use migrate_mode() to query for cpr-transfer
Posted by Fabiano Rosas 1 week, 1 day ago
Peter Xu <peterx@redhat.com> writes:

> On Fri, Dec 26, 2025 at 06:19:09PM -0300, Fabiano Rosas wrote:
>> cpr_set_incoming_mode() is only called on the target side, so
>> migrate_mode() on the source side is the same as s->parameters.mode.
>> 
>> Use the function to reduce explicit access to s->parameters, we have
>> options.c for that.
>> 
>> Signed-off-by: Fabiano Rosas <farosas@suse.de>
>
> Reviewed-by: Peter Xu <peterx@redhat.com>
>
> Said that, we have three more users outside options.c.  Wanna do it
> together?  They are:
>
>   migration_call_notifiers, migrate_mode_is_cpr, migrate_prepare.
>

Yep