aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2019-05-15 22:15:00 +0200
committerKevin Wolf <kwolf@redhat.com>2019-05-20 17:08:57 +0200
commit481e0eeef4fdf7e2ed42425e38d0a30ffd0e9b54 (patch)
treecb0b13e8cd6bcce96cf16f9df251999c7836c908 /block.c
parent4db4390ef31648be28626dff51e87e3647485a46 (diff)
downloadqemu-481e0eeef4fdf7e2ed42425e38d0a30ffd0e9b54.zip
qemu-481e0eeef4fdf7e2ed42425e38d0a30ffd0e9b54.tar.gz
qemu-481e0eeef4fdf7e2ed42425e38d0a30ffd0e9b54.tar.bz2
block: Improve "Block node is read-only" message
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 <mreitz@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/block.c b/block.c
index 1e5230f..cb11537 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, &current_perms, &current_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;
}