aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2015-10-19 17:53:13 +0200
committerKevin Wolf <kwolf@redhat.com>2015-10-23 18:18:22 +0200
commit28d7a78996ae73e681d0e061a4be446ed2240c97 (patch)
tree5359ee444ab09d8a59f16e75dce88b94d4a215c9 /block.c
parentdb0284f86a31ec66d138f0f7794321c306af969e (diff)
downloadqemu-arm-28d7a78996ae73e681d0e061a4be446ed2240c97.tar.gz
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>
Diffstat (limited to 'block.c')
-rw-r--r--block.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/block.c b/block.c
index bdd33383e8..bb8c067328 100644
--- a/block.c
+++ b/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;
}
/**