mirror of
https://github.com/qemu/qemu.git
synced 2025-08-09 10:25:06 +00:00
block: Use bdrv_reopen_set_read_only() in commit_start/complete()
This patch replaces the bdrv_reopen() calls that set and remove the BDRV_O_RDWR flag with the new bdrv_reopen_set_read_only() function. Signed-off-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
e94d3dba6a
commit
e70cdc57da
@ -38,7 +38,7 @@ typedef struct CommitBlockJob {
|
|||||||
BlockBackend *base;
|
BlockBackend *base;
|
||||||
BlockDriverState *base_bs;
|
BlockDriverState *base_bs;
|
||||||
BlockdevOnError on_error;
|
BlockdevOnError on_error;
|
||||||
int base_flags;
|
bool base_read_only;
|
||||||
char *backing_file_str;
|
char *backing_file_str;
|
||||||
} CommitBlockJob;
|
} CommitBlockJob;
|
||||||
|
|
||||||
@ -124,8 +124,8 @@ static void commit_clean(Job *job)
|
|||||||
/* restore base open flags here if appropriate (e.g., change the base back
|
/* restore base open flags here if appropriate (e.g., change the base back
|
||||||
* to r/o). These reopens do not need to be atomic, since we won't abort
|
* to r/o). These reopens do not need to be atomic, since we won't abort
|
||||||
* even on failure here */
|
* even on failure here */
|
||||||
if (s->base_flags != bdrv_get_flags(s->base_bs)) {
|
if (s->base_read_only) {
|
||||||
bdrv_reopen(s->base_bs, s->base_flags, NULL);
|
bdrv_reopen_set_read_only(s->base_bs, true, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(s->backing_file_str);
|
g_free(s->backing_file_str);
|
||||||
@ -264,7 +264,6 @@ void commit_start(const char *job_id, BlockDriverState *bs,
|
|||||||
const char *filter_node_name, Error **errp)
|
const char *filter_node_name, Error **errp)
|
||||||
{
|
{
|
||||||
CommitBlockJob *s;
|
CommitBlockJob *s;
|
||||||
int orig_base_flags;
|
|
||||||
BlockDriverState *iter;
|
BlockDriverState *iter;
|
||||||
BlockDriverState *commit_top_bs = NULL;
|
BlockDriverState *commit_top_bs = NULL;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
@ -283,11 +282,9 @@ void commit_start(const char *job_id, BlockDriverState *bs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* convert base to r/w, if necessary */
|
/* convert base to r/w, if necessary */
|
||||||
orig_base_flags = bdrv_get_flags(base);
|
s->base_read_only = bdrv_is_read_only(base);
|
||||||
if (!(orig_base_flags & BDRV_O_RDWR)) {
|
if (s->base_read_only) {
|
||||||
bdrv_reopen(base, orig_base_flags | BDRV_O_RDWR, &local_err);
|
if (bdrv_reopen_set_read_only(base, false, errp) != 0) {
|
||||||
if (local_err != NULL) {
|
|
||||||
error_propagate(errp, local_err);
|
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -363,7 +360,6 @@ void commit_start(const char *job_id, BlockDriverState *bs,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->base_flags = orig_base_flags;
|
|
||||||
s->backing_file_str = g_strdup(backing_file_str);
|
s->backing_file_str = g_strdup(backing_file_str);
|
||||||
s->on_error = on_error;
|
s->on_error = on_error;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user