|
|
9ae3a8 |
From 49b4262336e2875280d7d539851b5b318a86bc39 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Asias He <asias@redhat.com>
|
|
|
9ae3a8 |
Date: Thu, 12 Sep 2013 07:39:33 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 13/29] block: Introduce bs->zero_beyond_eof
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Asias He <asias@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1378971575-22416-3-git-send-email-asias@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 54326
|
|
|
9ae3a8 |
O-Subject: [RHEL7.0 qemu-kvm PATCH 2/4] block: Introduce bs->zero_beyond_eof
|
|
|
9ae3a8 |
Bugzilla: 1007226
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1007226
|
|
|
9ae3a8 |
Brew: https://brewweb.devel.redhat.com/taskinfo?taskID=6275752
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
In 4146b46c42e0989cb5842e04d88ab6ccb1713a48 (block: Produce zeros when
|
|
|
9ae3a8 |
protocols reading beyond end of file), we break qemu-iotests ./check
|
|
|
9ae3a8 |
-qcow2 022. This happens because qcow2 temporarily sets ->growable = 1
|
|
|
9ae3a8 |
for vmstate accesses (which are stored beyond the end of regular image
|
|
|
9ae3a8 |
data).
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
We introduce the bs->zero_beyond_eof to allow qcow2_load_vmstate() to
|
|
|
9ae3a8 |
disable ->zero_beyond_eof temporarily in addition to enable ->growable.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
[Since the broken patch "block: Produce zeros when protocols reading
|
|
|
9ae3a8 |
beyond end of file" has not been merged yet, I have applied this fix
|
|
|
9ae3a8 |
*first* and will then apply the next patch to keep the tree bisectable.
|
|
|
9ae3a8 |
-- Stefan]
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Suggested-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Asias He <asias@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 0d51b4debee6fb322751a57097a1d675c7a7c38d)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block.c | 2 ++
|
|
|
9ae3a8 |
block/qcow2.c | 3 +++
|
|
|
9ae3a8 |
include/block/block_int.h | 3 +++
|
|
|
9ae3a8 |
3 files changed, 8 insertions(+)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block.c | 2 ++
|
|
|
9ae3a8 |
block/qcow2.c | 3 +++
|
|
|
9ae3a8 |
include/block/block_int.h | 3 +++
|
|
|
9ae3a8 |
3 files changed, 8 insertions(+), 0 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block.c b/block.c
|
|
|
9ae3a8 |
index f4a89b9..dbcad0e 100644
|
|
|
9ae3a8 |
--- a/block.c
|
|
|
9ae3a8 |
+++ b/block.c
|
|
|
9ae3a8 |
@@ -708,6 +708,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
bs->open_flags = flags;
|
|
|
9ae3a8 |
bs->buffer_alignment = 512;
|
|
|
9ae3a8 |
+ bs->zero_beyond_eof = true;
|
|
|
9ae3a8 |
open_flags = bdrv_open_flags(bs, flags);
|
|
|
9ae3a8 |
bs->read_only = !(open_flags & BDRV_O_RDWR);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -1407,6 +1408,7 @@ void bdrv_close(BlockDriverState *bs)
|
|
|
9ae3a8 |
bs->valid_key = 0;
|
|
|
9ae3a8 |
bs->sg = 0;
|
|
|
9ae3a8 |
bs->growable = 0;
|
|
|
9ae3a8 |
+ bs->zero_beyond_eof = false;
|
|
|
9ae3a8 |
QDECREF(bs->options);
|
|
|
9ae3a8 |
bs->options = NULL;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/qcow2.c b/block/qcow2.c
|
|
|
9ae3a8 |
index abdc202..70da5bd 100644
|
|
|
9ae3a8 |
--- a/block/qcow2.c
|
|
|
9ae3a8 |
+++ b/block/qcow2.c
|
|
|
9ae3a8 |
@@ -1722,12 +1722,15 @@ static int qcow2_load_vmstate(BlockDriverState *bs, uint8_t *buf,
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
BDRVQcowState *s = bs->opaque;
|
|
|
9ae3a8 |
int growable = bs->growable;
|
|
|
9ae3a8 |
+ bool zero_beyond_eof = bs->zero_beyond_eof;
|
|
|
9ae3a8 |
int ret;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_LOAD);
|
|
|
9ae3a8 |
bs->growable = 1;
|
|
|
9ae3a8 |
+ bs->zero_beyond_eof = false;
|
|
|
9ae3a8 |
ret = bdrv_pread(bs, qcow2_vm_state_offset(s) + pos, buf, size);
|
|
|
9ae3a8 |
bs->growable = growable;
|
|
|
9ae3a8 |
+ bs->zero_beyond_eof = zero_beyond_eof;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
diff --git a/include/block/block_int.h b/include/block/block_int.h
|
|
|
9ae3a8 |
index 6078dd3..267be48 100644
|
|
|
9ae3a8 |
--- a/include/block/block_int.h
|
|
|
9ae3a8 |
+++ b/include/block/block_int.h
|
|
|
9ae3a8 |
@@ -268,6 +268,9 @@ struct BlockDriverState {
|
|
|
9ae3a8 |
/* Whether the disk can expand beyond total_sectors */
|
|
|
9ae3a8 |
int growable;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ /* Whether produces zeros when read beyond eof */
|
|
|
9ae3a8 |
+ bool zero_beyond_eof;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
/* the memory alignment required for the buffers handled by this driver */
|
|
|
9ae3a8 |
int buffer_alignment;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|