qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: qcow2: Zero-initialization of external data files


From: Eric Blake
Subject: Re: qcow2: Zero-initialization of external data files
Date: Thu, 9 Apr 2020 08:42:55 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0

On 4/9/20 8:05 AM, Max Reitz wrote:

$ sudo ./qemu-img create -f qcow2 -o \
      data_file=/dev/loop0,data_file_raw=on foo.qcow2 64M
[...]

$ sudo ./qemu-io -c 'read -P 0 0 64M' foo.qcow2
read 67108864/67108864 bytes at offset 0
64 MiB, 1 ops; 00.00 sec (25.036 GiB/sec and 400.5751 ops/sec)

This looks like a bug (and we should fix it for 5.0 if possible)

It seems a bit difficult for 5.0 now.  (But I don’t think it’d be a
regression, so that shouldn’t be too bad.)

So, you're arguing that since 4.2 has the same bug, slipping the fix to 5.1 instead of 5.0 is not bad because it's not a regression new to 5.0. Yes, that's a reasonable answer, if a fix is not fast.


I suppose this behavior is fine for blockdev-create because I guess it’s
the user’s responsibility to ensure that the external data file is zero.
   But maybe it isn’t, so that’s my first question: Is it really the
user’s responsibility or should we always ensure it’s zero?

I'd argue that requiring the user to pre-zero the raw data file is
undesirable; and that we should instead fix our code to not report the
image as reading all zeroes when creating with data_file_raw=on.

OK.  I think that could be achieved by just enforcing @preallocation to
be at least “metadata” whenever @data-file-raw is set.  Would that make
sense?

Is a preallocation of metadata sufficient to report things correctly? If so, it seems like a reasonable compromise to me. I was more envisioning a fix elsewhere: if we are reporting block status of what looks like an unallocated cluster, but data-file-raw is set, we change our answer to instead report it as allocated with unknown contents. But with preallocation, you either force the qcow2 file to list no cluster as unallocated (which matches the fact that the raw image really is fully allocated) while not touching the raw image, or you can go one step further and request full preallocation to wipe the raw image to 0 in the process.


Max

My second question is: If we decide that this is fine for
blockdev-create, should at least qcow2_co_create_opts() ensure the data
file it just created is zero?

Having an option to make qemu force-zero the raw image during
qcow2_co_create_opts seems reasonable, but for performance reasons, I
don't think the flag should be on by default.

And by mentioning preallocation, you've managed to convince me that we may already have exactly the option I was envisioning.

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]