block: Introduce BdrvChild.opaque
authorKevin Wolf <kwolf@redhat.com>
Wed, 24 Feb 2016 14:13:35 +0000 (15:13 +0100)
committerKevin Wolf <kwolf@redhat.com>
Thu, 19 May 2016 14:45:30 +0000 (16:45 +0200)
BlockBackends use it to get a back pointer from BdrvChild to
BlockBackend in any BdrvChildRole callbacks.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
block/block-backend.c
include/block/block_int.h

index b9aaa604a646c9bfd0fefa72106f03ecea0d6785..52b7b922c23428e2a89efb990be30559e7d20c14 100644 (file)
@@ -133,6 +133,7 @@ BlockBackend *blk_new_with_bs(Error **errp)
 
     bs = bdrv_new_root();
     blk->root = bdrv_root_attach_child(bs, "root", &child_root);
+    blk->root->opaque = blk;
     bs->blk = blk;
     return blk;
 }
@@ -458,6 +459,7 @@ void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs)
     assert(!blk->root && !bs->blk);
     bdrv_ref(bs);
     blk->root = bdrv_root_attach_child(bs, "root", &child_root);
+    blk->root->opaque = blk;
     bs->blk = blk;
 
     notifier_list_notify(&blk->insert_bs_notifiers, blk);
index 1218857f82580e3bb6553edb44c886ffb23f41e4..47dfafa46281dfdc3c1f61e5517748407a63622d 100644 (file)
@@ -373,6 +373,7 @@ struct BdrvChild {
     BlockDriverState *bs;
     char *name;
     const BdrvChildRole *role;
+    void *opaque;
     QLIST_ENTRY(BdrvChild) next;
     QLIST_ENTRY(BdrvChild) next_parent;
 };