[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 06/14] block: Use bdrv_reopen_set_read_only() in str
From: |
Alberto Garcia |
Subject: |
[Qemu-block] [PATCH 06/14] block: Use bdrv_reopen_set_read_only() in stream_start/complete() |
Date: |
Wed, 19 Sep 2018 17:47:44 +0300 |
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 <address@hidden>
---
block/stream.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/block/stream.c b/block/stream.c
index 9264b68a1e..07201f3df5 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -34,7 +34,7 @@ typedef struct StreamBlockJob {
BlockDriverState *base;
BlockdevOnError on_error;
char *backing_file_str;
- int bs_flags;
+ bool bs_read_only;
} StreamBlockJob;
static int coroutine_fn stream_populate(BlockBackend *blk,
@@ -86,10 +86,10 @@ static void stream_complete(Job *job, void *opaque)
out:
/* Reopen the image back in read-only mode if necessary */
- if (s->bs_flags != bdrv_get_flags(bs)) {
+ if (s->bs_read_only) {
/* Give up write permissions before making it read-only */
blk_set_perm(bjob->blk, 0, BLK_PERM_ALL, &error_abort);
- bdrv_reopen(bs, s->bs_flags, NULL);
+ bdrv_reopen_set_read_only(bs, true, NULL);
}
g_free(s->backing_file_str);
@@ -225,12 +225,12 @@ void stream_start(const char *job_id, BlockDriverState
*bs,
{
StreamBlockJob *s;
BlockDriverState *iter;
- int orig_bs_flags;
+ int bs_read_only;
/* Make sure that the image is opened in read-write mode */
- orig_bs_flags = bdrv_get_flags(bs);
- if (!(orig_bs_flags & BDRV_O_RDWR)) {
- if (bdrv_reopen(bs, orig_bs_flags | BDRV_O_RDWR, errp) != 0) {
+ bs_read_only = bdrv_is_read_only(bs);
+ if (bs_read_only) {
+ if (bdrv_reopen_set_read_only(bs, false, errp) != 0) {
return;
}
}
@@ -260,7 +260,7 @@ void stream_start(const char *job_id, BlockDriverState *bs,
s->base = base;
s->backing_file_str = g_strdup(backing_file_str);
- s->bs_flags = orig_bs_flags;
+ s->bs_read_only = bs_read_only;
s->on_error = on_error;
trace_stream_start(bs, base, s);
@@ -268,7 +268,7 @@ void stream_start(const char *job_id, BlockDriverState *bs,
return;
fail:
- if (orig_bs_flags != bdrv_get_flags(bs)) {
- bdrv_reopen(bs, orig_bs_flags, NULL);
+ if (bs_read_only) {
+ bdrv_reopen_set_read_only(bs, true, NULL);
}
}
--
2.11.0
- [Qemu-block] [PATCH 00/14] Don't pass flags to bdrv_reopen_queue(), Alberto Garcia, 2018/09/19
- [Qemu-block] [PATCH 08/14] block: Use bdrv_reopen_set_read_only() in external_snapshot_commit(), Alberto Garcia, 2018/09/19
- [Qemu-block] [PATCH 03/14] block: Use bdrv_reopen_set_read_only() in bdrv_backing_update_filename(), Alberto Garcia, 2018/09/19
- [Qemu-block] [PATCH 05/14] block: Use bdrv_reopen_set_read_only() in bdrv_commit(), Alberto Garcia, 2018/09/19
- [Qemu-block] [PATCH 07/14] block: Use bdrv_reopen_set_read_only() in qmp_change_backing_file(), Alberto Garcia, 2018/09/19
- [Qemu-block] [PATCH 02/14] block: Add bdrv_reopen_set_read_only(), Alberto Garcia, 2018/09/19
- [Qemu-block] [PATCH 04/14] block: Use bdrv_reopen_set_read_only() in commit_start/complete(), Alberto Garcia, 2018/09/19
- [Qemu-block] [PATCH 09/14] block: Use bdrv_reopen_set_read_only() in the mirror driver, Alberto Garcia, 2018/09/19
- [Qemu-block] [PATCH 06/14] block: Use bdrv_reopen_set_read_only() in stream_start/complete(),
Alberto Garcia <=
- [Qemu-block] [PATCH 01/14] block: Don't call update_flags_from_options() if the options are wrong, Alberto Garcia, 2018/09/19
- [Qemu-block] [PATCH 11/14] qemu-io: Put flag changes in the options QDict in reopen_f(), Alberto Garcia, 2018/09/19
- [Qemu-block] [PATCH 10/14] block: Drop bdrv_reopen(), Alberto Garcia, 2018/09/19
- [Qemu-block] [PATCH 12/14] block: Clean up reopen_backing_file() in block/replication.c, Alberto Garcia, 2018/09/19
- [Qemu-block] [PATCH 14/14] block: Stop passing flags to bdrv_reopen_queue_child(), Alberto Garcia, 2018/09/19
- [Qemu-block] [PATCH 13/14] block: Remove flags parameter from bdrv_reopen_queue(), Alberto Garcia, 2018/09/19