All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: "Denis V. Lunev" <den@openvz.org>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
	 Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>,
	 Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>,
	Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Subject: Re: [PATCH 10/13] qemu-io: add -g to write past the end of the image
Date: Mon, 5 Oct 2026 15:36:41 -0500	[thread overview]
Message-ID: <asQJArdFNRiILy_o@redhat.com> (raw)
In-Reply-To: <20260930165000.303236-11-den@openvz.org>

On Wed, Sep 30, 2026 at 06:49:56PM +0200, Denis V. Lunev wrote:
> From: Denis V. Lunev <den@openvz.org>
> 
> The preallocate filter only does anything for a write that lands beyond
> the end of its file, and that is what a format driver above it produces.
> qemu-io could not produce it at all: the backend rejects such a request
> with EIO, and the write path asserts without the resize permission, so
> the filter could only be reached by stacking a real format on top and
> letting it choose the offsets.
> 
> Take the resize permission and allow writes beyond the end when -g is
> given, which leaves the tool free to address the filter directly.
> 
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Kevin Wolf <kwolf@redhat.com>
> CC: Hanna Reitz <hreitz@redhat.com>
> CC: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> CC: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
> ---
>  qemu-io.c | 32 +++++++++++++++++++++++++++++---
>  1 file changed, 29 insertions(+), 3 deletions(-)
> 
> diff --git a/qemu-io.c b/qemu-io.c
> index 2b684ccf55..87254b32ff 100644
> --- a/qemu-io.c
> +++ b/qemu-io.c
> @@ -45,6 +45,7 @@ static bool quit_qemu_io;
>  static int ncmdline;

> @@ -149,7 +166,7 @@ static const cmdinfo_t open_cmd = {
>      .argmin     = 1,
>      .argmax     = -1,
>      .flags      = CMD_NOFILE_OK,
> -    .args       = "[-rsCnkU] [-t cache] [-d discard] [-o options] [path]",
> +    .args       = "[-grsCnkU] [-t cache] [-d discard] [-o options] [path]",

No real pattern to how we sort the letters in this help synopsis, so
your choice of sticking -g first is no worse.

> @@ -175,7 +192,7 @@ static int open_f(BlockBackend *blk, int argc, char **argv, Error **errp)
>      QDict *opts;
>      bool force_share = false;
>  
> -    while ((c = getopt(argc, argv, "snCro:ki:t:d:U")) != -1) {
> +    while ((c = getopt(argc, argv, "gsnCro:ki:t:d:U")) != -1) {
>          switch (c) {
>          case 's':
>              flags |= BDRV_O_SNAPSHOT;
> @@ -228,6 +245,9 @@ static int open_f(BlockBackend *blk, int argc, char **argv, Error **errp)
>          case 'U':
>              force_share = true;
>              break;
> +        case 'g':
> +            write_beyond_eof = true;
> +            break;
>          default:

With a maintainer's hat on, I do find it easier to patch a getopt()
call where the short-option string was in alphabetical order (mixed
case okay) and then the case statements are in the same order. Even if
the option string is NOT in alphabetical order, keeping the case
statements in the same order makes some sense (ie. since you put 'g'
before 's' in the optstring, it should be before 's' in the case
statements).  However, while the maintainance of sticking 'g' at the
end rather than in any particular order is harder, the logic is not
wrong; and shuffling cases is minor enough that whether or not you do
that on a respin, you can add:

Reviewed-by: Eric Blake <eblake@redhat.com>

> @@ -522,6 +544,7 @@ int main(int argc, char **argv)
>          { "object", required_argument, NULL, OPTION_OBJECT },
>          { "image-opts", no_argument, NULL, OPTION_IMAGE_OPTS },
>          { "force-share", no_argument, 0, 'U'},
> +        { "grow", no_argument, NULL, 'g' },

Pre-existing, but since you're touching this, it might be nice to use
NULL in place of 0 on the force-share line.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization:  qemu.org | libguestfs.org



  reply	other threads:[~2026-10-05 20:37 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30 16:49 [PATCH 00/13] block: fix data loss in the preallocate filter Denis V. Lunev
2026-09-30 16:49 ` [PATCH 01/13] block/file-posix: drop the XFS workaround for post-EOF fallocate Denis V. Lunev
2026-10-02 16:16   ` Andrey Drobyshev
2026-09-30 16:49 ` [PATCH 02/13] block/preallocate: keep zero_start above written data Denis V. Lunev
2026-10-02 16:16   ` Andrey Drobyshev
2026-09-30 16:49 ` [PATCH 03/13] block/preallocate: collect the state assignments in one place Denis V. Lunev
2026-10-02 16:16   ` Andrey Drobyshev
2026-09-30 16:49 ` [PATCH 04/13] block/preallocate: serialise the filter state Denis V. Lunev
2026-10-02 16:16   ` Andrey Drobyshev
2026-09-30 16:49 ` [PATCH 05/13] block/preallocate: hold back writes into a preallocation in flight Denis V. Lunev
2026-10-02 16:16   ` Andrey Drobyshev
2026-09-30 16:49 ` [PATCH 06/13] iotests/298: add testcase for async writes with preallocation filter Denis V. Lunev
2026-09-30 16:49 ` [PATCH 07/13] tests/unit: prefix the iothread test helper Denis V. Lunev
2026-10-05 20:06   ` Eric Blake
2026-09-30 16:49 ` [PATCH 08/13] qemu-io: accept --object iothread Denis V. Lunev
2026-10-05 20:11   ` Eric Blake
2026-09-30 16:49 ` [PATCH 09/13] qemu-io: add -t to run an aio request in a named iothread Denis V. Lunev
2026-10-05 20:28   ` Eric Blake
2026-09-30 16:49 ` [PATCH 10/13] qemu-io: add -g to write past the end of the image Denis V. Lunev
2026-10-05 20:36   ` Eric Blake [this message]
2026-09-30 16:49 ` [PATCH 11/13] block/blkdebug: make a breakpoint work across AioContexts Denis V. Lunev
2026-10-05 20:42   ` Eric Blake
2026-09-30 16:49 ` [PATCH 12/13] block: add blkdebug events for a write before it is tracked Denis V. Lunev
2026-10-05 20:45   ` Eric Blake
2026-09-30 16:49 ` [PATCH 13/13] iotests/298: cover the preallocation races Denis V. Lunev
2026-10-05 21:06   ` Eric Blake

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=asQJArdFNRiILy_o@redhat.com \
    --to=eblake@redhat.com \
    --cc=andrey.drobyshev@virtuozzo.com \
    --cc=den@openvz.org \
    --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.