]> Git Repo - qemu.git/commitdiff
block: Make bdrv_is_inserted() recursive
authorMax Reitz <[email protected]>
Mon, 19 Oct 2015 15:53:13 +0000 (17:53 +0200)
committerKevin Wolf <[email protected]>
Fri, 23 Oct 2015 16:18:22 +0000 (18:18 +0200)
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 <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
block.c

diff --git a/block.c b/block.c
index bdd33383e8caaf97212644250b9d8ad7a7ecb047..bb8c06732875f2bc7657ceab4ac3805427a562d4 100644 (file)
--- 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;
 }
 
 /**
This page took 0.032706 seconds and 4 git commands to generate.