All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Fabiano Rosas <farosas@suse.de>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
	qemu-devel@nongnu.org, "Peter Xu" <peterx@redhat.com>
Subject: Re: [RFC PATCH 05/13] migration: Reduce a bit of duplication in migration.json
Date: Wed, 16 Apr 2025 15:38:38 +0200	[thread overview]
Message-ID: <878qo0mdk1.fsf@pond.sub.org> (raw)
In-Reply-To: <87y0w2fzhp.fsf@suse.de> (Fabiano Rosas's message of "Mon, 14 Apr 2025 14:02:10 -0300")

Fabiano Rosas <farosas@suse.de> writes:

> Daniel P. Berrangé <berrange@redhat.com> writes:
>
>> On Fri, Apr 11, 2025 at 04:14:35PM -0300, Fabiano Rosas wrote:
>>> Introduce a new MigrationConfigBase, to allow most of the duplication
>>> in migration.json to be eliminated.
>>> 
>>> The reason we need MigrationParameters and MigrationSetParameters is
>>> that the internal parameter representation in the migration code, as
>>> well as the user-facing return of query-migrate-parameters use one
>>> type for the TLS options (tls-creds, tls-hostname, tls-authz), while
>>> the user-facing input from migrate-set-parameters uses another.
>>> 
>>> The difference is in whether the NULL values is accepted. The former
>>> considers NULL as invalid, while the latter doesn't.
>>> 
>>> Move all other (non-TLS) options into the new type and make it a base
>>> type for the two diverging types so that each child type can declare
>>> the TLS options in its own way.
>>> 
>>> Nothing changes in the user API, nothing changes in the internal
>>> representation, but we save several lines of duplication in
>>> migration.json.
>>> 
>>> Signed-off-by: Fabiano Rosas <farosas@suse.de>
>>> ---
>>>  qapi/migration.json | 358 +++++++++++++-------------------------------
>>>  1 file changed, 108 insertions(+), 250 deletions(-)
>>> 
>>> diff --git a/qapi/migration.json b/qapi/migration.json
>>> index 8b9c53595c..5a4d5a2d3e 100644
>>> --- a/qapi/migration.json
>>> +++ b/qapi/migration.json
>>> @@ -914,202 +914,6 @@
>>
>>> @@ -1277,45 +1059,121 @@
>>>  #     only has effect if the @mapped-ram capability is enabled.
>>>  #     (Since 9.1)
>>>  #
>>> +# @tls: Whether to use TLS. If this is set the options @tls-authz,
>>> +#     @tls-creds, @tls-hostname are mandatory and a valid string is
>>> +#     expected. (Since 10.1)
>>> +#
>>
>> I'm not really finding it compelling to add a bool @tls as it
>> is just a denormalization of  !!@tls-creds.
>>
>
> This is here by mistake.
>
> I remember Markus mentioning that implying TLS usage from tls-creds was
> undesirable. I was prototyping a way of requiring an explicit opt-in.

I don't remember a thing :)

>> Incidentally the docs here are wrong - TLS can be used by
>> only setting @tls-creds. The @tls-authz & @tls-hostname
>> params are always optional.
>>
>>>  # Features:
>>>  #
>>>  # @unstable: Members @x-checkpoint-delay and
>>>  #     @x-vcpu-dirty-limit-period are experimental.
>>>  #
>>> +# Since: 10.1
>>> +##
>>> +{ 'struct': 'MigrationConfigBase',
>>> +  'data': { '*announce-initial': 'size',
>>> +            '*announce-max': 'size',
>>> +            '*announce-rounds': 'size',
>>> +            '*announce-step': 'size',
>>> +            '*throttle-trigger-threshold': 'uint8',
>>> +            '*cpu-throttle-initial': 'uint8',
>>> +            '*cpu-throttle-increment': 'uint8',
>>> +            '*cpu-throttle-tailslow': 'bool',
>>> +            '*max-bandwidth': 'size',
>>> +            '*avail-switchover-bandwidth': 'size',
>>> +            '*downtime-limit': 'uint64',
>>> +            '*x-checkpoint-delay': { 'type': 'uint32',
>>> +                                     'features': [ 'unstable' ] },
>>> +            '*multifd-channels': 'uint8',
>>> +            '*xbzrle-cache-size': 'size',
>>> +            '*max-postcopy-bandwidth': 'size',
>>> +            '*max-cpu-throttle': 'uint8',
>>> +            '*multifd-compression': 'MultiFDCompression',
>>> +            '*multifd-zlib-level': 'uint8',
>>> +            '*multifd-qatzip-level': 'uint8',
>>> +            '*multifd-zstd-level': 'uint8',
>>> +            '*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ],
>>> +            '*x-vcpu-dirty-limit-period': { 'type': 'uint64',
>>> +                                            'features': [ 'unstable' ] },
>>> +            '*vcpu-dirty-limit': 'uint64',
>>> +            '*mode': 'MigMode',
>>> +            '*zero-page-detection': 'ZeroPageDetection',
>>> +            '*direct-io': 'bool',
>>> +            '*tls': 'bool' } }
>>
>>
>>>  { 'struct': 'MigrationParameters',
>>> +  'base': 'MigrationConfigBase',
>>> +  'data': { 'tls-creds': 'str',
>>> +            'tls-hostname': 'str',
>>> +            'tls-authz': 'str' } }
>>
>> snip
>>
>>> +{ 'struct': 'MigrateSetParameters',
>>> +  'base': 'MigrationConfigBase',
>>> +  'data': { '*tls-creds': 'StrOrNull',
>>> +            '*tls-hostname': 'StrOrNull',
>>> +            '*tls-authz': 'StrOrNull' } }
>>
>> I recall we discussed this difference a year or two ago, but can't
>> recall what the outcome was.
>>
>> Making the TLS params optional is a back compatible change for
>> MigrationParameters. I would think replacing 'str' with 'StrOrNull'
>> is also back compatible. So I'm wondering if we can't just unify
>> the sttructs fully for TLS, even if one usage scenario never actually
>> needs the "OrNull" bit nor needs the optionality 
>>
>
> MigrationParameters is the output type for query-migrate-parameters. I
> belive it must be all non-optional to keep compatibility. The docs on
> master say: "The optional members aren't really optional"

To be precise: even though the members are declared optional, they must
always be present.

The members became optional when commit de63ab61241 (migrate: Share
common MigrationParameters struct) reused MigrationParameters as
migrate-set-parameters argument type.

Making mandatory members of some type optional is compatible as long as
the type occurs only in command arguments.  But MigrationParameters is a
command return type.  Making its members optional was not kosher.
Because the optional members are always present, QMP didn't actually
change, except for introspection.

> For MigrateSetParameters they've always been optional and continue to
> be. There we need to keep StrOrNull for compat.

StrOrNull goes back to commit 01fa5598269 (migration: Use JSON null
instead of "" to reset parameter to default).

Similar argument: adding values to a member is compatible as long as the
type occurs only in command arguments.  But MigrationParameters is a
command return type.  Adding value null is won't be kosher.  However, as
long as as the value is never actually used there, QMP won't actually
change, except for introspection.

If this was a clean and obvious interface, I'd argue against such
trickery and for keeping it clean and obvious.  But the migration
configuration interface isn't.



  reply	other threads:[~2025-04-16 13:39 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-11 19:14 [RFC PATCH 00/13] migration: Unify capabilities and parameters Fabiano Rosas
2025-04-11 19:14 ` [RFC PATCH 01/13] migration: Fix latent bug in migrate_params_test_apply() Fabiano Rosas
2025-04-11 19:14 ` [RFC PATCH 02/13] migration: Normalize tls arguments Fabiano Rosas
2025-04-14 16:30   ` Daniel P. Berrangé
2025-04-11 19:14 ` [RFC PATCH 03/13] migration: Run a post update routine after setting parameters Fabiano Rosas
2025-05-15 20:42   ` Peter Xu
2025-04-11 19:14 ` [RFC PATCH 04/13] migration: Fix parameter validation Fabiano Rosas
2025-05-15 20:59   ` Peter Xu
2025-05-22 16:39     ` Fabiano Rosas
2025-05-22 17:39       ` Fabiano Rosas
2025-05-26 13:09         ` Peter Xu
2025-05-26 15:41           ` Fabiano Rosas
2025-04-11 19:14 ` [RFC PATCH 05/13] migration: Reduce a bit of duplication in migration.json Fabiano Rosas
2025-04-14 16:38   ` Daniel P. Berrangé
2025-04-14 17:02     ` Fabiano Rosas
2025-04-16 13:38       ` Markus Armbruster [this message]
2025-04-16 14:41         ` Fabiano Rosas
2025-04-17  5:56           ` Markus Armbruster
2025-04-17 18:45   ` Markus Armbruster
2025-04-18  6:40     ` Markus Armbruster
2025-04-11 19:14 ` [RFC PATCH 06/13] migration: Remove the parameters copy during validation Fabiano Rosas
2025-04-11 19:14 ` [RFC PATCH 07/13] migration: Introduce new MigrationConfig structure Fabiano Rosas
2025-04-18  7:03   ` Markus Armbruster
2025-05-23 13:38     ` Fabiano Rosas
2025-05-26  7:37       ` Markus Armbruster
2025-04-11 19:14 ` [RFC PATCH 08/13] migration: Replace s->parameters with s->config Fabiano Rosas
2025-04-11 19:14 ` [RFC PATCH 09/13] migration: Do away with usage of QERR_INVALID_PARAMETER_VALUE Fabiano Rosas
2025-04-11 19:14 ` [RFC PATCH 10/13] migration: Replace s->capabilities with s->config Fabiano Rosas
2025-04-11 19:14 ` [RFC PATCH 11/13] migration: Merge parameters and capability checks Fabiano Rosas
2025-04-11 19:14 ` [RFC PATCH 12/13] [PoC] migration: Add query/set commands for MigrationConfig Fabiano Rosas
2025-05-26  7:51   ` Markus Armbruster
2025-05-27 22:14     ` Fabiano Rosas
2025-04-11 19:14 ` [RFC PATCH 13/13] [PoC] migration: Allow migrate commands to provide the migration config Fabiano Rosas
2025-05-26  8:03   ` Markus Armbruster
2025-05-26 15:10     ` Peter Xu
2025-04-14 16:44 ` [RFC PATCH 00/13] migration: Unify capabilities and parameters Daniel P. Berrangé
2025-04-14 17:12   ` Fabiano Rosas
2025-04-14 17:20     ` Daniel P. Berrangé
2025-04-14 17:40       ` Fabiano Rosas
2025-04-14 19:06         ` Daniel P. Berrangé
2025-05-15 20:21         ` Peter Xu
2025-04-16 13:44   ` Markus Armbruster
2025-04-16 15:00     ` Fabiano Rosas
2025-04-24  9:35       ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878qo0mdk1.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=farosas@suse.de \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.