[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 09/12] block: use bdrv_can_set_read_only() during
From: |
Jeff Cody |
Subject: |
[Qemu-devel] [PULL v2 09/12] block: use bdrv_can_set_read_only() during reopen |
Date: |
Mon, 24 Apr 2017 15:19:59 -0400 |
Signed-off-by: Jeff Cody <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: John Snow <address@hidden>
Message-id: address@hidden
---
block.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/block.c b/block.c
index 1ac05c1..5db266b 100644
--- a/block.c
+++ b/block.c
@@ -2789,6 +2789,7 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state,
BlockReopenQueue *queue,
BlockDriver *drv;
QemuOpts *opts;
const char *value;
+ bool read_only;
assert(reopen_state != NULL);
assert(reopen_state->bs->drv != NULL);
@@ -2817,12 +2818,13 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state,
BlockReopenQueue *queue,
qdict_put(reopen_state->options, "driver", qstring_from_str(value));
}
- /* if we are to stay read-only, do not allow permission change
- * to r/w */
- if (!(reopen_state->bs->open_flags & BDRV_O_ALLOW_RDWR) &&
- reopen_state->flags & BDRV_O_RDWR) {
- error_setg(errp, "Node '%s' is read only",
- bdrv_get_device_or_node_name(reopen_state->bs));
+ /* If we are to stay read-only, do not allow permission change
+ * to r/w. Attempting to set to r/w may fail if either BDRV_O_ALLOW_RDWR is
+ * not set, or if the BDS still has copy_on_read enabled */
+ read_only = !(reopen_state->flags & BDRV_O_RDWR);
+ ret = bdrv_can_set_read_only(reopen_state->bs, read_only, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
goto error;
}
--
2.9.3
- [Qemu-devel] [PULL v2 00/12] Block patches, Jeff Cody, 2017/04/24
- [Qemu-devel] [PULL v2 04/12] block: add bdrv_set_read_only() helper function, Jeff Cody, 2017/04/24
- [Qemu-devel] [PULL v2 03/12] qemu-iotests: exclude vxhs from image creation via protocol, Jeff Cody, 2017/04/24
- [Qemu-devel] [PULL v2 06/12] block: honor BDRV_O_ALLOW_RDWR when clearing bs->read_only, Jeff Cody, 2017/04/24
- [Qemu-devel] [PULL v2 05/12] block: do not set BDS read_only if copy_on_read enabled, Jeff Cody, 2017/04/24
- [Qemu-devel] [PULL v2 02/12] block/vxhs.c: Add qemu-iotests for new block device type "vxhs", Jeff Cody, 2017/04/24
- [Qemu-devel] [PULL v2 01/12] block/vxhs.c: Add support for a new block device type called "vxhs", Jeff Cody, 2017/04/24
- [Qemu-devel] [PULL v2 08/12] block: introduce bdrv_can_set_read_only(), Jeff Cody, 2017/04/24
- [Qemu-devel] [PULL v2 07/12] block: code movement, Jeff Cody, 2017/04/24
- [Qemu-devel] [PULL v2 09/12] block: use bdrv_can_set_read_only() during reopen,
Jeff Cody <=
- [Qemu-devel] [PULL v2 11/12] block/rbd: Add support for reopen(), Jeff Cody, 2017/04/24
- [Qemu-devel] [PULL v2 12/12] qemu-iotests: _cleanup_qemu must be called on exit, Jeff Cody, 2017/04/24
- [Qemu-devel] [PULL v2 10/12] block/rbd - update variable names to more apt names, Jeff Cody, 2017/04/24
- Re: [Qemu-devel] [PULL v2 00/12] Block patches, Peter Maydell, 2017/04/25