提交 834fe28d 编写于 作者: A Alberto Garcia 提交者: Max Reitz

block: Create the commit block job before reopening any image

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: NAlberto Garcia <berto@igalia.com>
Message-id: aa495045770a6f1a7cc5d408397a17c75097fdd8.1464346103.git.berto@igalia.com
Reviewed-by: NMax Reitz <mreitz@redhat.com>
Signed-off-by: NMax Reitz <mreitz@redhat.com>
上级 0824afda
...@@ -236,6 +236,11 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base, ...@@ -236,6 +236,11 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base,
return; return;
} }
s = block_job_create(&commit_job_driver, bs, speed, cb, opaque, errp);
if (!s) {
return;
}
orig_base_flags = bdrv_get_flags(base); orig_base_flags = bdrv_get_flags(base);
orig_overlay_flags = bdrv_get_flags(overlay_bs); orig_overlay_flags = bdrv_get_flags(overlay_bs);
...@@ -252,16 +257,12 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base, ...@@ -252,16 +257,12 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base,
bdrv_reopen_multiple(reopen_queue, &local_err); bdrv_reopen_multiple(reopen_queue, &local_err);
if (local_err != NULL) { if (local_err != NULL) {
error_propagate(errp, local_err); error_propagate(errp, local_err);
block_job_unref(&s->common);
return; return;
} }
} }
s = block_job_create(&commit_job_driver, bs, speed, cb, opaque, errp);
if (!s) {
return;
}
s->base = blk_new(); s->base = blk_new();
blk_insert_bs(s->base, base); blk_insert_bs(s->base, base);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册