From: Markus Armbruster <armbru@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: Nir Soffer <nirsof@gmail.com>,
qemu-devel@nongnu.org, qemu-block@nongnu.org,
Kevin Wolf <kwolf@redhat.com>, Fam Zheng <fam@euphon.net>,
Hanna Reitz <hreitz@redhat.com>
Subject: Re: [PATCH v2 2/2] block/null: Add read-pattern option
Date: Fri, 09 May 2025 09:19:19 +0200 [thread overview]
Message-ID: <875xiab6a0.fsf@pond.sub.org> (raw)
In-Reply-To: <mykoj5oasoeq3k4xa7c2f4kt4sybz3o7plf7wc6ma27auh7gst@2anh6h54xam7> (Eric Blake's message of "Thu, 8 May 2025 09:30:43 -0500")
Eric Blake <eblake@redhat.com> writes:
> On Thu, May 08, 2025 at 07:28:26AM +0200, Markus Armbruster wrote:
>> Let's take a step back from the concrete interface and ponder what we're
>> trying to do. We want three cases:
>>
>> * Allocated, reads return unspecified crap (security hazard)
>>
>> * Allocated, reads return specified data
>>
>> * Sparse, reads return zeroes
>>
>> How would we do this if we started on a green field?
>>
>> Here's my try:
>>
>> bool sparse
>> uint8 contents
>>
>> so that
>>
>> * Allocated, reads return unspecified crap (security hazard)
>>
>> @sparse is false, and @contents is absent
>>
>> * Allocated, reads return specified data
>>
>> @sparse is false, and @contents is present
>>
>> * Sparse, reads return zeroes
>>
>> @sparse is true, and @contents must absent or zero
>
> That indeed is a nice view of what we hope to test with.
>
>>
>> I'd make @sparse either mandatory or default to true, so that we don't
>> default to security hazard.
>>
>> Now compare this to your patch: same configuration data (bool × uint8),
>> better names, cleaner semantics, better defaults.
>>
>> Unless we want to break compatibility, we're stuck with the name
>> @read-zeroes for the bool, and its trap-for-the-unwary default value,
>> but cleaner semantics seem possible.
>>
>> Thoughts?
>
> What if we add @sparse as an optional bool, but mutually exclusive
> with @read-zeroes. That would lead to 27 combinations of absent,
> present with 0 value, or present with non-zero value; but with fewer
> actual cases supported. Something like your above table of what to do
> with sparse and contents, and with these additional rules:
>
> read-zeroes omitted, sparse omitted
> - at present, defaults to sparse=false for back-compat
> - may change in the future [*]
> read-zeroes present, sparse omitted
> - behaves like explicit setting of sparse, but with old spelling
> - may issue a deprecation warning [*]
> read-zeroes omitted, sparse present
> - explicit spelling, no warning (use above logic for how contents acts)
> read-zeroes and sparse both present
> - error, whether values were same or different
>
> [*] Simultaneously, we start the deprecation cycle on @read-zeroes -
> tagging it as deprecated now, and removing it in a couple of releases.
> Once it is gone, we are left with just @sparse; at that time, we can
> decide to either make it mandatory (if so, we should warn now if
> neither read-zeroes nor sparse is specified), or leave it optional but
> change it to default true (so that the security hazard of sparse:false
> and omitted contents is now opt-in instead of default).
The recommended way to stay on top of deprecations in QMP is to test
with -compat deprecated-input=reject,deprecated-output=hide or similar.
This relies on special feature 'deprecated', and is limited to syntax.
There is no way to formally deprecate defaults.
We can deprecate @read-zeroes, but this wouldn't cover behavior when
absent. Changing that is a compatibility break. Hard to justify.
Except when the interface in question is unstable. Block drivers
null-aio and null-co aren't. Should they?
Warnings are awkward with QMP. We can only warn to stderr.
next prev parent reply other threads:[~2025-05-09 7:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-30 20:37 [PATCH v2 0/2] block/null: Add read-pattern option Nir Soffer
2025-04-30 20:37 ` [PATCH v2 1/2] block/null: Report DATA if not reading zeroes Nir Soffer
2025-05-08 4:37 ` Markus Armbruster
2025-05-08 5:03 ` Markus Armbruster
2025-05-08 5:20 ` Markus Armbruster
2025-05-16 21:35 ` Nir Soffer
2025-05-16 21:32 ` Nir Soffer
2025-05-16 21:31 ` Nir Soffer
2025-04-30 20:37 ` [PATCH v2 2/2] block/null: Add read-pattern option Nir Soffer
2025-05-08 5:28 ` Markus Armbruster
2025-05-08 14:30 ` Eric Blake
2025-05-09 7:19 ` Markus Armbruster [this message]
2025-05-16 21:12 ` Nir Soffer
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=875xiab6a0.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=fam@euphon.net \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=nirsof@gmail.com \
--cc=qemu-block@nongnu.org \
--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.