diff mbox series

[V1,18/26] migration: cpr-exec-args parameter

Message ID 1714406135-451286-19-git-send-email-steven.sistare@oracle.com (mailing list archive)
State New, archived
Headers show
Series Live update: cpr-exec | expand

Commit Message

Steven Sistare April 29, 2024, 3:55 p.m. UTC
Create the cpr-exec-args migration parameter, defined as a list of
strings.  It will be used for cpr-exec migration mode in a subsequent
patch.

No functional change, except that cpr-exec-args is shown by the
'info migrate' command.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
 hmp-commands.hx                |  2 +-
 migration/migration-hmp-cmds.c | 24 ++++++++++++++++++++++++
 migration/options.c            | 13 +++++++++++++
 qapi/migration.json            | 18 +++++++++++++++---
 4 files changed, 53 insertions(+), 4 deletions(-)

Comments

Markus Armbruster May 2, 2024, 12:23 p.m. UTC | #1
Steve Sistare <steven.sistare@oracle.com> writes:

> Create the cpr-exec-args migration parameter, defined as a list of
> strings.  It will be used for cpr-exec migration mode in a subsequent
> patch.
>
> No functional change, except that cpr-exec-args is shown by the
> 'info migrate' command.
>
> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>

[...]

> diff --git a/qapi/migration.json b/qapi/migration.json
> index 8c65b90..49710e7 100644
> --- a/qapi/migration.json
> +++ b/qapi/migration.json
> @@ -914,6 +914,9 @@
>  #     See description in @ZeroPageDetection.  Default is 'multifd'.
>  #     (since 9.0)
>  #
> +# @cpr-exec-args: Arguments passed to new QEMU for @cpr-exec mode.
> +#    See @cpr-exec for details.  (Since 9.1)
> +#

You mean migration mode @cpr-exec, don't you?

If yes, dangling reference until PATCH 20 adds it.  Okay, but worth a
mention in the commit message.

Suggest "See MigMode @cpr-exec for details."

>  # Features:
>  #
>  # @deprecated: Member @block-incremental is deprecated.  Use
> @@ -948,7 +951,8 @@
>             { 'name': 'x-vcpu-dirty-limit-period', 'features': ['unstable'] },
>             'vcpu-dirty-limit',
>             'mode',
> -           'zero-page-detection'] }
> +           'zero-page-detection',
> +           'cpr-exec-args'] }
>  
>  ##
>  # @MigrateSetParameters:
> @@ -1122,6 +1126,9 @@
>  #     See description in @ZeroPageDetection.  Default is 'multifd'.
>  #     (since 9.0)
>  #
> +# @cpr-exec-args: Arguments passed to new QEMU for @cpr-exec mode.
> +#    See @cpr-exec for details.  (Since 9.1)
> +#
>  # Features:
>  #
>  # @deprecated: Member @block-incremental is deprecated.  Use
> @@ -1176,7 +1183,8 @@
>                                              'features': [ 'unstable' ] },
>              '*vcpu-dirty-limit': 'uint64',
>              '*mode': 'MigMode',
> -            '*zero-page-detection': 'ZeroPageDetection'} }
> +            '*zero-page-detection': 'ZeroPageDetection',
> +            '*cpr-exec-args': [ 'str' ]} }
>  
>  ##
>  # @migrate-set-parameters:
> @@ -1354,6 +1362,9 @@
>  #     See description in @ZeroPageDetection.  Default is 'multifd'.
>  #     (since 9.0)
>  #
> +# @cpr-exec-args: Arguments passed to new QEMU for @cpr-exec mode.
> +#    See @cpr-exec for details.  (Since 9.1)
> +#
>  # Features:
>  #
>  # @deprecated: Member @block-incremental is deprecated.  Use
> @@ -1405,7 +1416,8 @@
>                                              'features': [ 'unstable' ] },
>              '*vcpu-dirty-limit': 'uint64',
>              '*mode': 'MigMode',
> -            '*zero-page-detection': 'ZeroPageDetection'} }
> +            '*zero-page-detection': 'ZeroPageDetection',
> +            '*cpr-exec-args': [ 'str' ]} }
>  
>  ##
>  # @query-migrate-parameters:
Steven Sistare May 2, 2024, 4 p.m. UTC | #2
On 5/2/2024 8:23 AM, Markus Armbruster wrote:
> Steve Sistare <steven.sistare@oracle.com> writes:
> 
>> Create the cpr-exec-args migration parameter, defined as a list of
>> strings.  It will be used for cpr-exec migration mode in a subsequent
>> patch.
>>
>> No functional change, except that cpr-exec-args is shown by the
>> 'info migrate' command.
>>
>> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
> 
> [...]
> 
>> diff --git a/qapi/migration.json b/qapi/migration.json
>> index 8c65b90..49710e7 100644
>> --- a/qapi/migration.json
>> +++ b/qapi/migration.json
>> @@ -914,6 +914,9 @@
>>   #     See description in @ZeroPageDetection.  Default is 'multifd'.
>>   #     (since 9.0)
>>   #
>> +# @cpr-exec-args: Arguments passed to new QEMU for @cpr-exec mode.
>> +#    See @cpr-exec for details.  (Since 9.1)
>> +#
> 
> You mean migration mode @cpr-exec, don't you?
> 
> If yes, dangling reference until PATCH 20 adds it.  Okay, but worth a
> mention in the commit message.
> 
> Suggest "See MigMode @cpr-exec for details."

