qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC V4 12/30] qcow2: Load and save deduplication table


From: Eric Blake
Subject: Re: [Qemu-devel] [RFC V4 12/30] qcow2: Load and save deduplication table header extension.
Date: Fri, 04 Jan 2013 17:02:13 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0

On 01/02/2013 09:16 AM, Benoît Canet wrote:
> Signed-off-by: Benoit Canet <address@hidden>
> ---
>  block/qcow2.c |   38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
> 
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 410d3c1..9a7177b 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -53,9 +53,16 @@ typedef struct {
>      uint32_t len;
>  } QCowExtension;
>  
> +typedef struct {
> +    uint64_t offset;
> +    int32_t  size;
> +    uint8_t  hash_algo;
> +} QCowDedupTableExtension;

This struct has a hole at the end (that is, you only specify 13 bytes,
but sizeof(QCowDedupTableExtension) is 16)...

> +    if (s->has_dedup) {
> +        dedup_table_extension.offset = cpu_to_be64(s->dedup_table_offset);
> +        dedup_table_extension.size = cpu_to_be32(s->dedup_table_size);
> +        dedup_table_extension.hash_algo = s->dedup_hash_algo;
> +        ret = header_ext_add(buf,
> +                             QCOW2_EXT_MAGIC_DEDUP_TABLE,
> +                             &dedup_table_extension,
> +                             sizeof(dedup_table_extension),
> +                             buflen);

...but here you are writing out that hole.  It would be better if you
explicitly accounted for all bytes being written, so that the reserved
fields are guaranteed to be 0 instead of random data, so that future
extensions can make use of those reserved bytes.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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