We currently do not keep track of how many times a child has quiesced its parent. We just guess based on the child’s quiesce_counter. That keeps biting us when we try to leave drained sections or detach children (see e.g. commit 5cb2737e925042e).
I think we need an explicit counter to keep track of how many times a parent has been quiesced (patch 1). That just makes the code more resilient. Actually, no, we don’t need a counter, we need a boolean. See patch 2 for the explanation. Yes, it is a bit weird to introduce a counter first (patch 1) and then immediately make it a boolean (patch 2). But I believe this to be the most logical change set. (“Our current model relies on counting, so adding an explicit counter makes sense. It then turns out that counting is probably not the best idea, so why not make it a boolean?”) Max Reitz (4): block: Introduce BdrvChild.parent_quiesce_counter block: Make @parent_quiesced a bool iotests: Add @has_quit to vm.shutdown() iotests: Test commit with a filter on the chain include/block/block.h | 9 +++--- include/block/block_int.h | 6 ++++ block.c | 18 ++++------- block/io.c | 61 +++++++++++++++++++++++++++++--------- tests/test-bdrv-drain.c | 31 +++++++++++-------- python/qemu/__init__.py | 5 ++-- tests/qemu-iotests/040 | 40 ++++++++++++++++++++++++- tests/qemu-iotests/040.out | 4 +-- tests/qemu-iotests/255 | 2 +- 9 files changed, 126 insertions(+), 50 deletions(-) -- 2.21.0