Yes to all.  Will update as you suggest.

- Steve

>>   # Features:
>>   #
>>   # @deprecated: Member @block-incremental is deprecated.  Use
>> @@ -948,7 +951,8 @@
>>              { 'name': 'x-vcpu-dirty-limit-period', 'features': ['unstable'] },
>>              'vcpu-dirty-limit',
>>              'mode',
>> -           'zero-page-detection'] }
>> +           'zero-page-detection',
>> +           'cpr-exec-args'] }
>>   
>>   ##
>>   # @MigrateSetParameters:
>> @@ -1122,6 +1126,9 @@
>>   #     See description in @ZeroPageDetection.  Default is 'multifd'.
>>   #     (since 9.0)
>>   #
>> +# @cpr-exec-args: Arguments passed to new QEMU for @cpr-exec mode.
>> +#    See @cpr-exec for details.  (Since 9.1)
>> +#
>>   # Features:
>>   #
>>   # @deprecated: Member @block-incremental is deprecated.  Use
>> @@ -1176,7 +1183,8 @@
>>                                               'features': [ 'unstable' ] },
>>               '*vcpu-dirty-limit': 'uint64',
>>               '*mode': 'MigMode',
>> -            '*zero-page-detection': 'ZeroPageDetection'} }
>> +            '*zero-page-detection': 'ZeroPageDetection',
>> +            '*cpr-exec-args': [ 'str' ]} }
>>   
>>   ##
>>   # @migrate-set-parameters:
>> @@ -1354,6 +1362,9 @@
>>   #     See description in @ZeroPageDetection.  Default is 'multifd'.
>>   #     (since 9.0)
>>   #
>> +# @cpr-exec-args: Arguments passed to new QEMU for @cpr-exec mode.
>> +#    See @cpr-exec for details.  (Since 9.1)
>> +#
>>   # Features:
>>   #
>>   # @deprecated: Member @block-incremental is deprecated.  Use
>> @@ -1405,7 +1416,8 @@
>>                                               'features': [ 'unstable' ] },
>>               '*vcpu-dirty-limit': 'uint64',
>>               '*mode': 'MigMode',
>> -            '*zero-page-detection': 'ZeroPageDetection'} }
>> +            '*zero-page-detection': 'ZeroPageDetection',
>> +            '*cpr-exec-args': [ 'str' ]} }
>>   
>>   ##
>>   # @query-migrate-parameters:
>
Daniel P. Berrangé May 21, 2024, 8:13 a.m. UTC | #3
On Mon, Apr 29, 2024 at 08:55:27AM -0700, Steve Sistare wrote:
> Create the cpr-exec-args migration parameter, defined as a list of
> strings.  It will be used for cpr-exec migration mode in a subsequent
> patch.
> 
> No functional change, except that cpr-exec-args is shown by the
> 'info migrate' command.
> 
> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
> ---
>  hmp-commands.hx                |  2 +-
>  migration/migration-hmp-cmds.c | 24 ++++++++++++++++++++++++
>  migration/options.c            | 13 +++++++++++++
>  qapi/migration.json            | 18 +++++++++++++++---
>  4 files changed, 53 insertions(+), 4 deletions(-)
> 
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index 2e2a3bc..39954ae 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -1012,7 +1012,7 @@ ERST
>  
>      {
>          .name       = "migrate_set_parameter",
> -        .args_type  = "parameter:s,value:s",
> +        .args_type  = "parameter:s,value:S",
>          .params     = "parameter value",
>          .help       = "Set the parameter for migration",
>          .cmd        = hmp_migrate_set_parameter,
> diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
> index 7e96ae6..414c7e8 100644
> --- a/migration/migration-hmp-cmds.c
> +++ b/migration/migration-hmp-cmds.c
> @@ -255,6 +255,18 @@ void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict)
>      qapi_free_MigrationCapabilityStatusList(caps);
>  }
>  
> +static void monitor_print_cpr_exec_args(Monitor *mon, strList *args)
> +{
> +    monitor_printf(mon, "%s:",
> +        MigrationParameter_str(MIGRATION_PARAMETER_CPR_EXEC_ARGS));
> +
> +    while (args) {
> +        monitor_printf(mon, " %s", args->value);
> +        args = args->next;
> +    }
> +    monitor_printf(mon, "\n");
> +}
> +
>  void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
>  {
>      MigrationParameters *params;
> @@ -397,6 +409,8 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
>          monitor_printf(mon, "%s: %s\n",
>              MigrationParameter_str(MIGRATION_PARAMETER_MODE),
>              qapi_enum_lookup(&MigMode_lookup, params->mode));
> +        assert(params->has_cpr_exec_args);
> +        monitor_print_cpr_exec_args(mon, params->cpr_exec_args);
>      }
>  
>      qapi_free_MigrationParameters(params);
> @@ -690,6 +704,16 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
>          p->has_mode = true;
>          visit_type_MigMode(v, param, &p->mode, &err);
>          break;
> +    case MIGRATION_PARAMETER_CPR_EXEC_ARGS: {
> +        g_autofree char **strv = g_strsplit(valuestr ?: "", " ", -1);

Splitting on whitespace means it'll break with any arguments containing
quoted whitespace. If we use g_shell_parse_argv then it should support
quoting in the normal shell mannre.

> +        strList **tail = &p->cpr_exec_args;
> +
> +        for (int i = 0; strv[i]; i++) {
> +            QAPI_LIST_APPEND(tail, strv[i]);
> +        }
> +        p->has_cpr_exec_args = true;
> +        break;
> +    }
>      default:
>          assert(0);
>      }

