Skip to content

Commit

Permalink
block: Create the commit block job before reopening any image
Browse files Browse the repository at this point in the history
If the base or overlay images need to be reopened in read-write mode
but the block_job_create() call fails then no one will put those
images back in read-only mode.

We can solve this problem easily by calling block_job_create() first.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Message-id: aa495045770a6f1a7cc5d408397a17c75097fdd8.1464346103.git.berto@igalia.com
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
  • Loading branch information
bertogg authored and XanClic committed Jun 16, 2016
1 parent 0824afd commit 834fe28
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions block/commit.c
Expand Up @@ -236,6 +236,11 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base,
return;
}

s = block_job_create(&commit_job_driver, bs, speed, cb, opaque, errp);
if (!s) {
return;
}

orig_base_flags = bdrv_get_flags(base);
orig_overlay_flags = bdrv_get_flags(overlay_bs);

Expand All @@ -252,16 +257,12 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base,
bdrv_reopen_multiple(reopen_queue, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
block_job_unref(&s->common);
return;
}
}


s = block_job_create(&commit_job_driver, bs, speed, cb, opaque, errp);
if (!s) {
return;
}

s->base = blk_new();
blk_insert_bs(s->base, base);

Expand Down

0 comments on commit 834fe28

Please sign in to comment.