From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Anthony Liguori <aliguori@us.ibm.com>,
Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH v2 for-1.2 1/2] stream: complete early if end of backing file is reached
Date: Tue, 28 Aug 2012 15:26:48 +0100 [thread overview]
Message-ID: <1346164009-30648-2-git-send-email-stefanha@linux.vnet.ibm.com> (raw)
In-Reply-To: <1346164009-30648-1-git-send-email-stefanha@linux.vnet.ibm.com>
It is possible to create an image that is larger than its backing file.
Reading beyond the end of the backing file produces zeroes if no writes
have been made to those sectors in the image file.
This patch finishes streaming early when the end of the backing file is
reached. Without this patch the block job hangs and continually tries
to stream the first sectors beyond the end of the backing file.
To reproduce the hung block job bug:
$ qemu-img create -f qcow2 backing.qcow2 128M
$ qemu-img create -f qcow2 -o backing_file=backing.qcow2 image.qcow2 6G
$ qemu -drive if=virtio,cache=none,file=image.qcow2
(qemu) block_stream virtio0
(qemu) info block-jobs
The qemu-iotests 030 streaming test still passes.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
block/stream.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/block/stream.c b/block/stream.c
index 37c4652..c4f87dd 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -122,6 +122,12 @@ wait:
* known-unallocated area [sector_num, sector_num+n). */
ret = bdrv_co_is_allocated_above(bs->backing_hd, base,
sector_num, n, &n);
+
+ /* Finish early if end of backing file has been reached */
+ if (ret == 0 && n == 0) {
+ n = end - sector_num;
+ }
+
copy = (ret == 1);
}
trace_stream_one_iteration(s, sector_num, n, ret);
--
1.7.10.4
next prev parent reply other threads:[~2012-08-28 14:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-28 14:26 [Qemu-devel] [PATCH v2 for-1.2 0/2] stream: complete early if end of backing file is reached Stefan Hajnoczi
2012-08-28 14:26 ` Stefan Hajnoczi [this message]
2012-08-28 14:37 ` [Qemu-devel] [PATCH v2 for-1.2 1/2] " Paolo Bonzini
2012-08-28 14:26 ` [Qemu-devel] [PATCH v2 for-1.2 2/2] qemu-iotests: add backing file smaller than image test case Stefan Hajnoczi
2012-08-28 14:38 ` Paolo Bonzini
2012-08-28 19:08 ` [Qemu-devel] [PATCH v2 for-1.2 0/2] stream: complete early if end of backing file is reached Kevin Wolf
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=1346164009-30648-2-git-send-email-stefanha@linux.vnet.ibm.com \
--to=stefanha@linux.vnet.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--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).