@@ -1042,7 +1042,7 @@ struct BdrvChild {
*/
bool quiesced_parent;
- QLIST_ENTRY(BdrvChild) next;
+ QLIST_ENTRY(BdrvChild GRAPH_RDLOCK_PTR) next;
QLIST_ENTRY(BdrvChild GRAPH_RDLOCK_PTR) next_parent;
};
@@ -1176,7 +1176,7 @@ struct BlockDriverState {
* See also comment in include/block/block.h, to learn how backing and file
* are connected with BdrvChildRole.
*/
- QLIST_HEAD(, BdrvChild) children;
+ QLIST_HEAD(, BdrvChild GRAPH_RDLOCK_PTR) children;
BdrvChild *backing;
BdrvChild *file;
@@ -2973,6 +2973,8 @@ static void bdrv_child_free(BdrvChild *child)
{
assert(!child->bs);
GLOBAL_STATE_CODE();
+ GRAPH_RDLOCK_GUARD_MAINLOOP();
+
assert(!child->next.le_prev); /* not in children list */
g_free(child->name);
@@ -430,7 +430,8 @@ static void backup_job_completed(void *opaque, int ret)
backup_job_cleanup(bs);
}
-static bool check_top_bs(BlockDriverState *top_bs, BlockDriverState *bs)
+static bool GRAPH_RDLOCK
+check_top_bs(BlockDriverState *top_bs, BlockDriverState *bs)
{
BdrvChild *child;
@@ -1034,9 +1034,13 @@ static void coroutine_fn test_co_delete_by_drain(void *opaque)
blk_co_unref(blk);
} else {
BdrvChild *c, *next_c;
+ bdrv_graph_co_rdlock();
QLIST_FOREACH_SAFE(c, &bs->children, next, next_c) {
+ bdrv_graph_co_rdunlock();
bdrv_co_unref_child(bs, c);
+ bdrv_graph_co_rdlock();
}
+ bdrv_graph_co_rdunlock();
}
dbdd->done = true;