From: Kevin Wolf <kwolf@redhat.com>
To: Fam Zheng <famz@redhat.com>
Cc: qemu-devel@nongnu.org, stefanha@redhat.com, qemu-stable@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-stable] [PATCH] qcow2: Zero-initialise first cluster for new images
Date: Wed, 27 Nov 2013 13:44:23 +0100 [thread overview]
Message-ID: <20131127124423.GC2884@dhcp-200-207.str.redhat.com> (raw)
In-Reply-To: <52949198.8080907@redhat.com>
Am 26.11.2013 um 13:18 hat Fam Zheng geschrieben:
> On 2013年11月26日 18:48, Kevin Wolf wrote:
> >Strictly speaking, this is only required for has_zero_init() == false,
> >but it's easy enough to just do a cluster-aligned write that is padded
> >with zeros after the header.
> >
> >This fixes that after 'qemu-img create' header extensions are attempted
> >to be parsed that are really just random leftover data.
> >
> >Cc: qemu-stable@nongnu.org
> >Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> >---
> > block/qcow2.c | 37 +++++++++++++++++++++----------------
> > 1 file changed, 21 insertions(+), 16 deletions(-)
> >
> >diff --git a/block/qcow2.c b/block/qcow2.c
> >index 6e5d98d..7c18587 100644
> >--- a/block/qcow2.c
> >+++ b/block/qcow2.c
> >@@ -1471,7 +1471,7 @@ static int qcow2_create2(const char *filename, int64_t total_size,
> > * size for any qcow2 image.
> > */
> > BlockDriverState* bs;
> >- QCowHeader header;
> >+ QCowHeader *header;
> > uint8_t* refcount_table;
> > Error *local_err = NULL;
> > int ret;
> >@@ -1489,30 +1489,35 @@ static int qcow2_create2(const char *filename, int64_t total_size,
> > }
> >
> > /* Write the header */
> >- memset(&header, 0, sizeof(header));
> >- header.magic = cpu_to_be32(QCOW_MAGIC);
> >- header.version = cpu_to_be32(version);
> >- header.cluster_bits = cpu_to_be32(cluster_bits);
> >- header.size = cpu_to_be64(0);
> >- header.l1_table_offset = cpu_to_be64(0);
> >- header.l1_size = cpu_to_be32(0);
> >- header.refcount_table_offset = cpu_to_be64(cluster_size);
> >- header.refcount_table_clusters = cpu_to_be32(1);
> >- header.refcount_order = cpu_to_be32(3 + REFCOUNT_SHIFT);
> >- header.header_length = cpu_to_be32(sizeof(header));
> >+ QEMU_BUILD_BUG_ON((1 << MIN_CLUSTER_BITS) < sizeof(*header));
> >+ header = g_malloc(cluster_size);
> >+ memset(header, 0, cluster_size);
>
> Could just be:
>
> header = g_malloc0(cluster_size);
>
> But either way,
Yes, that's better. I'll change it.
> Reviewed-by: Fam Zheng <famz@redhat.com>
Thanks.
Kevin
next prev parent reply other threads:[~2013-11-27 12:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-26 10:48 [Qemu-devel] [PATCH] qcow2: Zero-initialise first cluster for new images Kevin Wolf
2013-11-26 12:18 ` [Qemu-devel] [Qemu-stable] " Fam Zheng
2013-11-27 12:44 ` Kevin Wolf [this message]
2013-11-27 11:18 ` [Qemu-devel] " Paolo Bonzini
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=20131127124423.GC2884@dhcp-200-207.str.redhat.com \
--to=kwolf@redhat.com \
--cc=famz@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=stefanha@redhat.com \
/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).