diff mbox

[v3,08/14] block: Introduce BdrvChild.opaque

Message ID 1462973065-9876-9-git-send-email-kwolf@redhat.com
State New, archived
Headers show

Commit Message

Kevin Wolf May 11, 2016, 1:24 p.m. UTC
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>
---
 block/block-backend.c     | 2 ++
 include/block/block_int.h | 1 +
 2 files changed, 3 insertions(+)
diff mbox

Patch

diff --git a/block/block-backend.c b/block/block-backend.c
index b9aaa60..52b7b92 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -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);
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 65f716d..6af541e 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -368,6 +368,7 @@  struct BdrvChild {
     BlockDriverState *bs;
     char *name;
     const BdrvChildRole *role;
+    void *opaque;
     QLIST_ENTRY(BdrvChild) next;
     QLIST_ENTRY(BdrvChild) next_parent;
 };