All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Hanna Czenczek <hreitz@redhat.com>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH 1/4] qcow2: Add keep_data_file command-line option
Date: Fri, 6 Mar 2026 15:29:17 +0100	[thread overview]
Message-ID: <aarkvZt4Ww4ekTTu@redhat.com> (raw)
In-Reply-To: <20250530084448.192369-2-hreitz@redhat.com>

Am 30.05.2025 um 10:44 hat Hanna Czenczek geschrieben:
> Add a command-line-only option to prevent overwriting the file specified
> as external data file.
> 
> This option is only available on the qemu-img create command line, not
> via blockdev-create, as it makes no sense there: That interface
> separates file creation and formatting, so where the external data file
> attached to a newly formatted qcow2 node comes from is completely up to
> the user.
> 
> Implementation detail: Enabling this option will not only not overwrite
> the external data file, but also assume it already exists, for two
> reasons:
> - It is simpler than checking whether the file exists, and only skipping
>   creating it when it does not.  It is therefore also less error-prone,
>   i.e. we can never accidentally overwrite an existing file because we
>   made some mistake in checking whether it exists.
> - I think it makes sense from a user's perspective: You set this option
>   when you want to use an existing data file, and you unset it when you
>   want a new one.  Getting an error when you expect to use an existing
>   data file seems to me a nice warning that something is not right.
> 
> Signed-off-by: Hanna Czenczek <hreitz@redhat.com>

> @@ -4004,6 +4029,40 @@ qcow2_co_create_opts(BlockDriver *drv, const char *filename, QemuOpts *opts,
>          goto finish;
>      }
>  
> +    qcow2_opts = &create_options->u.qcow2;
> +
> +    if (!qcow2_opts->has_preallocation) {
> +        qcow2_opts->preallocation = PREALLOC_MODE_OFF;
> +    }
> +    if (!qcow2_opts->has_data_file_raw) {
> +        qcow2_opts->data_file_raw = false;
> +    }

These checks are technically redundant, QAPI already gives us a zeroed
object. At least for the enum, it might still be nice not to rely on the
order. I don't think there's a reason for the bool one, though.

Kevin



  parent reply	other threads:[~2026-03-06 14:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-30  8:44 [PATCH 0/4] qcow2: Add keep_data_file command-line option Hanna Czenczek
2025-05-30  8:44 ` [PATCH 1/4] " Hanna Czenczek
2025-06-12 18:54   ` Eric Blake
2026-03-06 14:29   ` Kevin Wolf [this message]
2025-05-30  8:44 ` [PATCH 2/4] qcow2: Simplify size round-up in co_create_opts Hanna Czenczek
2025-06-12 18:56   ` Eric Blake
2025-05-30  8:44 ` [PATCH 3/4] iotests/common.filter: Sort keep_data_file Hanna Czenczek
2025-06-12 19:09   ` Eric Blake
2025-05-30  8:44 ` [PATCH 4/4] iotests/244: Add test cases for keep_data_file Hanna Czenczek
2025-06-12 19:13   ` Eric Blake
2026-03-06 16:09   ` Kevin Wolf
2025-11-19 15:22 ` [PATCH 0/4] qcow2: Add keep_data_file command-line option Hanna Czenczek
2026-03-06 16:49 ` 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=aarkvZt4Ww4ekTTu@redhat.com \
    --to=kwolf@redhat.com \
    --cc=hreitz@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 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.