[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 16/33] assertions for blockdev.h global state API
From: |
Emanuele Giuseppe Esposito |
Subject: |
[PATCH v6 16/33] assertions for blockdev.h global state API |
Date: |
Fri, 21 Jan 2022 12:05:27 -0500 |
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/block-backend.c | 3 +++
blockdev.c | 16 ++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/block/block-backend.c b/block/block-backend.c
index fe56cc1cf4..048ba83f37 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -797,6 +797,7 @@ bool bdrv_is_root_node(BlockDriverState *bs)
*/
DriveInfo *blk_legacy_dinfo(BlockBackend *blk)
{
+ assert(qemu_in_main_thread());
return blk->legacy_dinfo;
}
@@ -808,6 +809,7 @@ DriveInfo *blk_legacy_dinfo(BlockBackend *blk)
DriveInfo *blk_set_legacy_dinfo(BlockBackend *blk, DriveInfo *dinfo)
{
assert(!blk->legacy_dinfo);
+ assert(qemu_in_main_thread());
return blk->legacy_dinfo = dinfo;
}
@@ -818,6 +820,7 @@ DriveInfo *blk_set_legacy_dinfo(BlockBackend *blk,
DriveInfo *dinfo)
BlockBackend *blk_by_legacy_dinfo(DriveInfo *dinfo)
{
BlockBackend *blk = NULL;
+ assert(qemu_in_main_thread());
while ((blk = blk_next(blk)) != NULL) {
if (blk->legacy_dinfo == dinfo) {
diff --git a/blockdev.c b/blockdev.c
index 1bd4bfb3fb..800e95ba54 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -113,6 +113,8 @@ void override_max_devs(BlockInterfaceType type, int
max_devs)
BlockBackend *blk;
DriveInfo *dinfo;
+ assert(qemu_in_main_thread());
+
if (max_devs <= 0) {
return;
}
@@ -142,6 +144,8 @@ void blockdev_mark_auto_del(BlockBackend *blk)
DriveInfo *dinfo = blk_legacy_dinfo(blk);
BlockJob *job;
+ assert(qemu_in_main_thread());
+
if (!dinfo) {
return;
}
@@ -163,6 +167,7 @@ void blockdev_mark_auto_del(BlockBackend *blk)
void blockdev_auto_del(BlockBackend *blk)
{
DriveInfo *dinfo = blk_legacy_dinfo(blk);
+ assert(qemu_in_main_thread());
if (dinfo && dinfo->auto_del) {
monitor_remove_blk(blk);
@@ -187,6 +192,8 @@ QemuOpts *drive_add(BlockInterfaceType type, int index,
const char *file,
{
QemuOpts *opts;
+ assert(qemu_in_main_thread());
+
opts = qemu_opts_parse_noisily(qemu_find_opts("drive"), optstr, false);
if (!opts) {
return NULL;
@@ -207,6 +214,8 @@ DriveInfo *drive_get(BlockInterfaceType type, int bus, int
unit)
BlockBackend *blk;
DriveInfo *dinfo;
+ assert(qemu_in_main_thread());
+
for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
dinfo = blk_legacy_dinfo(blk);
if (dinfo && dinfo->type == type
@@ -229,6 +238,8 @@ void drive_check_orphaned(void)
Location loc;
bool orphans = false;
+ assert(qemu_in_main_thread());
+
for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
dinfo = blk_legacy_dinfo(blk);
/*
@@ -262,6 +273,7 @@ void drive_check_orphaned(void)
DriveInfo *drive_get_by_index(BlockInterfaceType type, int index)
{
+ assert(qemu_in_main_thread());
return drive_get(type,
drive_index_to_bus_id(type, index),
drive_index_to_unit_id(type, index));
@@ -273,6 +285,8 @@ int drive_get_max_bus(BlockInterfaceType type)
BlockBackend *blk;
DriveInfo *dinfo;
+ assert(qemu_in_main_thread());
+
max_bus = -1;
for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
dinfo = blk_legacy_dinfo(blk);
@@ -759,6 +773,8 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType
block_default_type,
const char *filename;
int i;
+ assert(qemu_in_main_thread());
+
/* Change legacy command line options into QMP ones */
static const struct {
const char *from;
--
2.31.1
- [PATCH v6 12/33] block.c: add assertions to static functions, (continued)
- [PATCH v6 12/33] block.c: add assertions to static functions, Emanuele Giuseppe Esposito, 2022/01/21
- [PATCH v6 14/33] assertions for blockjob.h global state API, Emanuele Giuseppe Esposito, 2022/01/21
- [PATCH v6 09/33] block: introduce assert_bdrv_graph_writable, Emanuele Giuseppe Esposito, 2022/01/21
- [PATCH v6 11/33] assertions for blockjob_int.h, Emanuele Giuseppe Esposito, 2022/01/21
- [PATCH v6 29/33] job.h: assertions in the callers of JobDriver funcion pointers, Emanuele Giuseppe Esposito, 2022/01/21
- [PATCH v6 18/33] block/copy-before-write.h: global state API + assertions, Emanuele Giuseppe Esposito, 2022/01/21
- [PATCH v6 24/33] block_int-common.h: assertions in the callers of BlockDriver function pointers, Emanuele Giuseppe Esposito, 2022/01/21
- [PATCH v6 16/33] assertions for blockdev.h global state API,
Emanuele Giuseppe Esposito <=
- [PATCH v6 23/33] block_int-common.h: split function pointers in BlockDriver, Emanuele Giuseppe Esposito, 2022/01/21
- [PATCH v6 22/33] block/coroutines: I/O API, Emanuele Giuseppe Esposito, 2022/01/21
- [PATCH v6 20/33] block: rename bdrv_invalidate_cache_all, blk_invalidate_cache and test_sync_op_invalidate_cache, Emanuele Giuseppe Esposito, 2022/01/21
- Re: [PATCH v6 20/33] block: rename bdrv_invalidate_cache_all, blk_invalidate_cache and test_sync_op_invalidate_cache, Hanna Reitz, 2022/01/26
[PATCH v6 19/33] block: introduce bdrv_activate, Emanuele Giuseppe Esposito, 2022/01/21