block: Require .bdrv_child_perm() with child nodes
authorKevin Wolf <kwolf@redhat.com>
Tue, 20 Dec 2016 22:25:12 +0000 (23:25 +0100)
committerKevin Wolf <kwolf@redhat.com>
Tue, 28 Feb 2017 19:40:36 +0000 (20:40 +0100)
All block drivers that can have child nodes implement .bdrv_child_perm()
now. Make this officially a requirement by asserting that only drivers
without children can omit .bdrv_child_perm().

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Acked-by: Fam Zheng <famz@redhat.com>
block.c

diff --git a/block.c b/block.c
index 281ce7bec36f405348b42657709fdebcc2d55903..52c1f280dcefff92ce3195a76ccc1df0067ea7e0 100644 (file)
--- a/block.c
+++ b/block.c
@@ -1360,8 +1360,9 @@ static int bdrv_check_perm(BlockDriverState *bs, uint64_t cumulative_perms,
                                     cumulative_shared_perms, errp);
     }
 
-    /* Drivers may not have .bdrv_child_perm() */
+    /* Drivers that never have children can omit .bdrv_child_perm() */
     if (!drv->bdrv_child_perm) {
+        assert(QLIST_EMPTY(&bs->children));
         return 0;
     }
 
@@ -1420,8 +1421,9 @@ static void bdrv_set_perm(BlockDriverState *bs, uint64_t cumulative_perms,
         drv->bdrv_set_perm(bs, cumulative_perms, cumulative_shared_perms);
     }
 
-    /* Drivers may not have .bdrv_child_perm() */
+    /* Drivers that never have children can omit .bdrv_child_perm() */
     if (!drv->bdrv_child_perm) {
+        assert(QLIST_EMPTY(&bs->children));
         return;
     }