From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, jsnow@redhat.com, mreitz@redhat.com,
kwolf@redhat.com, philmd@redhat.com, peter.maydell@linaro.org,
berto@igalia.com, stefanha@redhat.com, pbonzini@redhat.com,
vsementsov@virtuozzo.com, den@openvz.org, eblake@redhat.com
Subject: [PATCH 1/5] abort-on-set-to-true
Date: Fri, 20 Nov 2020 19:16:18 +0300 [thread overview]
Message-ID: <20201120161622.1537-2-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20201120161622.1537-1-vsementsov@virtuozzo.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
block.c | 34 +++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)
diff --git a/block.c b/block.c
index f1cedac362..5e8dd98cec 100644
--- a/block.c
+++ b/block.c
@@ -84,6 +84,8 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
/* If non-zero, use only whitelisted block drivers */
static int use_bdrv_whitelist;
+bool abort_on_set_to_true = false;
+
#ifdef _WIN32
static int is_windows_drive_prefix(const char *filename)
{
@@ -2002,6 +2004,9 @@ static int bdrv_check_perm(BlockDriverState *bs, BlockReopenQueue *q,
added_perms = cumulative_perms & ~current_perms;
removed_shared_perms = current_shared & ~cumulative_shared_perms;
+ if ((added_perms || removed_shared_perms) && tighten_restrictions == &abort_on_set_to_true) {
+ abort();
+ }
*tighten_restrictions = added_perms || removed_shared_perms;
}
@@ -2066,12 +2071,17 @@ static int bdrv_check_perm(BlockDriverState *bs, BlockReopenQueue *q,
bdrv_child_perm(bs, c->bs, c, c->role, q,
cumulative_perms, cumulative_shared_perms,
&cur_perm, &cur_shared);
- ret = bdrv_child_check_perm(c, q, cur_perm, cur_shared, ignore_children,
- tighten_restrictions ? &child_tighten_restr
- : NULL,
- errp);
- if (tighten_restrictions) {
- *tighten_restrictions |= child_tighten_restr;
+ if (tighten_restrictions == &abort_on_set_to_true) {
+ ret = bdrv_child_check_perm(c, q, cur_perm, cur_shared, ignore_children,
+ &abort_on_set_to_true, errp);
+ } else {
+ ret = bdrv_child_check_perm(c, q, cur_perm, cur_shared, ignore_children,
+ tighten_restrictions ? &child_tighten_restr
+ : NULL,
+ errp);
+ if (tighten_restrictions) {
+ *tighten_restrictions |= child_tighten_restr;
+ }
}
if (ret < 0) {
return ret;
@@ -2227,6 +2237,9 @@ static int bdrv_check_update_perm(BlockDriverState *bs, BlockReopenQueue *q,
char *perm_names = bdrv_perm_names(new_used_perm & ~c->shared_perm);
if (tighten_restrictions) {
+ if (tighten_restrictions == &abort_on_set_to_true) {
+ abort();
+ }
*tighten_restrictions = true;
}
@@ -2243,6 +2256,9 @@ static int bdrv_check_update_perm(BlockDriverState *bs, BlockReopenQueue *q,
char *perm_names = bdrv_perm_names(c->perm & ~new_shared_perm);
if (tighten_restrictions) {
+ if (tighten_restrictions == &abort_on_set_to_true) {
+ abort();
+ }
*tighten_restrictions = true;
}
@@ -2639,13 +2655,13 @@ static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs)
/* Update permissions for old node. This is guaranteed to succeed
* because we're just taking a parent away, so we're loosening
* restrictions. */
- bool tighten_restrictions;
int ret;
+ assert(abort_on_set_to_true == false);
bdrv_get_cumulative_perm(old_bs, &perm, &shared_perm);
ret = bdrv_check_perm(old_bs, NULL, perm, shared_perm, NULL,
- &tighten_restrictions, NULL);
- assert(tighten_restrictions == false);
+ &abort_on_set_to_true, NULL);
+ assert(abort_on_set_to_true == false);
if (ret < 0) {
/* We only tried to loosen restrictions, so errors are not fatal */
bdrv_abort_perm_update(old_bs);
--
2.21.3
next prev parent reply other threads:[~2020-11-20 16:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-20 16:16 [PATCH RFC 0/5] Fix accidental crash in iotest 30 Vladimir Sementsov-Ogievskiy
2020-11-20 16:16 ` Vladimir Sementsov-Ogievskiy [this message]
2020-11-20 16:16 ` [PATCH 2/5] iotest-30-shorten: concentrate on failing test case Vladimir Sementsov-Ogievskiy
2020-11-20 16:16 ` [PATCH 3/5] scripts/block-coroutine-wrapper.py: allow more function types Vladimir Sementsov-Ogievskiy
2020-11-20 16:16 ` [PATCH 4/5] block: move some mirror and stream handlers to coroutine Vladimir Sementsov-Ogievskiy
2020-11-20 16:16 ` [PATCH 5/5] block: protect some graph-modifyng things by mutex Vladimir Sementsov-Ogievskiy
2020-11-20 16:27 ` [PATCH RFC 0/5] Fix accidental crash in iotest 30 no-reply
2020-11-20 16:35 ` Vladimir Sementsov-Ogievskiy
2020-11-20 16:36 ` Kevin Wolf
2020-11-20 16:43 ` Vladimir Sementsov-Ogievskiy
2020-11-20 17:22 ` Kevin Wolf
2020-11-20 18:19 ` Vladimir Sementsov-Ogievskiy
2020-11-23 10:10 ` Kevin Wolf
2020-11-23 10:29 ` Vladimir Sementsov-Ogievskiy
2020-11-23 11:10 ` Kevin Wolf
2020-11-23 13:44 ` Vladimir Sementsov-Ogievskiy
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=20201120161622.1537-2-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=berto@igalia.com \
--cc=den@openvz.org \
--cc=eblake@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).