From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: fam@euphon.net, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [PATCH] block: Introduce zero-co:// and zero-aio://
Date: Wed, 10 Mar 2021 15:22:52 +0100 [thread overview]
Message-ID: <d16dce2d-f844-5e58-6ae1-bbf366e74b60@redhat.com> (raw)
In-Reply-To: <20210310141752.5113-1-fam@euphon.net>
On 3/10/21 3:17 PM, fam@euphon.net wrote:
> From: Fam Zheng <famzheng@amazon.com>
>
> null-co:// has a read-zeroes=off default, when used to in security
> analysis, this can cause false positives because the driver doesn't
> write to the read buffer.
>
> null-co:// has the highest possible performance as a block driver, so
> let's keep it that way. This patch introduces zero-co:// and
> zero-aio://, largely similar with null-*://, but have read-zeroes=on by
> default, so it's more suitable in cases than null-co://.
Thanks!
>
> Signed-off-by: Fam Zheng <fam@euphon.net>
> ---
> block/null.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 91 insertions(+)
> +static int zero_file_open(BlockDriverState *bs, QDict *options, int flags,
> + Error **errp)
> +{
> + QemuOpts *opts;
> + BDRVNullState *s = bs->opaque;
> + int ret = 0;
> +
> + opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
> + qemu_opts_absorb_qdict(opts, options, &error_abort);
> + s->length =
> + qemu_opt_get_size(opts, BLOCK_OPT_SIZE, 1 << 30);
Please do not use this magic default value, let's always explicit the
size.
s->length = qemu_opt_get_size(opts, BLOCK_OPT_SIZE, 0);
if (s->length < 0) {
error_setg(errp, "%s is invalid", BLOCK_OPT_SIZE);
ret = -EINVAL;
}
> + s->latency_ns =
> + qemu_opt_get_number(opts, NULL_OPT_LATENCY, 0);
> + if (s->latency_ns < 0) {
> + error_setg(errp, "latency-ns is invalid");
> + ret = -EINVAL;
> + }
> + s->read_zeroes = true;
> + qemu_opts_del(opts);
> + bs->supported_write_flags = BDRV_REQ_FUA;
> + return ret;
> +}
Otherwise LGTM :)
next prev parent reply other threads:[~2021-03-10 14:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-10 14:17 [PATCH] block: Introduce zero-co:// and zero-aio:// fam
2021-03-10 14:22 ` Philippe Mathieu-Daudé [this message]
2021-03-10 14:28 ` Fam Zheng
2021-03-10 14:49 ` Philippe Mathieu-Daudé
2021-03-10 14:59 ` Fam Zheng
2021-03-10 14:40 ` Vladimir Sementsov-Ogievskiy
2021-03-10 14:59 ` Fam Zheng
2021-03-10 14:59 ` Max Reitz
2021-03-10 16:35 ` Fam Zheng
2021-03-11 12:11 ` Max Reitz
2021-03-10 17:37 ` Kevin Wolf
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=d16dce2d-f844-5e58-6ae1-bbf366e74b60@redhat.com \
--to=philmd@redhat.com \
--cc=fam@euphon.net \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).