All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>,
	qemu-block@nongnu.org,  qemu-devel@nongnu.org,
	 hreitz@redhat.com, kwolf@redhat.com
Subject: Re: [PATCH] qapi: merge common parts of NbdServerOptions and nbd-server-start data
Date: Thu, 13 Feb 2025 09:26:58 +0100	[thread overview]
Message-ID: <875xlel06l.fsf@pond.sub.org> (raw)
In-Reply-To: <ky3eygomndpcfsxvcwt3aqdnyqmkerzx6zzmusj432gpof4gge@tsxlpcqazel4> (Eric Blake's message of "Wed, 12 Feb 2025 16:12:46 -0600")

Eric Blake <eblake@redhat.com> writes:

> On Wed, Feb 12, 2025 at 05:33:51PM +0300, Vladimir Sementsov-Ogievskiy wrote:
>> Instead of comment
>> "Keep this type consistent with the nbd-server-start arguments", we
>> can simply merge these things.
>> 
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
>> ---
>> 
>> No problem for me to rebase on top of
>> [PATCH 0/2] nbd: Allow debugging tuning of handshake limit
>> if it goes earlier.
>
> I just sent the pull request for that, so this will indeed need
> rebasing.  But it's still worth reviewing as written.
>
>> 
>> Also, not that order of nbd-server-start is changed. I think the order

s/not/note/, I presume.

>> could not be a contract of JSON interface.
>
> Correct - QMP does not mandate wire ordering, so although the change
> causes C paramter rearrangement, it is not a breaking change.

Correct.

>> We could instead of making common base structure go another way
>> and define two structures with same data=NbdServerOptionsCommon, and
>> different bases (will have to define additional base strucutres with
>> SocketAddress and SocketAddressLegacy fields). But it would look a bit
>> unusual in QAPI.
>> 
>>  blockdev-nbd.c         |  4 +--
>>  qapi/block-export.json | 57 ++++++++++++++++++++----------------------
>>  2 files changed, 29 insertions(+), 32 deletions(-)
>> 
>> diff --git a/blockdev-nbd.c b/blockdev-nbd.c
>> index 9e61fbaf2b..b0b8993a1b 100644
>> --- a/blockdev-nbd.c
>> +++ b/blockdev-nbd.c
>> @@ -215,10 +215,10 @@ void nbd_server_start_options(NbdServerOptions *arg, Error **errp)
>>                       arg->max_connections, errp);
>>  }
>>  
>> -void qmp_nbd_server_start(SocketAddressLegacy *addr,
>> -                          const char *tls_creds,
>> +void qmp_nbd_server_start(const char *tls_creds,
>>                            const char *tls_authz,
>>                            bool has_max_connections, uint32_t max_connections,
>> +                          SocketAddressLegacy *addr,
>>                            Error **errp)
>>  {
>>      SocketAddress *addr_flat = socket_address_flatten(addr);
>> diff --git a/qapi/block-export.json b/qapi/block-export.json
>> index 117b05d13c..5eb94213db 100644
>> --- a/qapi/block-export.json
>> +++ b/qapi/block-export.json
>> @@ -9,13 +9,7 @@
>>  { 'include': 'block-core.json' }
>>  
>>  ##
>> -# @NbdServerOptions:
>> -#
>> -# Keep this type consistent with the nbd-server-start arguments.  The
>> -# only intended difference is using SocketAddress instead of
>> -# SocketAddressLegacy.
>> -#
>> -# @addr: Address on which to listen.
>> +# @NbdServerOptionsBase:
>>  #
>>  # @tls-creds: ID of the TLS credentials object (since 2.6).
>>  #
>> @@ -30,14 +24,35 @@
>>  #     server from advertising multiple client support (since 5.2;
>>  #     default: 100)
>>  #
>> -# Since: 4.2
>> +# Since: 10.0
>
> Markus, when refactoring types like this, should Since stay at the
> point in time where the fields were first introduced (4.2) or at the
> time where the refactoring introduced the new type (10.0)?  Or does
> type inlining make it all moot if this tag never shows up in the docs?

To answer this, we need to consider what doc comments are for:
documenting our external QMP interface for its users.

Types are not part of this QMP interface, only their members can be,
namely as arguments of commands and events, possibly nested into other
arguments.  Types can change in ways that do not affect the interface.
Like in this patch.

Since only members are part of the interface, only members need since
information.

Having to write down since information member by member all the time
would be onerous, so we provide a shorthand: write it down for the type,
and any members without explicit since use that.

This leads us to the answer to your question.  When you refactor types,
take care to preserve the interface documentation's since information,
just like you preserve the actual interface.

Much of the time, this is as trivial as "don't mess with since".

Sometimes, it involves things like adding a new type with an old since.

Occasionally, there's a conflict.  Say you unify two similar types into
one, a perfectly sane refactoring.  But the two types can have
conflicting since information.  Perhaps one type's member @foo goes back
to 4.2, and the other's goes back only to 9.1.  We don't have good
solutions for that.  We do our best in prose.

Maintaining accurate since information is bothersome and error prone.
It should be done by the machine, not us.  John and I have pondered ways
to do this, but we have other projects to finish first.

Questions?

[...]



  reply	other threads:[~2025-02-13  8:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-12 14:33 [PATCH] qapi: merge common parts of NbdServerOptions and nbd-server-start data Vladimir Sementsov-Ogievskiy
2025-02-12 22:12 ` Eric Blake
2025-02-13  8:26   ` Markus Armbruster [this message]
2025-02-13  9:25     ` Vladimir Sementsov-Ogievskiy

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=875xlel06l.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@yandex-team.ru \
    /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.