From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59085) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCbEa-00030k-RZ for qemu-devel@nongnu.org; Thu, 22 Aug 2013 16:12:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VCbEU-0004Cw-Oo for qemu-devel@nongnu.org; Thu, 22 Aug 2013 16:11:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23568) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCbEU-0004Cn-FO for qemu-devel@nongnu.org; Thu, 22 Aug 2013 16:11:50 -0400 From: Stefan Hajnoczi Date: Thu, 22 Aug 2013 22:10:58 +0200 Message-Id: <1377202298-22896-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1377202298-22896-1-git-send-email-stefanha@redhat.com> References: <1377202298-22896-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 02/42] block: Introduce bs->zero_beyond_eof List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Asias He , Stefan Hajnoczi , Anthony Liguori From: Asias He In 4146b46c42e0989cb5842e04d88ab6ccb1713a48 (block: Produce zeros when protocols reading beyond end of file), we break qemu-iotests ./check -qcow2 022. This happens because qcow2 temporarily sets ->growable = 1 for vmstate accesses (which are stored beyond the end of regular image data). We introduce the bs->zero_beyond_eof to allow qcow2_load_vmstate() to disable ->zero_beyond_eof temporarily in addition to enable ->growable. [Since the broken patch "block: Produce zeros when protocols reading beyond end of file" has not been merged yet, I have applied this fix *first* and will then apply the next patch to keep the tree bisectable. -- Stefan] Suggested-by: Stefan Hajnoczi Signed-off-by: Asias He Signed-off-by: Stefan Hajnoczi --- block.c | 2 ++ block/qcow2.c | 3 +++ include/block/block_int.h | 3 +++ 3 files changed, 8 insertions(+) diff --git a/block.c b/block.c index 45a545b..e655052 100644 --- a/block.c +++ b/block.c @@ -706,6 +706,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file, bs->open_flags = flags; bs->buffer_alignment = 512; + bs->zero_beyond_eof = true; open_flags = bdrv_open_flags(bs, flags); bs->read_only = !(open_flags & BDRV_O_RDWR); @@ -1402,6 +1403,7 @@ void bdrv_close(BlockDriverState *bs) bs->valid_key = 0; bs->sg = 0; bs->growable = 0; + bs->zero_beyond_eof = false; QDECREF(bs->options); bs->options = NULL; diff --git a/block/qcow2.c b/block/qcow2.c index 42ea7ec..78097e5 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1722,12 +1722,15 @@ static int qcow2_load_vmstate(BlockDriverState *bs, uint8_t *buf, { BDRVQcowState *s = bs->opaque; int growable = bs->growable; + bool zero_beyond_eof = bs->zero_beyond_eof; int ret; BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_LOAD); bs->growable = 1; + bs->zero_beyond_eof = false; ret = bdrv_pread(bs, qcow2_vm_state_offset(s) + pos, buf, size); bs->growable = growable; + bs->zero_beyond_eof = zero_beyond_eof; return ret; } diff --git a/include/block/block_int.h b/include/block/block_int.h index e45f2a0..74b0689 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -281,6 +281,9 @@ struct BlockDriverState { /* Whether the disk can expand beyond total_sectors */ int growable; + /* Whether produces zeros when read beyond eof */ + bool zero_beyond_eof; + /* the memory alignment required for the buffers handled by this driver */ int buffer_alignment; -- 1.8.3.1