With regards,
Daniel
diff mbox series

Patch

diff --git a/hmp-commands.hx b/hmp-commands.hx
index 2e2a3bc..39954ae 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1012,7 +1012,7 @@  ERST
 
     {
         .name       = "migrate_set_parameter",
-        .args_type  = "parameter:s,value:s",
+        .args_type  = "parameter:s,value:S",
         .params     = "parameter value",
         .help       = "Set the parameter for migration",
         .cmd        = hmp_migrate_set_parameter,
diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
index 7e96ae6..414c7e8 100644
--- a/migration/migration-hmp-cmds.c
+++ b/migration/migration-hmp-cmds.c
@@ -255,6 +255,18 @@  void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict)
     qapi_free_MigrationCapabilityStatusList(caps);
 }
 
+static void monitor_print_cpr_exec_args(Monitor *mon, strList *args)
+{
+    monitor_printf(mon, "%s:",
+        MigrationParameter_str(MIGRATION_PARAMETER_CPR_EXEC_ARGS));
+
+    while (args) {
+        monitor_printf(mon, " %s", args->value);
+        args = args->next;
+    }
+    monitor_printf(mon, "\n");
+}
+
 void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
 {
     MigrationParameters *params;
@@ -397,6 +409,8 @@  void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
         monitor_printf(mon, "%s: %s\n",
             MigrationParameter_str(MIGRATION_PARAMETER_MODE),
             qapi_enum_lookup(&MigMode_lookup, params->mode));
+        assert(params->has_cpr_exec_args);
+        monitor_print_cpr_exec_args(mon, params->cpr_exec_args);
     }
 
     qapi_free_MigrationParameters(params);
@@ -690,6 +704,16 @@  void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
         p->has_mode = true;
         visit_type_MigMode(v, param, &p->mode, &err);
         break;
+    case MIGRATION_PARAMETER_CPR_EXEC_ARGS: {
+        g_autofree char **strv = g_strsplit(valuestr ?: "", " ", -1);
+        strList **tail = &p->cpr_exec_args;
+
+        for (int i = 0; strv[i]; i++) {
+            QAPI_LIST_APPEND(tail, strv[i]);
+        }
+        p->has_cpr_exec_args = true;
+        break;
+    }
     default:
         assert(0);
     }
