From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Alberto Garcia <berto@igalia.com>,
qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH 1/4] block: Improve "Block node is read-only" message
Date: Wed, 15 May 2019 22:15:00 +0200 [thread overview]
Message-ID: <20190515201503.19069-2-mreitz@redhat.com> (raw)
In-Reply-To: <20190515201503.19069-1-mreitz@redhat.com>
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>
---
block.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/block.c b/block.c
index 16ef5edfd8..af662d5f17 100644
--- a/block.c
+++ b/block.c
@@ -1689,6 +1689,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;
@@ -1775,7 +1777,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.21.0
next prev parent reply other threads:[~2019-05-15 20:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-15 20:14 [Qemu-devel] [PATCH 0/4] iotests: Make 245 faster and more reliable Max Reitz
2019-05-15 20:15 ` Max Reitz [this message]
2019-05-16 12:49 ` [Qemu-devel] [PATCH 1/4] block: Improve "Block node is read-only" message Alberto Garcia
2019-05-15 20:15 ` [Qemu-devel] [PATCH 2/4] iotests.py: Let assert_qmp() accept an array Max Reitz
2019-05-16 12:50 ` Alberto Garcia
2019-05-15 20:15 ` [Qemu-devel] [PATCH 3/4] iotests.py: Fix VM.run_job Max Reitz
2019-05-16 12:51 ` Alberto Garcia
2019-05-15 20:15 ` [Qemu-devel] [PATCH 4/4] iotests: Make 245 faster and more reliable Max Reitz
2019-05-16 14:27 ` Alberto Garcia
2019-05-20 14:18 ` [Qemu-devel] [PATCH 0/4] " Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190515201503.19069-2-mreitz@redhat.com \
--to=mreitz@redhat.com \
--cc=berto@igalia.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).