[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 21/24] block: Improve "Block node is read-only" messa
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 21/24] block: Improve "Block node is read-only" message |
Date: |
Mon, 20 May 2019 18:14:50 +0200 |
From: Max Reitz <address@hidden>
This message does not make any sense when it appears as the response to
making an R/W node read-only. We should detect that case and emit a
different message, then.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Alberto Garcia <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/block.c b/block.c
index 1e5230f98e..cb11537029 100644
--- a/block.c
+++ b/block.c
@@ -1709,6 +1709,8 @@ static int bdrv_child_check_perm(BdrvChild *c,
BlockReopenQueue *q,
GSList *ignore_children, Error **errp);
static void bdrv_child_abort_perm_update(BdrvChild *c);
static void bdrv_child_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared);
+static void bdrv_get_cumulative_perm(BlockDriverState *bs, uint64_t *perm,
+ uint64_t *shared_perm);
typedef struct BlockReopenQueueEntry {
bool prepared;
@@ -1795,7 +1797,20 @@ static int bdrv_check_perm(BlockDriverState *bs,
BlockReopenQueue *q,
if ((cumulative_perms & (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED)) &&
!bdrv_is_writable_after_reopen(bs, q))
{
- error_setg(errp, "Block node is read-only");
+ if (!bdrv_is_writable_after_reopen(bs, NULL)) {
+ error_setg(errp, "Block node is read-only");
+ } else {
+ uint64_t current_perms, current_shared;
+ bdrv_get_cumulative_perm(bs, ¤t_perms, ¤t_shared);
+ if (current_perms & (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED)) {
+ error_setg(errp, "Cannot make block node read-only, there is "
+ "a writer on it");
+ } else {
+ error_setg(errp, "Cannot make block node read-only and create "
+ "a writer on it");
+ }
+ }
+
return -EPERM;
}
--
2.20.1
- [Qemu-devel] [PULL 12/24] block: Implement .(can_)set_aio_ctx for BlockBackend, (continued)
- [Qemu-devel] [PULL 12/24] block: Implement .(can_)set_aio_ctx for BlockBackend, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 11/24] test-block-iothread: Test AioContext propagation through the tree, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 13/24] block: Add blk_set_allow_aio_context_change(), Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 02/24] qcow2: Define and use QCOW2_COMPRESSED_SECTOR_SIZE, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 10/24] block: Propagate AioContext change to parents, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 08/24] block: Make bdrv_attach/detach_aio_context() static, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 16/24] test-block-iothread: Test AioContext propagation for block jobs, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 15/24] blockjob: Remove AioContext notifiers, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 14/24] blockjob: Propagate AioContext change to all job nodes, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 17/24] block/file-posix: Unaligned O_DIRECT block-status, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 21/24] block: Improve "Block node is read-only" message,
Kevin Wolf <=
- [Qemu-devel] [PULL 20/24] qemu-img.texi: Describe human-readable info output, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 23/24] iotests.py: Fix VM.run_job, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 22/24] iotests.py: Let assert_qmp() accept an array, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 19/24] qemu-img.texi: Be specific about JSON object types, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 18/24] iotests: Test unaligned raw images with O_DIRECT, Kevin Wolf, 2019/05/20
- [Qemu-devel] [PULL 24/24] iotests: Make 245 faster and more reliable, Kevin Wolf, 2019/05/20
- Re: [Qemu-devel] [PULL 00/24] Block layer patches, Peter Maydell, 2019/05/20