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:
parent
db0284f86a
commit
28d7a78996
12
block.c
12
block.c
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user