[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 15/25] assertions for blockdev.h global state API
From: |
Emanuele Giuseppe Esposito |
Subject: |
[PATCH v3 15/25] assertions for blockdev.h global state API |
Date: |
Tue, 12 Oct 2021 04:48:56 -0400 |
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 | 2 ++
blockdev.c | 12 ++++++++++++
2 files changed, 14 insertions(+)
diff --git a/block/block-backend.c b/block/block-backend.c
index 6f36a54e82..f2c724b487 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -805,6 +805,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 +816,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 1bf49ef610..f4bde8a8d2 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;
}
@@ -204,6 +206,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
@@ -226,6 +230,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);
/*
@@ -259,6 +265,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));
@@ -270,6 +277,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);
@@ -286,6 +295,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]++);
}
@@ -766,6 +776,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 v3 13/25] include/sysemu/blockdev.h: move drive_add and inline drive_def, (continued)
- [PATCH v3 13/25] include/sysemu/blockdev.h: move drive_add and inline drive_def, Emanuele Giuseppe Esposito, 2021/10/12
- [PATCH v3 12/25] assertions for blockob.h global state API, Emanuele Giuseppe Esposito, 2021/10/12
- [PATCH v3 21/25] block_int-common.h: split function pointers in BdrvChildClass, Emanuele Giuseppe Esposito, 2021/10/12
- [PATCH v3 14/25] include/systemu/blockdev.h: global state API, Emanuele Giuseppe Esposito, 2021/10/12
- [PATCH v3 19/25] block_int-common.h: split function pointers in BlockDriver, Emanuele Giuseppe Esposito, 2021/10/12
- [PATCH v3 17/25] block/copy-before-write.h: global state API + assertions, Emanuele Giuseppe Esposito, 2021/10/12
- [PATCH v3 15/25] assertions for blockdev.h global state API,
Emanuele Giuseppe Esposito <=
- [PATCH v3 16/25] include/block/snapshot: global state API + assertions, Emanuele Giuseppe Esposito, 2021/10/12
- [PATCH v3 20/25] block_int-common.h: assertion in the callers of BlockDriver function pointers, Emanuele Giuseppe Esposito, 2021/10/12
- [PATCH v3 18/25] block/coroutines: I/O API, Emanuele Giuseppe Esposito, 2021/10/12
- [PATCH v3 22/25] block_int-common.h: assertions in the callers of BdrvChildClass function pointers, Emanuele Giuseppe Esposito, 2021/10/12
- [PATCH v3 23/25] block-backend-common.h: split function pointers in BlockDevOps, Emanuele Giuseppe Esposito, 2021/10/12
- [PATCH v3 24/25] job.h: split function pointers in JobDriver, Emanuele Giuseppe Esposito, 2021/10/12
- [PATCH v3 25/25] job.h: assertions in the callers of JobDriver funcion pointers, Emanuele Giuseppe Esposito, 2021/10/12