qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Hanna Czenczek <hreitz@redhat.com>
To: "Denis V. Lunev" <den@virtuozzo.com>,
	Mike Maslenkin <mike.maslenkin@gmail.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, kwolf@redhat.com,
	den@openvz.org
Subject: Re: [PATCH v2 1/1] qemu-img: do not erase destination file in qemu-img dd command
Date: Tue, 31 Oct 2023 15:33:52 +0100	[thread overview]
Message-ID: <5f3a8585-18ed-4e05-ac6b-ac21178dfe79@redhat.com> (raw)
In-Reply-To: <d29be9a0-3765-10b1-24f1-6aa053e4213f@virtuozzo.com>

On 01.10.23 22:46, Denis V. Lunev wrote:
> Can you please not top-post. This makes the discussion complex. This
> approach is followed in this mailing list and in other similar lists
> like LKML.
>
> On 10/1/23 19:08, Mike Maslenkin wrote:
>> I thought about "conv=notrunc", but my main concern is changed virtual
>> disk metadata.
>> It depends on how qemu-img used.
>> May be I followed to wrong pattern, but pros and cons of adding "conv"
>> parameter was not in my mind in scope of the first patch version.
>> I see 4 obvious ways of using `qemu-img dd`:
>> 1. Copy virtual disk data between images of same format. I think disk
>> geometry must be preserved in this case.
>> 2. Copy virtual disk data between different formats. It is a valid
>> pattern? May be `qemu-img convert` should to be used instead?
>> 3. Merge snapshots to specified disk image, i.e read current state and
>> write it to new disk image.
>> 4. Copy virtual disk data to raw binary file. Actually this patch
>> breaks 'dd' behavior for this case when source image is less (in terms
>> of logical blocks) than existed raw binary file.
>>      May be for this case condition can be improved to smth like
>>     if (strcmp(fmt, "raw") || !g_file_test(out.filename,
>> G_FILE_TEST_EXISTS)) . And parameter "conv=notrunc" may be implemented
>> additionally for this case.
> My personal opinion is that qemu dd when you will need to
> extract the SOME data from the original image and process
> it further. Thus I use it to copy some data into raw binary
> file. My next goal here would add ability to put data into
> stdout that would be beneficial for. Though this is out of the
> equation at the moment.
>
> Though, speaking about the approach, I would say that the
> patch changes current behavior which is not totally buggy
> under a matter of this or that taste. It should be noted that
> we are here in Linux world, not in the Mac world where we
> were in position to avoid options and selections.
>
> Thus my opinion that original behavior is to be preserved
> as somebody is relying on it. The option you are proposing
> seems valuable to me also and thus the switch is to be added.
> The switch is well-defined in the original 'dd' world thus
> either conv= option would be good, either nocreat or notrunc.
> For me 'nocreat' seems more natural.
>
> Anyway, the last word here belongs to either Hanna or Kevin ;)

Personally, and honestly, I see no actual use for qemu-img dd at all, 
because we’re trying to mimic a subset of an interface of a rather 
complex program that has been designed to do what it does. We can only 
fail at that.  Personally, whenever I need dd functionality, I use 
qemu-storage-daemon’s fuse export, and then use the actual dd program on 
top.  Alternatively, qemu-img convert is our native interface; 
unfortunately, its feature set is lacking when compared to qemu-img dd, 
but I think it would be better to improve that rather than working on 
qemu-img dd.

I tend to agree with you, Denis, though, that this patch changes 
behavior, and users may be relying on the current behavior.

Comparing to “what would dd do” is difficult because dd just has no 
concept of file formats.  (That’s another reason why I think it’s bad to 
provide a dd-like interface, and users should rather use dd itself, or 
qemu-img convert.)  But in any case, adding conv=notrunc to keep the 
existing target file would seem fair to me.  I understand conv=nocreat 
would advise dd to never create the target file, which is something 
slightly different (i.e. conv=notrunc will still create a new target 
file if it doesn’t exist yet, but won’t create/truncate one if it 
already exists; while conv=nocreat would disable creating a new target 
file if it doesn’t exist yet, but still truncate it if it does exist; 
using both together would ensure that the target file is never 
created/truncated).

Summary: If we do this under a new conv=notrunc, fine with me.  I just 
don’t think qemu-img dd is something that should be used at all.

Hanna



  reply	other threads:[~2023-10-31 14:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-30 20:31 [PATCH v2 1/1] qemu-img: do not erase destination file in qemu-img dd command Mike Maslenkin
2023-10-01 12:25 ` Denis V. Lunev
2023-10-01 17:08   ` Mike Maslenkin
2023-10-01 20:46     ` Denis V. Lunev
2023-10-31 14:33       ` Hanna Czenczek [this message]
2023-11-01 16:26         ` Eric Blake
2023-11-01 16:51         ` Daniel P. Berrangé
2023-11-01 17:03           ` Denis V. Lunev
2023-11-01 17:22             ` Daniel P. Berrangé

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=5f3a8585-18ed-4e05-ac6b-ac21178dfe79@redhat.com \
    --to=hreitz@redhat.com \
    --cc=den@openvz.org \
    --cc=den@virtuozzo.com \
    --cc=kwolf@redhat.com \
    --cc=mike.maslenkin@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 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).