From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:33635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6MvG-0006fQ-RS for qemu-devel@nongnu.org; Tue, 28 Aug 2012 10:37:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T6MvC-0001N0-55 for qemu-devel@nongnu.org; Tue, 28 Aug 2012 10:37:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13989) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6MvB-0001Mn-SM for qemu-devel@nongnu.org; Tue, 28 Aug 2012 10:37:38 -0400 Message-ID: <503CD7AC.3020109@redhat.com> Date: Tue, 28 Aug 2012 16:37:32 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1346164009-30648-1-git-send-email-stefanha@linux.vnet.ibm.com> <1346164009-30648-2-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1346164009-30648-2-git-send-email-stefanha@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 for-1.2 1/2] stream: complete early if end of backing file is reached List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Anthony Liguori , qemu-devel@nongnu.org Il 28/08/2012 16:26, Stefan Hajnoczi ha scritto: > 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 > --- > 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; > + } Reviewed-by: Paolo Bonzini > copy = (ret == 1); > } > trace_stream_one_iteration(s, sector_num, n, ret); >