From: Markus Armbruster <armbru@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Cc: Michael Tokarev <mjt@tls.msk.ru>,
qemu-devel@nongnu.org, eblake@redhat.com, jasowang@redhat.com,
devel@lists.libvirt.org, pbonzini@redhat.com,
marcandre.lureau@redhat.com, yc-core@yandex-team.ru,
d-tatianin@yandex-team.ru, qemu-trivial@nongnu.org
Subject: Re: [PATCH 0/2] remove deprecated 'reconnect' options
Date: Fri, 10 Oct 2025 13:24:41 +0200 [thread overview]
Message-ID: <87ms5zj8xy.fsf@pond.sub.org> (raw)
In-Reply-To: <7503ba0e-2596-4919-b4ea-bc61e469564a@yandex-team.ru> (Vladimir Sementsov-Ogievskiy's message of "Fri, 10 Oct 2025 12:02:14 +0300")
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes:
> On 10.10.25 10:52, Michael Tokarev wrote:
>> On 10/9/25 17:17, Markus Armbruster wrote:
>>> Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes:
>>>
>>>> They were deprecated in 9.2, now we can remove them.
>>>> New options to use are reconnect-ms.
>> Speaking of the option itself.. I'd not remove it, instead,
>> I'd de-deprecate it, and allow units to be specified for it,
>> like reconnect=10ms (defaults to s). Or reconnect=0.1 (in
>> fractions of second). But it's just me, it looks like :)
>
> QAPI is not for humans) So simple milliseconds integer is better,
> then parse the variety of suffixes. And it better fit into json
> (number is number, not a string)
>
>> Also, `has_reconnect_ms` becomes redundant after applying this
>> patch, - it should be enough to use just reconnect_ms, which
>> defaults to 0. But this can be done in a subsequent cleanup.
>>
>
> You mean just use sock->reconnect_ms instead of explicit
>
> int64_t reconnect_ms = sock->has_reconnect_ms ? sock->reconnect_ms : 0;
>
> ?
We routinely exploit that QAPI initializes absent members to zero.
> I believe that QMP will zero-initialize everything. But I'm not sure
> that we do zero initialize this structure on all paths.. Keeping also in mind
> handling other fields here like
>
> bool is_telnet = sock->has_telnet ? sock->telnet : false;
> bool is_tn3270 = sock->has_tn3270 ? sock->tn3270 : false;
> bool is_waitconnect = sock->has_wait ? sock->wait : false;
> bool is_websock = sock->has_websocket ? sock->websocket : false;
>
> To drop this, we should check for all paths, that incoming structure is
> zero-initialized. And no guarantee that it does not break in future.
>
> Probably, we can implement a new QAPI feature "value with default to zero",
> so that we can avoid existence of .has_foo field at all for such fields.
> No field - no problem.. But not in this series)
The simple way to do "optional" is to have the machinery supply a
default value.
The less simple way is to add a distinct extra value that means
"absent". This permits "absent" to means something else than any value.
QAPI does the latter. Not my choice; I inherited it :)
For pointers, generated C uses null as distinct extra value. Works,
because "present" implies non-null.
For other types, generated C uses a pair of variables (has_FOO, FOO),
where
(true, V) means present with value V
(false, zero) means absent
(false, non-zero) is invalid
This results in slightly more complicated code.
Most of the time, code maps "absent" to a default value. This default
value is not visible in the schema, it's buried in the C code. When a
type gets used in multiple places, each place can pick its own default.
Bothersome to document, and the system cannot ensure the code matches
its documentation. Strong dislike.
Special case: when the default value is zero, we can ignore has_FOO and
just use FOO. See "routinely exploit" above.
We could extend the QAPI schema language to let us specify the default
value. The generator could then elide has_FOO. Code would become
simpler.
next prev parent reply other threads:[~2025-10-10 11:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-24 13:33 [PATCH 0/2] remove deprecated 'reconnect' options Vladimir Sementsov-Ogievskiy
2025-09-24 13:33 ` [PATCH v2 1/2] chardev: remove deprecated 'reconnect' option Vladimir Sementsov-Ogievskiy
2025-09-24 13:38 ` Daniil Tatianin
2025-09-24 13:33 ` [PATCH v2 2/2] net/stream: " Vladimir Sementsov-Ogievskiy
2025-09-24 13:38 ` Daniil Tatianin
2025-09-24 13:50 ` [PATCH 0/2] remove deprecated 'reconnect' options Ján Tomko
2025-09-24 13:52 ` Marc-André Lureau
2025-10-09 8:17 ` Vladimir Sementsov-Ogievskiy
2025-10-09 14:17 ` Markus Armbruster
2025-10-10 7:45 ` Michael Tokarev
2025-10-10 7:52 ` Michael Tokarev
2025-10-10 9:02 ` Vladimir Sementsov-Ogievskiy
2025-10-10 11:24 ` Markus Armbruster [this message]
2025-10-10 12:06 ` Vladimir Sementsov-Ogievskiy
-- strict thread matches above, loose matches on Subject: below --
2025-09-24 12:44 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=87ms5zj8xy.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=d-tatianin@yandex-team.ru \
--cc=devel@lists.libvirt.org \
--cc=eblake@redhat.com \
--cc=jasowang@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mjt@tls.msk.ru \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=vsementsov@yandex-team.ru \
--cc=yc-core@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.