commit: reopen overlay_bs before base
commit3db2bd5508c86a1605258bc77c9672d93b5c350e
authorAlberto Garcia <berto@igalia.com>
Wed, 28 Oct 2015 13:43:49 +0000 (28 15:43 +0200)
committerKevin Wolf <kwolf@redhat.com>
Wed, 11 Nov 2015 15:25:47 +0000 (11 16:25 +0100)
tree430d334eb2a56fe4b7063933fa0d641fb94fbdf0
parent89e3a2d86d31212d09ca688193ccecb92c0c77b5
commit: reopen overlay_bs before base

'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: qemu-stable@nongnu.org
Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/commit.c