From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
To: qemu-block@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>, "Fam Zheng" <fam@euphon.net>,
"Vladimir Sementsov-Ogievskiy" <vsementsov@virtuozzo.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Juan Quintela" <quintela@redhat.com>,
qemu-devel@nongnu.org, "John Snow" <jsnow@redhat.com>,
"Emanuele Giuseppe Esposito" <eesposit@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Markus Armbruster" <armbru@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
"Hanna Reitz" <hreitz@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Eric Blake" <eblake@redhat.com>
Subject: [PATCH v4 07/25] assertions for block_int global state API
Date: Mon, 25 Oct 2021 06:17:17 -0400 [thread overview]
Message-ID: <20211025101735.2060852-8-eesposit@redhat.com> (raw)
In-Reply-To: <20211025101735.2060852-1-eesposit@redhat.com>
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block.c | 17 +++++++++++++++++
block/backup.c | 1 +
block/block-backend.c | 3 +++
block/commit.c | 2 ++
block/dirty-bitmap.c | 1 +
block/io.c | 6 ++++++
block/mirror.c | 4 ++++
block/monitor/bitmap-qmp-cmds.c | 6 ++++++
block/stream.c | 2 ++
blockdev.c | 7 +++++++
10 files changed, 49 insertions(+)
diff --git a/block.c b/block.c
index 672f946065..41c5883c5c 100644
--- a/block.c
+++ b/block.c
@@ -653,6 +653,8 @@ int coroutine_fn bdrv_co_create_opts_simple(BlockDriver *drv,
Error *local_err = NULL;
int ret;
+ assert(qemu_in_main_thread());
+
size = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0);
buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
prealloc = qapi_enum_parse(&PreallocMode_lookup, buf,
@@ -2428,6 +2430,8 @@ void bdrv_get_cumulative_perm(BlockDriverState *bs, uint64_t *perm,
uint64_t cumulative_perms = 0;
uint64_t cumulative_shared_perms = BLK_PERM_ALL;
+ assert(qemu_in_main_thread());
+
QLIST_FOREACH(c, &bs->parents, next_parent) {
cumulative_perms |= c->perm;
cumulative_shared_perms &= c->shared_perm;
@@ -2486,6 +2490,8 @@ int bdrv_child_try_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared,
Transaction *tran = tran_new();
int ret;
+ assert(qemu_in_main_thread());
+
bdrv_child_set_perm(c, perm, shared, tran);
ret = bdrv_refresh_perms(c->bs, &local_err);
@@ -2516,6 +2522,8 @@ int bdrv_child_refresh_perms(BlockDriverState *bs, BdrvChild *c, Error **errp)
uint64_t parent_perms, parent_shared;
uint64_t perms, shared;
+ assert(qemu_in_main_thread());
+
bdrv_get_cumulative_perm(bs, &parent_perms, &parent_shared);
bdrv_child_perm(bs, c->bs, c, c->role, NULL,
parent_perms, parent_shared, &perms, &shared);
@@ -2658,6 +2666,7 @@ void bdrv_default_perms(BlockDriverState *bs, BdrvChild *c,
uint64_t perm, uint64_t shared,
uint64_t *nperm, uint64_t *nshared)
{
+ assert(qemu_in_main_thread());
if (role & BDRV_CHILD_FILTERED) {
assert(!(role & (BDRV_CHILD_DATA | BDRV_CHILD_METADATA |
BDRV_CHILD_COW)));
@@ -2984,6 +2993,8 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
BdrvChild *child = NULL;
Transaction *tran = tran_new();
+ assert(qemu_in_main_thread());
+
ret = bdrv_attach_child_common(child_bs, child_name, child_class,
child_role, perm, shared_perm, opaque,
&child, tran, errp);
@@ -6027,6 +6038,8 @@ const char *bdrv_get_parent_name(const BlockDriverState *bs)
BdrvChild *c;
const char *name;
+ assert(qemu_in_main_thread());
+
/* If multiple parents have a name, just pick the first one. */
QLIST_FOREACH(c, &bs->parents, next_parent) {
if (c->klass->get_name) {
@@ -7302,6 +7315,8 @@ bool bdrv_recurse_can_replace(BlockDriverState *bs,
{
BlockDriverState *filtered;
+ assert(qemu_in_main_thread());
+
if (!bs || !bs->drv) {
return false;
}
@@ -7473,6 +7488,7 @@ static bool append_strong_runtime_options(QDict *d, BlockDriverState *bs)
* would result in exactly bs->backing. */
bool bdrv_backing_overridden(BlockDriverState *bs)
{
+ assert(qemu_in_main_thread());
if (bs->backing) {
return strcmp(bs->auto_backing_file,
bs->backing->bs->filename);
@@ -7861,6 +7877,7 @@ static BlockDriverState *bdrv_do_skip_filters(BlockDriverState *bs,
*/
BlockDriverState *bdrv_skip_implicit_filters(BlockDriverState *bs)
{
+ assert(qemu_in_main_thread());
return bdrv_do_skip_filters(bs, true);
}
diff --git a/block/backup.c b/block/backup.c
index 21d5983779..c53041772c 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -372,6 +372,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
assert(bs);
assert(target);
+ assert(qemu_in_main_thread());
/* QMP interface protects us from these cases */
assert(sync_mode != MIRROR_SYNC_MODE_INCREMENTAL);
diff --git a/block/block-backend.c b/block/block-backend.c
index ed45576007..fa30bb88ea 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1087,6 +1087,7 @@ static void blk_root_change_media(BdrvChild *child, bool load)
*/
bool blk_dev_has_removable_media(BlockBackend *blk)
{
+ assert(qemu_in_main_thread());
return !blk->dev || (blk->dev_ops && blk->dev_ops->change_media_cb);
}
@@ -1104,6 +1105,7 @@ bool blk_dev_has_tray(BlockBackend *blk)
*/
void blk_dev_eject_request(BlockBackend *blk, bool force)
{
+ assert(qemu_in_main_thread());
if (blk->dev_ops && blk->dev_ops->eject_request_cb) {
blk->dev_ops->eject_request_cb(blk->dev_opaque, force);
}
@@ -1126,6 +1128,7 @@ bool blk_dev_is_tray_open(BlockBackend *blk)
*/
bool blk_dev_is_medium_locked(BlockBackend *blk)
{
+ assert(qemu_in_main_thread());
if (blk->dev_ops && blk->dev_ops->is_medium_locked) {
return blk->dev_ops->is_medium_locked(blk->dev_opaque);
}
diff --git a/block/commit.c b/block/commit.c
index 45a414a19b..f639eb49c5 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -253,6 +253,8 @@ void commit_start(const char *job_id, BlockDriverState *bs,
uint64_t base_perms, iter_shared_perms;
int ret;
+ assert(qemu_in_main_thread());
+
assert(top != bs);
if (bdrv_skip_filters(top) == bdrv_skip_filters(base)) {
error_setg(errp, "Invalid files for merge: top and base are the same");
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index 0ef46163e3..49462ca121 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -673,6 +673,7 @@ void bdrv_restore_dirty_bitmap(BdrvDirtyBitmap *bitmap, HBitmap *backup)
{
HBitmap *tmp = bitmap->bitmap;
assert(!bdrv_dirty_bitmap_readonly(bitmap));
+ assert(qemu_in_main_thread());
bitmap->bitmap = backup;
hbitmap_free(tmp);
}
diff --git a/block/io.c b/block/io.c
index c5d7f8495e..f271ab3684 100644
--- a/block/io.c
+++ b/block/io.c
@@ -560,6 +560,7 @@ void bdrv_subtree_drained_end(BlockDriverState *bs)
void bdrv_apply_subtree_drain(BdrvChild *child, BlockDriverState *new_parent)
{
int i;
+ assert(qemu_in_main_thread());
for (i = 0; i < new_parent->recursive_quiesce_counter; i++) {
bdrv_do_drained_begin(child->bs, true, child, false, true);
@@ -571,6 +572,8 @@ void bdrv_unapply_subtree_drain(BdrvChild *child, BlockDriverState *old_parent)
int drained_end_counter = 0;
int i;
+ assert(qemu_in_main_thread());
+
for (i = 0; i < old_parent->recursive_quiesce_counter; i++) {
bdrv_do_drained_end(child->bs, true, child, false,
&drained_end_counter);
@@ -690,6 +693,7 @@ void bdrv_drain_all_end_quiesce(BlockDriverState *bs)
{
int drained_end_counter = 0;
+ assert(qemu_in_main_thread());
g_assert(bs->quiesce_counter > 0);
g_assert(!bs->refcnt);
@@ -3419,6 +3423,7 @@ int coroutine_fn bdrv_co_copy_range_from(BdrvChild *src, int64_t src_offset,
{
trace_bdrv_co_copy_range_from(src, src_offset, dst, dst_offset, bytes,
read_flags, write_flags);
+ assert(qemu_in_main_thread());
return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset,
bytes, read_flags, write_flags, true);
}
@@ -3435,6 +3440,7 @@ int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, int64_t src_offset,
{
trace_bdrv_co_copy_range_to(src, src_offset, dst, dst_offset, bytes,
read_flags, write_flags);
+ assert(qemu_in_main_thread());
return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset,
bytes, read_flags, write_flags, false);
}
diff --git a/block/mirror.c b/block/mirror.c
index efec2c7674..00089e519b 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -1880,6 +1880,8 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
bool is_none_mode;
BlockDriverState *base;
+ assert(qemu_in_main_thread());
+
if ((mode == MIRROR_SYNC_MODE_INCREMENTAL) ||
(mode == MIRROR_SYNC_MODE_BITMAP)) {
error_setg(errp, "Sync mode '%s' not supported",
@@ -1905,6 +1907,8 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs,
bool base_read_only;
BlockJob *job;
+ assert(qemu_in_main_thread());
+
base_read_only = bdrv_is_read_only(base);
if (base_read_only) {
diff --git a/block/monitor/bitmap-qmp-cmds.c b/block/monitor/bitmap-qmp-cmds.c
index 9f11deec64..8b8d30287a 100644
--- a/block/monitor/bitmap-qmp-cmds.c
+++ b/block/monitor/bitmap-qmp-cmds.c
@@ -56,6 +56,8 @@ BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *node,
BlockDriverState *bs;
BdrvDirtyBitmap *bitmap;
+ assert(qemu_in_main_thread());
+
if (!node) {
error_setg(errp, "Node cannot be NULL");
return NULL;
@@ -155,6 +157,8 @@ BdrvDirtyBitmap *block_dirty_bitmap_remove(const char *node, const char *name,
BdrvDirtyBitmap *bitmap;
AioContext *aio_context;
+ assert(qemu_in_main_thread());
+
bitmap = block_dirty_bitmap_lookup(node, name, &bs, errp);
if (!bitmap || !bs) {
return NULL;
@@ -261,6 +265,8 @@ BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *target,
BlockDirtyBitmapMergeSourceList *lst;
Error *local_err = NULL;
+ assert(qemu_in_main_thread());
+
dst = block_dirty_bitmap_lookup(node, target, &bs, errp);
if (!dst) {
return NULL;
diff --git a/block/stream.c b/block/stream.c
index 97bee482dc..b85c3742b2 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -216,6 +216,8 @@ void stream_start(const char *job_id, BlockDriverState *bs,
QDict *opts;
int ret;
+ assert(qemu_in_main_thread());
+
assert(!(base && bottom));
assert(!(backing_file_str && bottom));
diff --git a/blockdev.c b/blockdev.c
index ddba382abd..c1f6171c6c 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -69,6 +69,7 @@ QTAILQ_HEAD(, BlockDriverState) monitor_bdrv_states =
void bdrv_set_monitor_owned(BlockDriverState *bs)
{
+ assert(qemu_in_main_thread());
QTAILQ_INSERT_TAIL(&monitor_bdrv_states, bs, monitor_list);
}
@@ -661,6 +662,7 @@ BlockDriverState *bds_tree_init(QDict *bs_opts, Error **errp)
{
int bdrv_flags = 0;
+ assert(qemu_in_main_thread());
/* bdrv_open() defaults to the values in bdrv_flags (for compatibility
* with other callers) rather than what we want as the real defaults.
* Apply the defaults here instead. */
@@ -679,6 +681,7 @@ void blockdev_close_all_bdrv_states(void)
{
BlockDriverState *bs, *next_bs;
+ assert(qemu_in_main_thread());
QTAILQ_FOREACH_SAFE(bs, &monitor_bdrv_states, monitor_list, next_bs) {
AioContext *ctx = bdrv_get_aio_context(bs);
@@ -2332,6 +2335,8 @@ void qmp_transaction(TransactionActionList *dev_list,
BlkActionState *state, *next;
Error *local_err = NULL;
+ assert(qemu_in_main_thread());
+
QTAILQ_HEAD(, BlkActionState) snap_bdrv_states;
QTAILQ_INIT(&snap_bdrv_states);
@@ -3625,6 +3630,8 @@ void qmp_blockdev_del(const char *node_name, Error **errp)
AioContext *aio_context;
BlockDriverState *bs;
+ assert(qemu_in_main_thread());
+
bs = bdrv_find_node(node_name);
if (!bs) {
error_setg(errp, "Failed to find node with node-name='%s'", node_name);
--
2.27.0
next prev parent reply other threads:[~2021-10-25 10:29 UTC|newest]
Thread overview: 86+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-25 10:17 [PATCH v4 00/25] block layer: split block APIs in global state and I/O Emanuele Giuseppe Esposito
2021-10-25 10:17 ` [PATCH v4 01/25] main-loop.h: introduce qemu_in_main_thread() Emanuele Giuseppe Esposito
2021-10-25 11:33 ` Philippe Mathieu-Daudé
2021-10-25 10:17 ` [PATCH v4 02/25] include/block/block: split header into I/O and global state API Emanuele Giuseppe Esposito
2021-10-25 11:37 ` Philippe Mathieu-Daudé
2021-10-25 12:22 ` Emanuele Giuseppe Esposito
2021-11-11 15:00 ` Hanna Reitz
2021-11-15 12:08 ` Emanuele Giuseppe Esposito
2021-11-12 12:25 ` Hanna Reitz
2021-11-16 14:00 ` Emanuele Giuseppe Esposito
2021-10-25 10:17 ` [PATCH v4 03/25] assertions for block " Emanuele Giuseppe Esposito
2021-11-11 16:32 ` Hanna Reitz
2021-11-15 12:27 ` Emanuele Giuseppe Esposito
2021-11-15 15:27 ` Hanna Reitz
2021-11-12 11:31 ` Hanna Reitz
2021-10-25 10:17 ` [PATCH v4 04/25] include/sysemu/block-backend: split header into I/O and global state (GS) API Emanuele Giuseppe Esposito
2021-11-12 10:23 ` Hanna Reitz
2021-11-16 10:16 ` Emanuele Giuseppe Esposito
2021-11-12 12:30 ` Hanna Reitz
2021-11-16 14:24 ` Emanuele Giuseppe Esposito
2021-11-16 15:07 ` Hanna Reitz
2021-10-25 10:17 ` [PATCH v4 05/25] block/block-backend.c: assertions for block-backend Emanuele Giuseppe Esposito
2021-11-12 11:01 ` Hanna Reitz
2021-11-16 10:15 ` Emanuele Giuseppe Esposito
2021-11-16 12:29 ` Hanna Reitz
2021-10-25 10:17 ` [PATCH v4 06/25] include/block/block_int: split header into I/O and global state API Emanuele Giuseppe Esposito
2021-11-12 12:17 ` Hanna Reitz
2021-11-16 10:24 ` Emanuele Giuseppe Esposito
2021-11-16 12:30 ` Hanna Reitz
2021-10-25 10:17 ` Emanuele Giuseppe Esposito [this message]
2021-11-12 13:51 ` [PATCH v4 07/25] assertions for block_int " Hanna Reitz
2021-11-16 15:43 ` Emanuele Giuseppe Esposito
2021-11-16 16:46 ` Hanna Reitz
2021-10-25 10:17 ` [PATCH v4 08/25] block: introduce assert_bdrv_graph_writable Emanuele Giuseppe Esposito
2021-11-12 14:40 ` Hanna Reitz
2021-11-18 9:55 ` Emanuele Giuseppe Esposito
2021-11-18 10:24 ` Emanuele Giuseppe Esposito
2021-11-18 15:17 ` Hanna Reitz
2021-11-19 8:55 ` Emanuele Giuseppe Esposito
2021-10-25 10:17 ` [PATCH v4 09/25] include/block/blockjob_int.h: split header into I/O and GS API Emanuele Giuseppe Esposito
2021-10-25 10:17 ` [PATCH v4 10/25] assertions for blockjob_int.h Emanuele Giuseppe Esposito
2021-11-12 15:17 ` Hanna Reitz
2021-10-25 10:17 ` [PATCH v4 11/25] include/block/blockjob.h: global state API Emanuele Giuseppe Esposito
2021-10-25 10:17 ` [PATCH v4 12/25] assertions for blockob.h " Emanuele Giuseppe Esposito
2021-11-12 15:26 ` Hanna Reitz
2021-10-25 10:17 ` [PATCH v4 13/25] include/sysemu/blockdev.h: move drive_add and inline drive_def Emanuele Giuseppe Esposito
2021-11-12 15:41 ` Hanna Reitz
2021-10-25 10:17 ` [PATCH v4 14/25] include/systemu/blockdev.h: global state API Emanuele Giuseppe Esposito
2021-10-28 15:48 ` Stefan Hajnoczi
2021-11-12 15:46 ` Hanna Reitz
2021-10-25 10:17 ` [PATCH v4 15/25] assertions for blockdev.h " Emanuele Giuseppe Esposito
2021-10-25 10:17 ` [PATCH v4 16/25] include/block/snapshot: global state API + assertions Emanuele Giuseppe Esposito
2021-10-25 10:17 ` [PATCH v4 17/25] block/copy-before-write.h: " Emanuele Giuseppe Esposito
2021-10-25 10:17 ` [PATCH v4 18/25] block/coroutines: I/O API Emanuele Giuseppe Esposito
2021-10-25 10:17 ` [PATCH v4 19/25] block_int-common.h: split function pointers in BlockDriver Emanuele Giuseppe Esposito
2021-11-15 12:00 ` Hanna Reitz
2021-11-18 12:42 ` Emanuele Giuseppe Esposito
2021-10-25 10:17 ` [PATCH v4 20/25] block_int-common.h: assertion in the callers of BlockDriver function pointers Emanuele Giuseppe Esposito
2021-11-15 12:48 ` Hanna Reitz
2021-11-15 14:15 ` Hanna Reitz
2021-11-17 11:33 ` Emanuele Giuseppe Esposito
2021-11-17 12:51 ` Hanna Reitz
2021-11-17 13:09 ` Emanuele Giuseppe Esposito
2021-11-17 13:34 ` Hanna Reitz
2021-10-25 10:17 ` [PATCH v4 21/25] block_int-common.h: split function pointers in BdrvChildClass Emanuele Giuseppe Esposito
2021-11-15 14:36 ` Hanna Reitz
2021-10-25 10:17 ` [PATCH v4 22/25] block_int-common.h: assertions in the callers of BdrvChildClass function pointers Emanuele Giuseppe Esposito
2021-11-15 14:48 ` Hanna Reitz
2021-10-25 10:17 ` [PATCH v4 23/25] block-backend-common.h: split function pointers in BlockDevOps Emanuele Giuseppe Esposito
2021-10-25 14:10 ` Philippe Mathieu-Daudé
2021-10-25 10:17 ` [PATCH v4 24/25] job.h: split function pointers in JobDriver Emanuele Giuseppe Esposito
2021-11-15 15:11 ` Hanna Reitz
2021-11-17 13:43 ` Emanuele Giuseppe Esposito
2021-11-17 13:44 ` Hanna Reitz
2021-10-25 10:17 ` [PATCH v4 25/25] job.h: assertions in the callers of JobDriver funcion pointers Emanuele Giuseppe Esposito
2021-10-25 14:09 ` [PATCH v4 00/25] block layer: split block APIs in global state and I/O Philippe Mathieu-Daudé
2021-10-28 15:45 ` Stefan Hajnoczi
2021-10-28 15:49 ` Stefan Hajnoczi
2021-11-15 16:03 ` Hanna Reitz
2021-11-15 16:11 ` Daniel P. Berrangé
2021-11-18 13:50 ` Paolo Bonzini
2021-11-18 15:31 ` Hanna Reitz
2021-11-19 3:13 ` Paolo Bonzini
2021-11-19 10:42 ` Emanuele Giuseppe Esposito
2021-11-18 14:04 ` Paolo Bonzini
2021-11-18 15:22 ` Hanna Reitz
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=20211025101735.2060852-8-eesposit@redhat.com \
--to=eesposit@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=ehabkost@redhat.com \
--cc=fam@euphon.net \
--cc=hreitz@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=richard.henderson@linaro.org \
--cc=stefanha@redhat.com \
--cc=vsementsov@virtuozzo.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).