diff options
author | Kevin Wolf <kwolf@redhat.com> | 2023-09-29 16:51:55 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2023-10-12 16:31:33 +0200 |
commit | b59b466071391cb76b39584e1558be2d0797c054 (patch) | |
tree | e086d7ac7fdec76b82c386c6eb946b85cfa4ea55 /tests/unit | |
parent | 3574499a1e5e420c3e72d0e283cfb2b13bce672e (diff) |
block: Protect bs->parents with graph_lock
Almost all functions that access the parent link already take the graph
lock now. Add locking to the remaining user in a test case and finally
annotate the struct field itself as protected by the graph lock.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20230929145157.45443-21-kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/test-block-iothread.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c index 151049bda5..9b15d2768c 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -471,11 +471,16 @@ static void test_sync_op(const void *opaque) BlockDriverState *bs; BdrvChild *c; + GLOBAL_STATE_CODE(); + blk = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL); bs = bdrv_new_open_driver(&bdrv_test, "base", BDRV_O_RDWR, &error_abort); bs->total_sectors = 65536 / BDRV_SECTOR_SIZE; blk_insert_bs(blk, bs, &error_abort); + + bdrv_graph_rdlock_main_loop(); c = QLIST_FIRST(&bs->parents); + bdrv_graph_rdunlock_main_loop(); blk_set_aio_context(blk, ctx, &error_abort); aio_context_acquire(ctx); |