Am 19.04.2016 um 03:42 hat Fam Zheng geschrieben:
> Currently we only inactivate the top BDS. Actually bdrv_inactivate
> should be the opposite of bdrv_invalidate_cache.
>
> Recurse into the whole subtree instead.
>
> Signed-off-by: Fam Zheng <[email protected]>
Did you actually test this?
I would expect that bs->drv->bdrv_inactivate() fails now (as in
assertion failure) if it has anything to flush to the image because
bs->file has already be inactivated before. I think children need to be
inactived after their parents.
Nodes with multiple parents could actually become even more
interesting...
Kevin
> block.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/block.c b/block.c
> index fa8b38f..9a84ed1 100644
> --- a/block.c
> +++ b/block.c
> @@ -3260,8 +3260,16 @@ void bdrv_invalidate_cache_all(Error **errp)
>
> static int bdrv_inactivate(BlockDriverState *bs)
> {
> + BdrvChild *child;
> int ret;
>
> + QLIST_FOREACH(child, &bs->children, next) {
> + ret = bdrv_inactivate(child->bs);
> + if (ret < 0) {
> + return ret;
> + }
> + }
> +
> if (bs->drv->bdrv_inactivate) {
> ret = bs->drv->bdrv_inactivate(bs);
> if (ret < 0) {
> --
> 2.8.0
>