aboutsummaryrefslogtreecommitdiff
path: root/block/commit.c
diff options
context:
space:
mode:
authorAlberto Garcia <berto@igalia.com>2016-10-28 10:08:08 +0300
committerKevin Wolf <kwolf@redhat.com>2016-10-31 16:52:38 +0100
commit3e4c5122cbb881cd271314ef0782c4b6c57ab03d (patch)
tree588c2798ffef955a7cc80434cbf8db27f1eef177 /block/commit.c
parent058223a6e3b73cdf7f56b8d0a55032f99c5f11ac (diff)
downloadqemu-3e4c5122cbb881cd271314ef0782c4b6c57ab03d.zip
qemu-3e4c5122cbb881cd271314ef0782c4b6c57ab03d.tar.gz
qemu-3e4c5122cbb881cd271314ef0782c4b6c57ab03d.tar.bz2
block: Block all nodes involved in the block-commit operation
After a successful block-commit operation all nodes between top and base are removed from the backing chain, and top's overlay needs to be updated to point to base. Because of that we should prevent other block jobs from messing with them. This patch blocks all operations in these nodes in commit_start(). Signed-off-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/commit.c')
-rw-r--r--block/commit.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/block/commit.c b/block/commit.c
index 499ecca..a5e17f6 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -216,6 +216,7 @@ void commit_start(const char *job_id, BlockDriverState *bs,
BlockReopenQueue *reopen_queue = NULL;
int orig_overlay_flags;
int orig_base_flags;
+ BlockDriverState *iter;
BlockDriverState *overlay_bs;
Error *local_err = NULL;
@@ -260,6 +261,19 @@ void commit_start(const char *job_id, BlockDriverState *bs,
}
+ /* Block all nodes between top and base, because they will
+ * disappear from the chain after this operation. */
+ assert(bdrv_chain_contains(top, base));
+ for (iter = top; iter != backing_bs(base); iter = backing_bs(iter)) {
+ block_job_add_bdrv(&s->common, iter);
+ }
+ /* overlay_bs must be blocked because it needs to be modified to
+ * update the backing image string, but if it's the root node then
+ * don't block it again */
+ if (bs != overlay_bs) {
+ block_job_add_bdrv(&s->common, overlay_bs);
+ }
+
s->base = blk_new();
blk_insert_bs(s->base, base);