From: Stefan Hajnoczi <stefanha@gmail.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-devel@nongnu.org, stefanha@redhat.com, rjones@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 for-1.5 1/4] qcow2: Catch some L1 table index overflows
Date: Tue, 14 May 2013 16:49:24 +0200 [thread overview]
Message-ID: <20130514144924.GA29434@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <1368540876-30747-2-git-send-email-kwolf@redhat.com>
On Tue, May 14, 2013 at 04:14:33PM +0200, Kevin Wolf wrote:
> This catches the situation that is described in the bug report at
> https://bugs.launchpad.net/qemu/+bug/865518 and goes like this:
>
> $ qemu-img create -f qcow2 huge.qcow2 $((1024*1024))T
> Formatting 'huge.qcow2', fmt=qcow2 size=1152921504606846976 encryption=off cluster_size=65536 lazy_refcounts=off
> $ qemu-io /tmp/huge.qcow2 -c "write $((1024*1024*1024*1024*1024*1024 - 1024)) 512"
> Segmentation fault
>
> With this patch applied the segfault will be avoided, however the case
> will still fail, though gracefully:
>
> $ qemu-img create -f qcow2 /tmp/huge.qcow2 $((1024*1024))T
> Formatting 'huge.qcow2', fmt=qcow2 size=1152921504606846976 encryption=off cluster_size=65536 lazy_refcounts=off
> qemu-img: The image size is too large for file format 'qcow2'
>
> Note that even long before these overflow checks kick in, you get
> insanely high memory usage (up to INT_MAX * sizeof(uint64_t) = 16 GB for
> the L1 table), so with somewhat smaller image sizes you'll probably see
> qemu aborting for a failed g_malloc().
>
> If you need huge image sizes, you should increase the cluster size to
> the maximum of 2 MB in order to get higher limits.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> block/qcow2-cluster.c | 23 +++++++++++++++--------
> block/qcow2.c | 13 +++++++++++--
> block/qcow2.h | 5 +++--
> 3 files changed, 29 insertions(+), 12 deletions(-)
Thanks, applied to my block tree for 1.5:
https://github.com/stefanha/qemu/commits/block
Stefan
next prev parent reply other threads:[~2013-05-14 14:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-14 14:14 [Qemu-devel] [PATCH v2 for-1.5 0/4] qcow2: Catch some L1 table index overflows Kevin Wolf
2013-05-14 14:14 ` [Qemu-devel] [PATCH v2 for-1.5 1/4] " Kevin Wolf
2013-05-14 14:49 ` Stefan Hajnoczi [this message]
2013-05-14 14:14 ` [Qemu-devel] [PATCH v2 for-1.5 2/4] block: Add hint to -EFBIG error message Kevin Wolf
2013-05-14 14:49 ` Stefan Hajnoczi
2013-05-14 14:14 ` [Qemu-devel] [PATCH v2 3/4] qcow2.py: Subcommand for changing header fields Kevin Wolf
2013-05-14 14:14 ` [Qemu-devel] [PATCH v2 4/4] qemu-iotests: Try creating huge qcow2 image Kevin Wolf
2013-05-14 16:18 ` [Qemu-devel] [PATCH v2 for-1.5 0/4] qcow2: Catch some L1 table index overflows Richard W.M. Jones
2013-05-15 8:28 ` Stefan Hajnoczi
2013-05-16 9:26 ` Stefan Hajnoczi
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=20130514144924.GA29434@stefanha-thinkpad.redhat.com \
--to=stefanha@gmail.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rjones@redhat.com \
--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).