[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 17/24] qcow2: Don't write with BDRV_O_INCOMING
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 17/24] qcow2: Don't write with BDRV_O_INCOMING |
Date: |
Wed, 12 Mar 2014 11:29:25 +0100 |
From: Kevin Wolf <address@hidden>
qcow2_open() causes writes when repairing an image with the dirty flag
set and when clearing autoclear flags. It shouldn't do this when another
qemu instance is still actively working on this image file.
One effect of the bug is that images may have a cleared dirty flag while
the migration source host still has it in use with lazy refcounts
enabled, so refcounts are not accurate and the dirty flag must remain
set.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block/qcow2.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index ec23cc4..945c9d6 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -644,7 +644,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options,
int flags,
}
/* Clear unknown autoclear feature bits */
- if (!bs->read_only && s->autoclear_features != 0) {
+ if (!bs->read_only && !(flags & BDRV_O_INCOMING) && s->autoclear_features)
{
s->autoclear_features = 0;
ret = qcow2_update_header(bs);
if (ret < 0) {
@@ -657,7 +657,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options,
int flags,
qemu_co_mutex_init(&s->lock);
/* Repair image if dirty */
- if (!(flags & BDRV_O_CHECK) && !bs->read_only &&
+ if (!(flags & (BDRV_O_CHECK | BDRV_O_INCOMING)) && !bs->read_only &&
(s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) {
BdrvCheckResult result = {0};
@@ -1137,10 +1137,12 @@ static void qcow2_close(BlockDriverState *bs)
/* else pre-write overlap checks in cache_destroy may crash */
s->l1_table = NULL;
- qcow2_cache_flush(bs, s->l2_table_cache);
- qcow2_cache_flush(bs, s->refcount_block_cache);
+ if (!(bs->open_flags & BDRV_O_INCOMING)) {
+ qcow2_cache_flush(bs, s->l2_table_cache);
+ qcow2_cache_flush(bs, s->refcount_block_cache);
- qcow2_mark_clean(bs);
+ qcow2_mark_clean(bs);
+ }
qcow2_cache_destroy(bs, s->l2_table_cache);
qcow2_cache_destroy(bs, s->refcount_block_cache);
--
1.8.5.3
- [Qemu-devel] [PULL 01/24] qcow2-refcount: Sanitize refcount table entry, (continued)
- [Qemu-devel] [PULL 01/24] qcow2-refcount: Sanitize refcount table entry, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 02/24] block: Update image size in bdrv_invalidate_cache(), Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 04/24] block: bs->drv may be NULL in bdrv_debug_resume(), Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 06/24] block: Rewrite the snapshot authorization mechanism for block filters., Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 07/24] object: add object_get_canonical_path_component(), Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 08/24] rfifolock: add recursive FIFO lock, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 10/24] iothread: add I/O thread object, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 09/24] aio: add aio_context_acquire() and aio_context_release(), Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 12/24] iothread: add "iothread" qdev property type, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 13/24] dataplane: replace internal thread with IOThread, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 17/24] qcow2: Don't write with BDRV_O_INCOMING,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 14/24] iothread: stash thread ID away, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 03/24] qcow2: Check bs->drv in copy_sectors(), Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 05/24] iotests: Test corruption during COW request, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 11/24] qdev: make get_pointer() handle temporary strings, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 15/24] qmp: add query-iothreads command, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 21/24] block/raw-posix: bdrv_parse_filename() for floppy, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 19/24] qemu-io: Fix warnings from static code analysis, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 24/24] block/raw-win32: bdrv_parse_filename() for hdev, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 16/24] qcow2: Keep option in qcow2_invalidate_cache(), Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 18/24] block: Unlink temporary file, Stefan Hajnoczi, 2014/03/12