block: Make bdrv_is_inserted() recursive

If bdrv_is_inserted() is called on the top level BDS, it should make
sure all nodes in the BDS tree are actually inserted.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Max Reitz 2015-10-19 17:53:13 +02:00 committed by Kevin Wolf
parent db0284f86a
commit 28d7a78996
1 changed files with 9 additions and 3 deletions

12
block.c
View File

@ -3143,14 +3143,20 @@ void bdrv_invalidate_cache_all(Error **errp)
bool bdrv_is_inserted(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
BdrvChild *child;
if (!drv) {
return false;
}
if (!drv->bdrv_is_inserted) {
return true;
if (drv->bdrv_is_inserted) {
return drv->bdrv_is_inserted(bs);
}
return drv->bdrv_is_inserted(bs);
QLIST_FOREACH(child, &bs->children, next) {
if (!bdrv_is_inserted(child->bs)) {
return false;
}
}
return true;
}
/**