diff --git a/migration/options.c b/migration/options.c
index 239f5ec..89082cc 100644
--- a/migration/options.c
+++ b/migration/options.c
@@ -1060,6 +1060,8 @@  MigrationParameters *qmp_query_migrate_parameters(Error **errp)
     params->mode = s->parameters.mode;
     params->has_zero_page_detection = true;
     params->zero_page_detection = s->parameters.zero_page_detection;
+    params->has_cpr_exec_args = true;
+    params->cpr_exec_args = QAPI_CLONE(strList, s->parameters.cpr_exec_args);
 
     return params;
 }
@@ -1097,6 +1099,7 @@  void migrate_params_init(MigrationParameters *params)
     params->has_vcpu_dirty_limit = true;
     params->has_mode = true;
     params->has_zero_page_detection = true;
+    params->has_cpr_exec_args = true;
 }
 
 /*
@@ -1416,6 +1419,10 @@  static void migrate_params_test_apply(MigrateSetParameters *params,
     if (params->has_zero_page_detection) {
         dest->zero_page_detection = params->zero_page_detection;
     }
+
+    if (params->has_cpr_exec_args) {
+        dest->cpr_exec_args = params->cpr_exec_args;
+    }
 }
 
 static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
@@ -1570,6 +1577,12 @@  static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
     if (params->has_zero_page_detection) {
         s->parameters.zero_page_detection = params->zero_page_detection;
     }
+
+    if (params->has_cpr_exec_args) {
+        qapi_free_strList(s->parameters.cpr_exec_args);
+        s->parameters.cpr_exec_args =
+            QAPI_CLONE(strList, params->cpr_exec_args);
+    }
 }
 
 void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp)
diff --git a/qapi/migration.json b/qapi/migration.json
index 8c65b90..49710e7 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -914,6 +914,9 @@ 
 #     See description in @ZeroPageDetection.  Default is 'multifd'.
 #     (since 9.0)
 #
+# @cpr-exec-args: Arguments passed to new QEMU for @cpr-exec mode.
+#    See @cpr-exec for details.  (Since 9.1)
+#
 # Features:
 #
 # @deprecated: Member @block-incremental is deprecated.  Use
@@ -948,7 +951,8 @@ 
            { 'name': 'x-vcpu-dirty-limit-period', 'features': ['unstable'] },
            'vcpu-dirty-limit',
            'mode',
-           'zero-page-detection'] }
+           'zero-page-detection',
+           'cpr-exec-args'] }
 
 ##
 # @MigrateSetParameters:
@@ -1122,6 +1126,9 @@ 
 #     See description in @ZeroPageDetection.  Default is 'multifd'.
 #     (since 9.0)
 #
+# @cpr-exec-args: Arguments passed to new QEMU for @cpr-exec mode.
+#    See @cpr-exec for details.  (Since 9.1)
+#
 # Features:
 #
 # @deprecated: Member @block-incremental is deprecated.  Use
@@ -1176,7 +1183,8 @@ 
                                             'features': [ 'unstable' ] },
             '*vcpu-dirty-limit': 'uint64',
             '*mode': 'MigMode',
-            '*zero-page-detection': 'ZeroPageDetection'} }
+            '*zero-page-detection': 'ZeroPageDetection',
+            '*cpr-exec-args': [ 'str' ]} }
 
 ##
 # @migrate-set-parameters:
@@ -1354,6 +1362,9 @@ 
 #     See description in @ZeroPageDetection.  Default is 'multifd'.
 #     (since 9.0)
 #
+# @cpr-exec-args: Arguments passed to new QEMU for @cpr-exec mode.
+#    See @cpr-exec for details.  (Since 9.1)
+#
 # Features:
 #
 # @deprecated: Member @block-incremental is deprecated.  Use
@@ -1405,7 +1416,8 @@ 
                                             'features': [ 'unstable' ] },
             '*vcpu-dirty-limit': 'uint64',
             '*mode': 'MigMode',
-            '*zero-page-detection': 'ZeroPageDetection'} }
+            '*zero-page-detection': 'ZeroPageDetection',
+            '*cpr-exec-args': [ 'str' ]} }
 
 ##
 # @query-migrate-parameters: