From: Eric Blake <eblake@redhat.com>
To: Denis Plotnikov <dplotnikov@virtuozzo.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH v10] qemu-io: add pattern file for write command
Date: Tue, 20 Aug 2019 12:24:58 -0500 [thread overview]
Message-ID: <d1de09cd-2243-0ae8-c589-2871be826f66@redhat.com> (raw)
In-Reply-To: <20190820164616.4072-1-dplotnikov@virtuozzo.com>
[-- Attachment #1.1: Type: text/plain, Size: 2553 bytes --]
On 8/20/19 11:46 AM, Denis Plotnikov wrote:
> The patch allows to provide a pattern file for write
> command. There was no similar ability before.
>
> Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
> ---
> @@ -983,8 +1057,9 @@ static int write_f(BlockBackend *blk, int argc, char **argv)
> /* Some compilers get confused and warn if this is not initialized. */
> int64_t total = 0;
> int pattern = 0xcd;
> + const char *file_name = NULL;
>
> - while ((c = getopt(argc, argv, "bcCfnpP:quz")) != -1) {
> + while ((c = getopt(argc, argv, "bcCfnpP:quzs:")) != -1) {
This one looks odd (I would have preserved ordering by sticking s:
between q and u). But a maintainer could fix that.
> switch (c) {
> case 'b':
> bflag = true;
> @@ -1020,6 +1095,10 @@ static int write_f(BlockBackend *blk, int argc, char **argv)
> case 'z':
> zflag = true;
> break;
> + case 's':
> + sflag = true;
> + file_name = optarg;
> + break;
Likewise, sorting the cases in the same order as the getopt() listing
helps in finding code during later edits.
> @@ -1088,7 +1168,14 @@ static int write_f(BlockBackend *blk, int argc, char **argv)
> }
>
> if (!zflag) {
> - buf = qemu_io_alloc(blk, count, pattern);
> + if (sflag) {
> + buf = qemu_io_alloc_from_file(blk, count, file_name);
> + if (!buf) {
> + return -EINVAL;
> + }
> + } else {
> + buf = qemu_io_alloc(blk, count, pattern);
> + }
Pre-existing, but it is odd that qemu_io_alloc() exit()s rather than
returning NULL on huge allocation requests that can't be met. (Then
again, we have an early exit on any length > 2G, and 2G allocations tend
to succeed on modern development machines). Perhaps it would be nice to
teach qemu-io to use blk_try_blockalign for more graceful handling even
on 32-bit platforms, but that's not the problem of your patch.
Option ordering is minor enough that I'm fine giving:
Reviewed-by: Eric Blake <eblake@redhat.com>
Now, to figure out which maintainer should take it. Perhaps you want to
add a patch 2/1 that adds an iotest using this new mode, to a) ensure it
doesn't regress, and b) makes it reasonable to take in through the
iotest tree.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-08-20 17:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-20 16:46 [Qemu-devel] [PATCH v10] qemu-io: add pattern file for write command Denis Plotnikov
2019-08-20 17:24 ` Eric Blake [this message]
2019-08-20 19:16 ` Max Reitz
2019-08-20 19:19 ` John Snow
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=d1de09cd-2243-0ae8-c589-2871be826f66@redhat.com \
--to=eblake@redhat.com \
--cc=dplotnikov@virtuozzo.com \
--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).