[RFC PATCH 13/13] [PoC] migration: Allow migrate commands to provide the migration config

Fabiano Rosas posted 13 patches 7 months, 1 week ago
There is a newer version of this series
[RFC PATCH 13/13] [PoC] migration: Allow migrate commands to provide the migration config
Posted by Fabiano Rosas 7 months, 1 week ago
Allow the migrate and migrate_incoming commands to pass the migration
configuration options all at once, dispensing the use of
migrate-set-parameters and migrate-set-capabilities.

The motivation of this is to simplify the interface with the
management layer and avoid the usage of several command invocations to
configure a migration. It also avoids stale parameters from a previous
migration to influence the current migration.

The options that are changed during the migration can still be set
with the existing commands.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
 migration/migration-hmp-cmds.c |  5 +++--
 migration/migration.c          |  8 ++++----
 qapi/migration.json            | 10 ++++++++++
 system/vl.c                    |  3 ++-
 4 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
index 49c26daed3..44d2265002 100644
--- a/migration/migration-hmp-cmds.c
+++ b/migration/migration-hmp-cmds.c
@@ -429,7 +429,7 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)
     }
     QAPI_LIST_PREPEND(caps, g_steal_pointer(&channel));
 
-    qmp_migrate_incoming(NULL, true, caps, true, false, &err);
+    qmp_migrate_incoming(NULL, true, caps, NULL, true, false, &err);
     qapi_free_MigrationChannelList(caps);
 
 end:
@@ -715,7 +715,8 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
     }
     QAPI_LIST_PREPEND(caps, g_steal_pointer(&channel));
 
-    qmp_migrate(NULL, true, caps, false, false, true, resume, &err);
+    qmp_migrate(NULL, true, caps, NULL, false, false, true, resume,
+                &err);
     if (hmp_handle_error(mon, err)) {
         return;
     }
