]> xenbits.xensource.com Git - qemu-xen-unstable.git/commitdiff
block: Add blk_insert_bs()
authorMax Reitz <mreitz@redhat.com>
Mon, 19 Oct 2015 15:53:28 +0000 (17:53 +0200)
committerKevin Wolf <kwolf@redhat.com>
Fri, 23 Oct 2015 16:18:23 +0000 (18:18 +0200)
This function associates the given BlockDriverState with the given
BlockBackend.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/block-backend.c
include/sysemu/block-backend.h

index a5c58c5fd8b16fed2e957090b2a06d773c37dcc1..19fdaaec1a06e4b830e6e9ee0fa881a795ef6a6d 100644 (file)
@@ -333,6 +333,17 @@ void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend *blk)
     }
 }
 
+/*
+ * Associates a new BlockDriverState with @blk.
+ */
+void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs)
+{
+    assert(!blk->bs && !bs->blk);
+    bdrv_ref(bs);
+    blk->bs = bs;
+    bs->blk = blk;
+}
+
 /*
  * Attach device model @dev to @blk.
  * Return 0 on success, -EBUSY when a device model is attached already.
index 52e35a1491163b5fd7149851239a8eb5729171ec..9306a527bb259df7a5bb7135b7666667a6631fed 100644 (file)
@@ -72,6 +72,7 @@ BlockBackend *blk_by_name(const char *name);
 BlockBackend *blk_next(BlockBackend *blk);
 
 BlockDriverState *blk_bs(BlockBackend *blk);
+void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs);
 
 void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend *blk);