[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 17/31] assertions for blockdev.h global state API
From: |
Emanuele Giuseppe Esposito |
Subject: |
[PATCH v5 17/31] assertions for blockdev.h global state API |
Date: |
Wed, 24 Nov 2021 01:44:04 -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 | 15 +++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/block/block-backend.c b/block/block-backend.c
index 56670a774f..aad6d9a4c3 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -794,6 +794,7 @@ bool bdrv_is_root_node(BlockDriverState *bs)
*/
DriveInfo *blk_legacy_dinfo(BlockBackend *blk)
{
+ assert(qemu_in_main_thread());
return blk->legacy_dinfo;
}
@@ -805,6 +806,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;
}
@@ -815,6 +817,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 7706919410..eebd9317c2 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 @@ 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
@@ -209,6 +216,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);
/*
@@ -242,6 +251,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));
@@ -253,6 +263,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);
@@ -269,6 +281,7 @@ int drive_get_max_bus(BlockInterfaceType type)
DriveInfo *drive_get_next(BlockInterfaceType type)
{
static int next_block_unit[IF_COUNT];
+ assert(qemu_in_main_thread());
return drive_get(type, 0, next_block_unit[type]++);
}
@@ -749,6 +762,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.27.0
- [PATCH v5 02/31] include/block/block: split header into I/O and global state API, (continued)
- [PATCH v5 02/31] include/block/block: split header into I/O and global state API, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 10/31] block.c: modify .attach and .detach callbacks of child_of_bds, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 08/31] assertions for block_int global state API, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 09/31] block: introduce assert_bdrv_graph_writable, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 07/31] include/block/block_int: split header into I/O and global state API, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 12/31] assertions for blockjob_int.h, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 13/31] block.c: add assertions to static functions, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 11/31] include/block/blockjob_int.h: split header into I/O and GS API, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 14/31] include/block/blockjob.h: global state API, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 15/31] assertions for blockjob.h global state API, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 17/31] assertions for blockdev.h global state API,
Emanuele Giuseppe Esposito <=
- [PATCH v5 19/31] block/copy-before-write.h: global state API + assertions, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 16/31] include/sysemu/blockdev.h: global state API, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 18/31] include/block/snapshot: global state API + assertions, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 22/31] block_int-common.h: assertion in the callers of BlockDriver function pointers, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 24/31] block_int-common.h: assertions in the callers of BdrvChildClass function pointers, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 23/31] block_int-common.h: split function pointers in BdrvChildClass, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 20/31] block/coroutines: I/O API, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 26/31] job.h: split function pointers in JobDriver, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 21/31] block_int-common.h: split function pointers in BlockDriver, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 25/31] block-backend-common.h: split function pointers in BlockDevOps, Emanuele Giuseppe Esposito, 2021/11/24