diff --git a/migration/migration.c b/migration/migration.c
index 55d839abd0..a1f04cef32 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1894,8 +1894,8 @@ void migrate_del_blocker(Error **reasonp)
 
 void qmp_migrate_incoming(const char *uri, bool has_channels,
                           MigrationChannelList *channels,
-                          bool has_exit_on_error, bool exit_on_error,
-                          Error **errp)
+                          MigrationConfig *config, bool has_exit_on_error,
+                          bool exit_on_error, Error **errp)
 {
     Error *local_err = NULL;
     static bool once = true;
@@ -2159,8 +2159,8 @@ static gboolean qmp_migrate_finish_cb(QIOChannel *channel,
     return G_SOURCE_REMOVE;
 }
 
-void qmp_migrate(const char *uri, bool has_channels,
-                 MigrationChannelList *channels, bool has_detach, bool detach,
+void qmp_migrate(const char *uri, bool has_channels, MigrationChannelList *channels,
+                 MigrationConfig *config, bool has_detach, bool detach,
                  bool has_resume, bool resume, Error **errp)
 {
     bool resume_requested;
diff --git a/qapi/migration.json b/qapi/migration.json
index bb2487dbc6..5bd8f0f1b2 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -1638,6 +1638,10 @@
 #
 # @resume: resume one paused migration, default "off".  (since 3.0)
 #
+# @config: migration configuration options, previously set via
+#     @migrate-set-parameters and @migrate-set-capabilities.  (since
+#     10.1)
+#
 # Since: 0.14
 #
 # .. admonition:: Notes
@@ -1702,6 +1706,7 @@
 { 'command': 'migrate',
   'data': {'*uri': 'str',
            '*channels': [ 'MigrationChannel' ],
+           '*config': 'MigrationConfig',
            '*detach': 'bool', '*resume': 'bool' } }
 
 ##
@@ -1721,6 +1726,10 @@
 #     error details could be retrieved with query-migrate.
 #     (since 9.1)
 #
+# @config: migration configuration options, previously set via
+#     @migrate-set-parameters and @migrate-set-capabilities.  (since
+#     10.1)
+#
 # Since: 2.3
 #
 # .. admonition:: Notes
@@ -1774,6 +1783,7 @@
 { 'command': 'migrate-incoming',
              'data': {'*uri': 'str',
                       '*channels': [ 'MigrationChannel' ],
+                      '*config': 'MigrationConfig',
                       '*exit-on-error': 'bool' } }
 
 ##
diff --git a/system/vl.c b/system/vl.c
index ec93988a03..ea7040ef8d 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -2826,7 +2826,8 @@ void qmp_x_exit_preconfig(Error **errp)
                 g_new0(MigrationChannelList, 1);
 
             channels->value = incoming_channels[MIGRATION_CHANNEL_TYPE_MAIN];
-            qmp_migrate_incoming(NULL, true, channels, true, true, &local_err);
+            qmp_migrate_incoming(NULL, true, channels, NULL, true, true,
+                                 &local_err);
             if (local_err) {
                 error_reportf_err(local_err, "-incoming %s: ", incoming);
                 exit(1);
-- 
2.35.3
Re: [RFC PATCH 13/13] [PoC] migration: Allow migrate commands to provide the migration config
Posted by Markus Armbruster 5 months, 3 weeks ago
Fabiano Rosas <farosas@suse.de> writes:

> Allow the migrate and migrate_incoming commands to pass the migration
> configuration options all at once, dispensing the use of
> migrate-set-parameters and migrate-set-capabilities.
>
> The motivation of this is to simplify the interface with the
> management layer and avoid the usage of several command invocations to
> configure a migration. It also avoids stale parameters from a previous
> migration to influence the current migration.
>
> The options that are changed during the migration can still be set
> with the existing commands.
>
> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> ---
>  migration/migration-hmp-cmds.c |  5 +++--
>  migration/migration.c          |  8 ++++----
>  qapi/migration.json            | 10 ++++++++++
>  system/vl.c                    |  3 ++-
>  4 files changed, 19 insertions(+), 7 deletions(-)
>
> diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
> index 49c26daed3..44d2265002 100644
> --- a/migration/migration-hmp-cmds.c
> +++ b/migration/migration-hmp-cmds.c
> @@ -429,7 +429,7 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)
>      }
>      QAPI_LIST_PREPEND(caps, g_steal_pointer(&channel));
>  
> -    qmp_migrate_incoming(NULL, true, caps, true, false, &err);
> +    qmp_migrate_incoming(NULL, true, caps, NULL, true, false, &err);
>      qapi_free_MigrationChannelList(caps);
>  
>  end:
> @@ -715,7 +715,8 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
>      }
>      QAPI_LIST_PREPEND(caps, g_steal_pointer(&channel));
>  
> -    qmp_migrate(NULL, true, caps, false, false, true, resume, &err);
> +    qmp_migrate(NULL, true, caps, NULL, false, false, true, resume,
> +                &err);
>      if (hmp_handle_error(mon, err)) {
>          return;
>      }
> diff --git a/migration/migration.c b/migration/migration.c
> index 55d839abd0..a1f04cef32 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -1894,8 +1894,8 @@ void migrate_del_blocker(Error **reasonp)
>  
>  void qmp_migrate_incoming(const char *uri, bool has_channels,
>                            MigrationChannelList *channels,
> -                          bool has_exit_on_error, bool exit_on_error,
> -                          Error **errp)
> +                          MigrationConfig *config, bool has_exit_on_error,
> +                          bool exit_on_error, Error **errp)
>  {
>      Error *local_err = NULL;
>      static bool once = true;
> @@ -2159,8 +2159,8 @@ static gboolean qmp_migrate_finish_cb(QIOChannel *channel,
>      return G_SOURCE_REMOVE;
>  }
>  
> -void qmp_migrate(const char *uri, bool has_channels,
> -                 MigrationChannelList *channels, bool has_detach, bool detach,
> +void qmp_migrate(const char *uri, bool has_channels, MigrationChannelList *channels,
> +                 MigrationConfig *config, bool has_detach, bool detach,
>                   bool has_resume, bool resume, Error **errp)
>  {
>      bool resume_requested;
> diff --git a/qapi/migration.json b/qapi/migration.json
> index bb2487dbc6..5bd8f0f1b2 100644
> --- a/qapi/migration.json
> +++ b/qapi/migration.json
> @@ -1638,6 +1638,10 @@
   ##
   # @migrate:
   #
   # Migrates the current running guest to another Virtual Machine.
   #
   # @uri: the Uniform Resource Identifier of the destination VM
   #
   # @channels: list of migration stream channels with each stream in the
   #     list connected to a destination interface endpoint.
   #
   # @detach: this argument exists only for compatibility reasons and is
   #     ignored by QEMU
>  #
>  # @resume: resume one paused migration, default "off".  (since 3.0)

Unrelated to this patch, but here goes anyway.  What happens if I pass
@uri and @channels with I "resume": true, and they differ from the ones
passed originally?

>  #
> +# @config: migration configuration options, previously set via
> +#     @migrate-set-parameters and @migrate-set-capabilities.  (since
> +#     10.1)
> +#
>  # Since: 0.14
>  #
>  # .. admonition:: Notes
> @@ -1702,6 +1706,7 @@
>  { 'command': 'migrate',
>    'data': {'*uri': 'str',
>             '*channels': [ 'MigrationChannel' ],
> +           '*config': 'MigrationConfig',
>             '*detach': 'bool', '*resume': 'bool' } }
>  

Some configuration is passed in individual arguments, the remainder
wrapped in a struct.

Here's how we could avoid this.  'data': 'MigrateArguments' where
MigrateArguments is a struct with base MigrationConfig that adds the
other arguments.  Add 'boxed': true if you like.

Not sure it's wortwhile, but I wanted to show you for your
consideration.

>  ##
> @@ -1721,6 +1726,10 @@
>  #     error details could be retrieved with query-migrate.
>  #     (since 9.1)
>  #
> +# @config: migration configuration options, previously set via
> +#     @migrate-set-parameters and @migrate-set-capabilities.  (since
> +#     10.1)
> +#
>  # Since: 2.3
>  #
>  # .. admonition:: Notes
> @@ -1774,6 +1783,7 @@
>  { 'command': 'migrate-incoming',
>               'data': {'*uri': 'str',
>                        '*channels': [ 'MigrationChannel' ],
> +                      '*config': 'MigrationConfig',
>                        '*exit-on-error': 'bool' } }
>  
>  ##

Likewise.

> diff --git a/system/vl.c b/system/vl.c
> index ec93988a03..ea7040ef8d 100644
> --- a/system/vl.c
> +++ b/system/vl.c
> @@ -2826,7 +2826,8 @@ void qmp_x_exit_preconfig(Error **errp)
>                  g_new0(MigrationChannelList, 1);
>  
>              channels->value = incoming_channels[MIGRATION_CHANNEL_TYPE_MAIN];
> -            qmp_migrate_incoming(NULL, true, channels, true, true, &local_err);
> +            qmp_migrate_incoming(NULL, true, channels, NULL, true, true,
> +                                 &local_err);
>              if (local_err) {
>                  error_reportf_err(local_err, "-incoming %s: ", incoming);
>                  exit(1);
Re: [RFC PATCH 13/13] [PoC] migration: Allow migrate commands to provide the migration config
Posted by Peter Xu 5 months, 3 weeks ago
On Mon, May 26, 2025 at 10:03:55AM +0200, Markus Armbruster wrote:
> > diff --git a/qapi/migration.json b/qapi/migration.json
> > index bb2487dbc6..5bd8f0f1b2 100644
> > --- a/qapi/migration.json
> > +++ b/qapi/migration.json
> > @@ -1638,6 +1638,10 @@
>    ##
>    # @migrate:
>    #
>    # Migrates the current running guest to another Virtual Machine.
>    #
>    # @uri: the Uniform Resource Identifier of the destination VM
>    #
>    # @channels: list of migration stream channels with each stream in the
>    #     list connected to a destination interface endpoint.
>    #
>    # @detach: this argument exists only for compatibility reasons and is
>    #     ignored by QEMU
> >  #
> >  # @resume: resume one paused migration, default "off".  (since 3.0)
> 
> Unrelated to this patch, but here goes anyway.  What happens if I pass
> @uri and @channels with I "resume": true, and they differ from the ones
> passed originally?

I can answer this one - "resume" was designed to work always with new
channels/URI passed in.  It was currently only used for postcopy to resume
a paused postcopy migration where the old URI/channels stopped working
already.

The doc is indeed not obvious to show that, and can be confusing.  If
anyone thinks worthwhile, I can send a patch to touch it up:

diff --git a/qapi/migration.json b/qapi/migration.json
index 8b9c53595c..a4c9272e8b 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -1658,7 +1658,10 @@
 # @detach: this argument exists only for compatibility reasons and is
 #     ignored by QEMU
 #
-# @resume: resume one paused migration, default "off".  (since 3.0)
+# @resume: when set, resume one paused postcopy migration, using the new
+#     URI/channels specified to replace the old/broken channels.  The user
+#     should make sure the migration is in "postcopy-paused" state before
+#     the resume request.  Default "off".  (since 3.0)
 #
 # Since: 0.14
 #

Thanks,

-- 
Peter Xu