Message ID | 20211005143215.29500-15-eesposit@redhat.com |
---|---|
State | New |
Headers | show |
Series | block layer: split block APIs in global state and I/O | expand |
On 05/10/21 16:32, Emanuele Giuseppe Esposito wrote: > Signed-off-by: Emanuele Giuseppe Esposito <eesposit@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 9f09245069..18791c4fdc 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); > + g_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; > + g_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 5608b78f8f..917bcf8cbc 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -114,6 +114,8 @@ void override_max_devs(BlockInterfaceType type, int max_devs) > BlockBackend *blk; > DriveInfo *dinfo; > > + g_assert(qemu_in_main_thread()); > + > if (max_devs <= 0) { > return; > } > @@ -230,6 +232,8 @@ DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit) > BlockBackend *blk; > DriveInfo *dinfo; > > + g_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 > @@ -252,6 +256,8 @@ void drive_check_orphaned(void) > Location loc; > bool orphans = false; > > + g_assert(qemu_in_main_thread()); > + > for (blk = blk_next(NULL); blk; blk = blk_next(blk)) { > dinfo = blk_legacy_dinfo(blk); > /* > @@ -285,6 +291,7 @@ void drive_check_orphaned(void) > > DriveInfo *drive_get_by_index(BlockInterfaceType type, int index) > { > + g_assert(qemu_in_main_thread()); > return drive_get(type, > drive_index_to_bus_id(type, index), > drive_index_to_unit_id(type, index)); > @@ -296,6 +303,8 @@ int drive_get_max_bus(BlockInterfaceType type) > BlockBackend *blk; > DriveInfo *dinfo; > > + g_assert(qemu_in_main_thread()); > + > max_bus = -1; > for (blk = blk_next(NULL); blk; blk = blk_next(blk)) { > dinfo = blk_legacy_dinfo(blk); > @@ -312,6 +321,7 @@ int drive_get_max_bus(BlockInterfaceType type) > DriveInfo *drive_get_next(BlockInterfaceType type) > { > static int next_block_unit[IF_COUNT]; > + g_assert(qemu_in_main_thread()); > > return drive_get(type, 0, next_block_unit[type]++); > } > @@ -792,6 +802,8 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type, > const char *filename; > int i; > > + g_assert(qemu_in_main_thread()); > + > /* Change legacy command line options into QMP ones */ > static const struct { > const char *from; > Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
On Tue, Oct 05, 2021 at 10:32:04AM -0400, Emanuele Giuseppe Esposito wrote: > Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> > --- > block/block-backend.c | 2 ++ > blockdev.c | 12 ++++++++++++ > 2 files changed, 14 insertions(+) Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
diff --git a/block/block-backend.c b/block/block-backend.c index 9f09245069..18791c4fdc 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); + g_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; + g_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 5608b78f8f..917bcf8cbc 100644 --- a/blockdev.c +++ b/blockdev.c @@ -114,6 +114,8 @@ void override_max_devs(BlockInterfaceType type, int max_devs) BlockBackend *blk; DriveInfo *dinfo; + g_assert(qemu_in_main_thread()); + if (max_devs <= 0) { return; } @@ -230,6 +232,8 @@ DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit) BlockBackend *blk; DriveInfo *dinfo; + g_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 @@ -252,6 +256,8 @@ void drive_check_orphaned(void) Location loc; bool orphans = false; + g_assert(qemu_in_main_thread()); + for (blk = blk_next(NULL); blk; blk = blk_next(blk)) { dinfo = blk_legacy_dinfo(blk); /* @@ -285,6 +291,7 @@ void drive_check_orphaned(void) DriveInfo *drive_get_by_index(BlockInterfaceType type, int index) { + g_assert(qemu_in_main_thread()); return drive_get(type, drive_index_to_bus_id(type, index), drive_index_to_unit_id(type, index)); @@ -296,6 +303,8 @@ int drive_get_max_bus(BlockInterfaceType type) BlockBackend *blk; DriveInfo *dinfo; + g_assert(qemu_in_main_thread()); + max_bus = -1; for (blk = blk_next(NULL); blk; blk = blk_next(blk)) { dinfo = blk_legacy_dinfo(blk); @@ -312,6 +321,7 @@ int drive_get_max_bus(BlockInterfaceType type) DriveInfo *drive_get_next(BlockInterfaceType type) { static int next_block_unit[IF_COUNT]; + g_assert(qemu_in_main_thread()); return drive_get(type, 0, next_block_unit[type]++); } @@ -792,6 +802,8 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type, const char *filename; int i; + g_assert(qemu_in_main_thread()); + /* Change legacy command line options into QMP ones */ static const struct { const char *from;
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> --- block/block-backend.c | 2 ++ blockdev.c | 12 ++++++++++++ 2 files changed, 14 insertions(+)