[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 22/40] commit: reopen overlay_bs before base
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL v2 22/40] commit: reopen overlay_bs before base |
Date: |
Tue, 10 Nov 2015 15:09:22 +0100 |
From: Alberto Garcia <address@hidden>
'block-commit' needs write access to two different nodes of the chain:
- 'base', because that's where the data is written to.
- the overlay of 'top', because it needs to update the backing file
string to point to 'base' after the operation.
Both images have to be opened in read-write mode, and commit_start()
takes care of reopening them if necessary.
With the current implementation, however, when overlay_bs is reopened
in read-write mode it has the side effect of making 'base' read-only
again, eventually making 'block-commit' fail.
This needs to be fixed in bdrv_reopen(), but until we get to that it
can be worked around simply by swapping the order of base and
overlay_bs in the reopen queue.
In order to reproduce this bug, overlay_bs needs to be initially in
read-only mode. That is: the 'top' parameter of 'block-commit' cannot
be the active layer nor its immediate backing chain.
Cc: address@hidden
Signed-off-by: Alberto Garcia <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/commit.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/block/commit.c b/block/commit.c
index fdebe87..a5d02aa 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -236,14 +236,14 @@ void commit_start(BlockDriverState *bs, BlockDriverState
*base,
orig_overlay_flags = bdrv_get_flags(overlay_bs);
/* convert base & overlay_bs to r/w, if necessary */
- if (!(orig_base_flags & BDRV_O_RDWR)) {
- reopen_queue = bdrv_reopen_queue(reopen_queue, base, NULL,
- orig_base_flags | BDRV_O_RDWR);
- }
if (!(orig_overlay_flags & BDRV_O_RDWR)) {
reopen_queue = bdrv_reopen_queue(reopen_queue, overlay_bs, NULL,
orig_overlay_flags | BDRV_O_RDWR);
}
+ if (!(orig_base_flags & BDRV_O_RDWR)) {
+ reopen_queue = bdrv_reopen_queue(reopen_queue, base, NULL,
+ orig_base_flags | BDRV_O_RDWR);
+ }
if (reopen_queue) {
bdrv_reopen_multiple(reopen_queue, &local_err);
if (local_err != NULL) {
--
1.8.3.1
- [Qemu-devel] [PULL v2 07/40] blockdev: Add blockdev-remove-medium, (continued)
- [Qemu-devel] [PULL v2 07/40] blockdev: Add blockdev-remove-medium, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 11/40] block: Inquire tray state before tray-moved events, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 12/40] qmp: Introduce blockdev-change-medium, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 10/40] blockdev: Implement change with basic operations, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 13/40] hmp: Use blockdev-change-medium for change command, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 15/40] hmp: Add read-only-mode option to change command, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 14/40] blockdev: read-only-mode for blockdev-change-medium, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 18/40] block: rename BlockdevSnapshot to BlockdevSnapshotSync, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 17/40] block: check for existing device IDs in external_snapshot_prepare(), Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 19/40] block: support passing 'backing': '' to 'blockdev-add', Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 22/40] commit: reopen overlay_bs before base,
Kevin Wolf <=
- [Qemu-devel] [PULL v2 21/40] block: add tests for the 'blockdev-snapshot' command, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 20/40] block: add a 'blockdev-snapshot' QMP command, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 26/40] throttle: Check for pending requests in throttle_group_unregister_bs(), Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 24/40] qcow2: avoid misaligned 64bit bswap, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 16/40] iotests: Add test for change-related QMP commands, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 23/40] qemu-iotests: Test the reopening of overlay_bs in 'block-commit', Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 28/40] block: Disallow snapshots if the overlay doesn't support backing files, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 29/40] block: Remove inner quotation marks in iotest 085, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 25/40] qemu-img: add check for zero-length job len, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 32/40] qemu-io: Check for trailing chars, Kevin Wolf, 2015/11/10